Documentation ¶
Index ¶
- Constants
- type MessageQueue
- func (mq *MessageQueue) Close()
- func (mq *MessageQueue) Count() (uint64, error)
- func (mq *MessageQueue) Destroy() error
- func (mq *MessageQueue) ReceiveBytes(msgType int, flags int) ([]byte, int, error)
- func (mq *MessageQueue) ReceiveString(msgType int, flags int) (string, int, error)
- func (mq *MessageQueue) SendBytes(message []byte, msgType int, flags int) error
- func (mq *MessageQueue) SendString(message string, msgType int, flags int) error
- func (mq *MessageQueue) Size() (uint64, error)
- func (mq *MessageQueue) Stat() (*QueueStats, error)
- type QueueConfig
- type QueuePermissions
- type QueueStats
Examples ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageQueue ¶
type MessageQueue struct {
// contains filtered or unexported fields
}
Represents the message queue
Example ¶
mq, err := NewMessageQueue(&QueueConfig{ Key: 0xDEADBEEF, MaxSize: 1024, Mode: IPC_CREAT | 0600, }) if err != nil { fmt.Println(err) } err = mq.SendBytes([]byte("Hello World"), 1, IPC_NOWAIT) if err != nil { fmt.Println(err) } response, _, err := mq.ReceiveBytes(0, IPC_NOWAIT) if err != nil { fmt.Println(err) } fmt.Println(string(response))
Output: Hello World
func NewMessageQueue ¶
func NewMessageQueue(config *QueueConfig) (*MessageQueue, error)
NewMessageQueue returns an instance of the message queue given a QueueConfig.
func (*MessageQueue) Close ¶
func (mq *MessageQueue) Close()
Frees up the resources associated with the message queue, but it will leave the message wueue itself in place.
func (*MessageQueue) Count ¶
func (mq *MessageQueue) Count() (uint64, error)
Number of messages currently in the queue.
func (*MessageQueue) Destroy ¶
func (mq *MessageQueue) Destroy() error
Get statistics about the message queue.
func (*MessageQueue) ReceiveBytes ¶
Receive a []byte message with the type specified by the integer argument. Pass 0 to retrieve the message at the top of the queue, regardless of type.
func (*MessageQueue) ReceiveString ¶
Receive a string message with the type specified by the integer argument. Pass 0 to retrieve the message at the top of the queue, regardless of type.
func (*MessageQueue) SendBytes ¶
func (mq *MessageQueue) SendBytes(message []byte, msgType int, flags int) error
Sends a []byte message to the queue of the type passed as the second argument.
func (*MessageQueue) SendString ¶
func (mq *MessageQueue) SendString(message string, msgType int, flags int) error
Sends a string message to the queue of the type passed as the second argument.
func (*MessageQueue) Size ¶
func (mq *MessageQueue) Size() (uint64, error)
Size of the queue in bytes.
func (*MessageQueue) Stat ¶
func (mq *MessageQueue) Stat() (*QueueStats, error)
Get statistics about the message queue.
type QueueConfig ¶
type QueueConfig struct { Mode int // The mode of the message queue, e.g. 0600 MaxSize int // Size of the largest message to retrieve or send, allocates a buffer of this size Key int // SysV IPC key Path string // The path to a file to obtain a SysV IPC key if Key is not set ProjId int // ProjId for ftok to generate a SysV IPC key if Key is not set }
QueueConfig is used to configure an instance of the message queue.
type QueuePermissions ¶
type QueuePermissions struct { Uid uint32 // unsigned int32, according to bits/typesizes.h Gid uint32 // Cuid uint32 // Cgid uint32 // Mode uint16 // unsigned short, according to msgctl(2) }
Wraps the C structure "struct ipc_perm" (see msgctl(2))
type QueueStats ¶
type QueueStats struct { Perm QueuePermissions Stime int64 // signed long, according to bits/types.h // Rtime int64 // https://github.com/Shopify/sysv_mq/issues/10 Ctime int64 // Cbytes uint64 // unsigned long, according to msgctl(2) Qnum uint64 // unsigned long, according to bits/msq.h Qbytes uint64 // unsigned long, according to bits/msg.h Lspid int32 // signed int32, according to bits/typesizes.h Lrpid int32 // }
Wraps the C structure "struct msgid_ds" (see msgctl(2))