Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultMessageSize() (int, error)
- func DefaultQueueSize() (int, error)
- func MaxMessageSize() (int, error)
- func MaxQueueSize() (int, error)
- func MaxQueues() (int, error)
- func RawClose(mqd int) error
- func RawNotify(mq int, notify *Notify) error
- func RawOpen(name string, oflag OpenFlag, mode int, attr *Attributes) (int, error)
- func RawSendReceive[P uint | *uint](mqd int, dl deadline.Deadline, buf []byte, priority P) (int, error)
- func RawUnlink(name string) error
- func ValidateName(name string) (string, error)
- type AttributeFlag
- type Attributes
- type ErrBadFileDescriptor
- type ErrGetSetAttrInvalidFlags
- type ErrNameContainedMultipleSlash
- type ErrNameEmpty
- type ErrNameInvalid
- type ErrNameTooLong
- type ErrNoMemory
- type ErrNotifyBusy
- type ErrNotifyInvalid
- type ErrOpenBadAccess
- type ErrOpenExists
- type ErrOpenInvalid
- type ErrOpenNoEntry
- type ErrOpenNoSpace
- type ErrOpenProcessLimitReached
- type ErrOpenSystemLimitReached
- type ErrReceiveInvalidFileDescriptor
- type ErrRecvEmptyQueue
- type ErrRecvInvalidMessageSize
- type ErrSendFullQueue
- type ErrSendInvalidFileDescriptor
- type ErrSendInvalidMessageSize
- type ErrSendRecvInterrupted
- type ErrSendRecvInvalidTimeout
- type ErrSendRecvTimeout
- type ErrUnlinkNoMessageQueue
- type ErrUnlinkNoPermission
- type MQ
- func (mq *MQ) Close() error
- func (mq *MQ) GetAttr() (oldValue Attributes, _ error)
- func (mq *MQ) Mode() int
- func (mq *MQ) Mqd() int
- func (mq *MQ) Name() string
- func (mq *MQ) Notify(sig unix.Signal) error
- func (mq *MQ) Oflag() OpenFlag
- func (mq *MQ) Receive(dl deadline.Deadline) (data []byte, priority uint, _ error)
- func (mq *MQ) Send(dl deadline.Deadline, data []byte, priority uint) error
- func (mq *MQ) SetBlocking(blocking bool) (Attributes, error)
- func (mq *MQ) Unlink() error
- type MQOption
- type Notify
- type OpenFlag
Constants ¶
const ( AttributeNonBlocking = AttributeFlag(OpenNonBlocking) AttributeBlocking = AttributeFlag(0) )
Variables ¶
var ( NotifyNone int // Registers a handler but sends no signal NotifySignal int )
Functions ¶
func DefaultMessageSize ¶
func DefaultQueueSize ¶
func MaxMessageSize ¶
func MaxQueueSize ¶
func RawOpen ¶
RawOpen validates the name and opens a message queue. One of OpenReadOnly, OpenWriteOnly, or OpenReadWrite must be set. If opening with OpenCreate mode and attr must be set.
func RawSendReceive ¶
func RawSendReceive[P uint | *uint](mqd int, dl deadline.Deadline, buf []byte, priority P) (int, error)
RawSendReceive sends or receives a message depending on the type of P.
- uint: Sends buf with the priority to mpd. On success (0, nil) is returned.
- *uint: Receives into buf from mqd and stores the priority in the provided pointer. The int returned is the size of the message.
If dl does not return a Deadline, the operation will block unless OpenNonBlocking was specified.
func RawUnlink ¶
RawUnlink removes the message queue with the specified name from the system. The system will free the queue once all instances are closed.
func ValidateName ¶
ValidateName checks if a name is valid and returns it without the initial slash. The name must start with '/', be non-empty, and contain no other '/' characters.
Types ¶
type AttributeFlag ¶
type AttributeFlag OpenFlag
func (AttributeFlag) String ¶
func (af AttributeFlag) String() string
String converts the AttributeFlag to a human-readable string.
type Attributes ¶
type Attributes struct { // Flags can only be 0 or [OpenNonBlocking]. Flags AttributeFlag `json:"mq_flags"` // MaxQueueSize is the max size of the queue. MaxQueueSize int `json:"mq_maxmsg"` // MaxMessageSize is the max size of a message. MaxMessageSize int `json:"mq_msgsize"` // NumCurrMessages is the number of messages in the queue. NumCurrMessages int `json:"mq_curmsgs"` }
func RawGetSetAttributes ¶
func RawGetSetAttributes(mqd int, newAttr *Attributes) (attr Attributes, err error)
RawGetSetAttributes retrieves or modifies the attributes of a message queue. - If newAttr is nil, it retrieves the current attributes of the queue. - If newAttr is provided, it updates the blocking flag and returns the attributes before the change.
type ErrBadFileDescriptor ¶
type ErrBadFileDescriptor struct { sys.Err[ErrBadFileDescriptor] }
func (ErrBadFileDescriptor) Errno ¶
func (e ErrBadFileDescriptor) Errno() unix.Errno
func (ErrBadFileDescriptor) Error ¶
func (e ErrBadFileDescriptor) Error() string
type ErrGetSetAttrInvalidFlags ¶
type ErrGetSetAttrInvalidFlags struct { sys.Err[ErrGetSetAttrInvalidFlags] }
func (ErrGetSetAttrInvalidFlags) Errno ¶
func (ErrGetSetAttrInvalidFlags) Errno() unix.Errno
func (ErrGetSetAttrInvalidFlags) Error ¶
func (ErrGetSetAttrInvalidFlags) Error() string
type ErrNameContainedMultipleSlash ¶
type ErrNameContainedMultipleSlash struct { sys.Err[ErrNameContainedMultipleSlash] }
func (ErrNameContainedMultipleSlash) Errno ¶
func (ErrNameContainedMultipleSlash) Errno() unix.Errno
func (ErrNameContainedMultipleSlash) Error ¶
func (ErrNameContainedMultipleSlash) Error() string
type ErrNameEmpty ¶
type ErrNameEmpty struct { sys.Err[ErrNameEmpty] }
func (ErrNameEmpty) Errno ¶
func (ErrNameEmpty) Errno() unix.Errno
func (ErrNameEmpty) Error ¶
func (ErrNameEmpty) Error() string
type ErrNameInvalid ¶
type ErrNameInvalid struct { sys.Err[ErrNameInvalid] }
func (ErrNameInvalid) Errno ¶
func (ErrNameInvalid) Errno() unix.Errno
func (ErrNameInvalid) Error ¶
func (ErrNameInvalid) Error() string
type ErrNameTooLong ¶
type ErrNameTooLong struct { sys.Err[ErrNameTooLong] }
func (ErrNameTooLong) Errno ¶
func (err ErrNameTooLong) Errno() unix.Errno
func (ErrNameTooLong) Error ¶
func (err ErrNameTooLong) Error() string
type ErrNoMemory ¶
type ErrNoMemory struct { sys.Err[ErrNoMemory] }
func (ErrNoMemory) Errno ¶
func (err ErrNoMemory) Errno() unix.Errno
func (ErrNoMemory) Error ¶
func (err ErrNoMemory) Error() string
type ErrNotifyBusy ¶
type ErrNotifyBusy struct { sys.Err[ErrNotifyBusy] }
func (ErrNotifyBusy) Errno ¶
func (ErrNotifyBusy) Errno() unix.Errno
func (ErrNotifyBusy) Error ¶
func (ErrNotifyBusy) Error() string
type ErrNotifyInvalid ¶
type ErrNotifyInvalid struct { sys.Err[ErrNotifyInvalid] }
func (ErrNotifyInvalid) Errno ¶
func (ErrNotifyInvalid) Errno() unix.Errno
func (ErrNotifyInvalid) Error ¶
func (ErrNotifyInvalid) Error() string
type ErrOpenBadAccess ¶
type ErrOpenBadAccess struct { sys.Err[ErrOpenBadAccess] }
func (ErrOpenBadAccess) Errno ¶
func (ErrOpenBadAccess) Errno() unix.Errno
func (ErrOpenBadAccess) Error ¶
func (ErrOpenBadAccess) Error() string
type ErrOpenExists ¶
type ErrOpenExists struct { sys.Err[ErrOpenExists] }
func (ErrOpenExists) Errno ¶
func (ErrOpenExists) Errno() unix.Errno
func (ErrOpenExists) Error ¶
func (ErrOpenExists) Error() string
type ErrOpenInvalid ¶
type ErrOpenInvalid struct { sys.Err[ErrOpenInvalid] }
func (ErrOpenInvalid) Errno ¶
func (ErrOpenInvalid) Errno() unix.Errno
func (ErrOpenInvalid) Error ¶
func (ErrOpenInvalid) Error() string
type ErrOpenNoEntry ¶
type ErrOpenNoEntry struct { sys.Err[ErrOpenNoEntry] }
func (ErrOpenNoEntry) Errno ¶
func (ErrOpenNoEntry) Errno() unix.Errno
func (ErrOpenNoEntry) Error ¶
func (ErrOpenNoEntry) Error() string
type ErrOpenNoSpace ¶
type ErrOpenNoSpace struct { sys.Err[ErrOpenNoSpace] }
func (ErrOpenNoSpace) Errno ¶
func (ErrOpenNoSpace) Errno() unix.Errno
func (ErrOpenNoSpace) Error ¶
func (ErrOpenNoSpace) Error() string
type ErrOpenProcessLimitReached ¶
type ErrOpenProcessLimitReached struct { sys.Err[ErrOpenProcessLimitReached] }
func (ErrOpenProcessLimitReached) Errno ¶
func (ErrOpenProcessLimitReached) Errno() unix.Errno
func (ErrOpenProcessLimitReached) Error ¶
func (ErrOpenProcessLimitReached) Error() string
type ErrOpenSystemLimitReached ¶
type ErrOpenSystemLimitReached struct { sys.Err[ErrOpenSystemLimitReached] }
func (ErrOpenSystemLimitReached) Errno ¶
func (ErrOpenSystemLimitReached) Errno() unix.Errno
func (ErrOpenSystemLimitReached) Error ¶
func (ErrOpenSystemLimitReached) Error() string
type ErrReceiveInvalidFileDescriptor ¶
type ErrReceiveInvalidFileDescriptor struct { sys.Err[ErrReceiveInvalidFileDescriptor] }
func (ErrReceiveInvalidFileDescriptor) Errno ¶
func (ErrReceiveInvalidFileDescriptor) Errno() unix.Errno
func (ErrReceiveInvalidFileDescriptor) Error ¶
func (ErrReceiveInvalidFileDescriptor) Error() string
type ErrRecvEmptyQueue ¶
type ErrRecvEmptyQueue struct { sys.Err[ErrRecvEmptyQueue] }
func (ErrRecvEmptyQueue) Errno ¶
func (ErrRecvEmptyQueue) Errno() unix.Errno
func (ErrRecvEmptyQueue) Error ¶
func (ErrRecvEmptyQueue) Error() string
type ErrRecvInvalidMessageSize ¶
type ErrRecvInvalidMessageSize struct { sys.Err[ErrRecvInvalidMessageSize] }
func (ErrRecvInvalidMessageSize) Errno ¶
func (ErrRecvInvalidMessageSize) Errno() unix.Errno
func (ErrRecvInvalidMessageSize) Error ¶
func (ErrRecvInvalidMessageSize) Error() string
type ErrSendFullQueue ¶
type ErrSendFullQueue struct { sys.Err[ErrSendFullQueue] }
func (ErrSendFullQueue) Errno ¶
func (ErrSendFullQueue) Errno() unix.Errno
func (ErrSendFullQueue) Error ¶
func (ErrSendFullQueue) Error() string
type ErrSendInvalidFileDescriptor ¶
type ErrSendInvalidFileDescriptor struct { sys.Err[ErrSendInvalidFileDescriptor] }
func (ErrSendInvalidFileDescriptor) Errno ¶
func (ErrSendInvalidFileDescriptor) Errno() unix.Errno
func (ErrSendInvalidFileDescriptor) Error ¶
func (ErrSendInvalidFileDescriptor) Error() string
type ErrSendInvalidMessageSize ¶
type ErrSendInvalidMessageSize struct { sys.Err[ErrSendInvalidMessageSize] }
func (ErrSendInvalidMessageSize) Errno ¶
func (ErrSendInvalidMessageSize) Errno() unix.Errno
func (ErrSendInvalidMessageSize) Error ¶
func (ErrSendInvalidMessageSize) Error() string
type ErrSendRecvInterrupted ¶
type ErrSendRecvInterrupted struct { sys.Err[ErrSendRecvInterrupted] }
func (ErrSendRecvInterrupted) Errno ¶
func (ErrSendRecvInterrupted) Errno() unix.Errno
func (ErrSendRecvInterrupted) Error ¶
func (ErrSendRecvInterrupted) Error() string
type ErrSendRecvInvalidTimeout ¶
type ErrSendRecvInvalidTimeout struct { sys.Err[ErrSendRecvInvalidTimeout] }
func (ErrSendRecvInvalidTimeout) Errno ¶
func (ErrSendRecvInvalidTimeout) Errno() unix.Errno
func (ErrSendRecvInvalidTimeout) Error ¶
func (ErrSendRecvInvalidTimeout) Error() string
type ErrSendRecvTimeout ¶
type ErrSendRecvTimeout struct { sys.Err[ErrSendRecvTimeout] }
func (ErrSendRecvTimeout) Errno ¶
func (ErrSendRecvTimeout) Errno() unix.Errno
func (ErrSendRecvTimeout) Error ¶
func (ErrSendRecvTimeout) Error() string
type ErrUnlinkNoMessageQueue ¶
type ErrUnlinkNoMessageQueue struct { sys.Err[ErrUnlinkNoMessageQueue] }
func (ErrUnlinkNoMessageQueue) Errno ¶
func (ErrUnlinkNoMessageQueue) Errno() unix.Errno
func (ErrUnlinkNoMessageQueue) Error ¶
func (ErrUnlinkNoMessageQueue) Error() string
type ErrUnlinkNoPermission ¶
type ErrUnlinkNoPermission struct { sys.Err[ErrUnlinkNoPermission] }
func (ErrUnlinkNoPermission) Errno ¶
func (ErrUnlinkNoPermission) Errno() unix.Errno
func (ErrUnlinkNoPermission) Error ¶
func (ErrUnlinkNoPermission) Error() string
type MQ ¶
type MQ struct {
// contains filtered or unexported fields
}
MQ allows for structured usage of POSIX message queues.
func (*MQ) GetAttr ¶
func (mq *MQ) GetAttr() (oldValue Attributes, _ error)
GetAttr gets the message queue's attributes.
func (*MQ) Mode ¶
Mode returns the mode used to create the queue. Returns 0 if OpenCreate was not used.
func (*MQ) Receive ¶
Receive retrieves a message from the queue. The returned data is invalid after the next call to Receive.
func (*MQ) SetBlocking ¶
func (mq *MQ) SetBlocking(blocking bool) (Attributes, error)
SetBlocking sets or clears the blocking flag on the message queue.
type MQOption ¶
type MQOption interface {
// contains filtered or unexported methods
}
MQOption represents options that can be applied when creating or opening a message queue.
func OptionCreateArgs ¶
OptionCreateArgs supplies arguments for creating a queue with OpenCreate.
func OptionOflag ¶
OptionOflag sets the oflag parameter for opening the queue.
type Notify ¶
type Notify struct { Notify int `json:"sigev_notify"` // Notification type (e.g., NotifyNone, NotifySignal). Signo unix.Signal `json:"sigev_signo"` // Signal number to use for signal-based notifications. }
Notify defines the structure for queue notification settings.
type OpenFlag ¶
type OpenFlag int
OpenFlag represents the flags used for opening a message queue.
const ( OpenReadOnly OpenFlag = unix.O_RDONLY OpenWriteOnly OpenFlag = unix.O_WRONLY OpenReadWrite OpenFlag = unix.O_RDWR OpenCloseOnExec OpenFlag = unix.O_CLOEXEC OpenCreate OpenFlag = unix.O_CREAT OpenExclusive OpenFlag = unix.O_EXCL OpenNonBlocking OpenFlag = unix.O_NONBLOCK DefaultOpenFlags = OpenReadOnly | OpenCloseOnExec DefaultCreateFlags = OpenWriteOnly | OpenCloseOnExec | OpenCreate | OpenExclusive )