Documentation ¶
Overview ¶
Package mq provides an implementation for POSIX message queues.
Index ¶
- Constants
- type AccessType
- type Message
- func (e *Message) Next() *Message
- func (e *Message) Prev() *Message
- func (e *Message) SetNext(elem *Message)
- func (e *Message) SetPrev(elem *Message)
- func (m *Message) StateFields() []string
- func (m *Message) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (m *Message) StateSave(stateSinkObject state.Sink)
- func (m *Message) StateTypeName() string
- type OpenOpts
- type Queue
- func (q *Queue) EventRegister(e *waiter.Entry) error
- func (q *Queue) EventUnregister(e *waiter.Entry)
- func (q *Queue) Flush(ctx context.Context)
- func (q *Queue) Generate(ctx context.Context, buf *bytes.Buffer) error
- func (q *Queue) HasPermissions(creds *auth.Credentials, req vfs.AccessTypes) bool
- func (q *Queue) Readiness(mask waiter.EventMask) waiter.EventMask
- func (q *Queue) StateFields() []string
- func (q *Queue) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (q *Queue) StateSave(stateSinkObject state.Sink)
- func (q *Queue) StateTypeName() string
- type Reader
- type ReaderWriter
- type Registry
- func (r *Registry) Destroy(ctx context.Context)
- func (r *Registry) FindOrCreate(ctx context.Context, opts OpenOpts, mode linux.FileMode, attr *linux.MqAttr) (*vfs.FileDescription, error)
- func (r *Registry) Impl() RegistryImpl
- func (r *Registry) Remove(ctx context.Context, name string) error
- func (r *Registry) StateFields() []string
- func (r *Registry) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (r *Registry) StateSave(stateSinkObject state.Sink)
- func (r *Registry) StateTypeName() string
- type RegistryImpl
- type Subscriber
- type View
- type Writer
Constants ¶
const MaxName = 255
MaxName is the maximum size for a queue name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessType ¶
type AccessType int
AccessType is the access type passed to mq_open.
const ( ReadOnly AccessType = iota WriteOnly ReadWrite )
Possible access types.
type Message ¶
type Message struct { // Text is the message's sent content. Text string // Size is the message's size in bytes. Size uint64 // Priority is the message's priority. Priority uint32 // contains filtered or unexported fields }
Message holds a message exchanged through a Queue via mq_timedsend(2) and mq_timedreceive(2), and additional info relating to the message.
+stateify savable
func (*Message) Next ¶
func (e *Message) Next() *Message
Next returns the entry that follows e in the list.
func (*Message) Prev ¶
func (e *Message) Prev() *Message
Prev returns the entry that precedes e in the list.
func (*Message) SetNext ¶
func (e *Message) SetNext(elem *Message)
SetNext assigns 'entry' as the entry that follows e in the list.
func (*Message) SetPrev ¶
func (e *Message) SetPrev(elem *Message)
SetPrev assigns 'entry' as the entry that precedes e in the list.
func (*Message) StateFields ¶
func (*Message) StateTypeName ¶
type OpenOpts ¶
type OpenOpts struct { Name string Access AccessType Create bool Exclusive bool Block bool }
OpenOpts holds the options passed to FindOrCreate.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue represents a POSIX message queue.
+stateify savable
func (*Queue) EventRegister ¶
EventRegister implements Waitable.EventRegister.
func (*Queue) EventUnregister ¶
EventUnregister implements Waitable.EventUnregister.
func (*Queue) Generate ¶
Generate implements vfs.DynamicBytesSource.Generate. Queue is used as a DynamicBytesSource for mqfs's queueInode.
func (*Queue) HasPermissions ¶
func (q *Queue) HasPermissions(creds *auth.Credentials, req vfs.AccessTypes) bool
HasPermissions returns true if the given credentials meet the access permissions required by the queue.
func (*Queue) StateFields ¶
func (*Queue) StateTypeName ¶
type Reader ¶
type Reader struct { *Queue // contains filtered or unexported fields }
Reader provides a send-only view into a queue.
+stateify savable
func (*Reader) StateFields ¶
func (*Reader) StateTypeName ¶
type ReaderWriter ¶
type ReaderWriter struct { *Queue // contains filtered or unexported fields }
ReaderWriter provides a send and receive view into a queue.
+stateify savable
func (*ReaderWriter) StateFields ¶
func (r *ReaderWriter) StateFields() []string
func (*ReaderWriter) StateLoad ¶
func (r *ReaderWriter) StateLoad(ctx context.Context, stateSourceObject state.Source)
+checklocksignore
func (*ReaderWriter) StateSave ¶
func (r *ReaderWriter) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*ReaderWriter) StateTypeName ¶
func (r *ReaderWriter) StateTypeName() string
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a POSIX message queue registry.
Unlike SysV utilities, Registry is not map-based. It uses a provided RegistryImpl backed by a virtual filesystem to implement registry operations.
+stateify savable
func NewRegistry ¶
func NewRegistry(userNS *auth.UserNamespace, impl RegistryImpl) *Registry
NewRegistry returns a new, initialized message queue registry. NewRegistry should be called when a new message queue filesystem is created, once per IPCNamespace.
func (*Registry) FindOrCreate ¶
func (r *Registry) FindOrCreate(ctx context.Context, opts OpenOpts, mode linux.FileMode, attr *linux.MqAttr) (*vfs.FileDescription, error)
FindOrCreate creates a new POSIX message queue or opens an existing queue. See mq_open(2).
func (*Registry) Remove ¶
Remove removes the queue with the given name from the registry. See mq_unlink(2).
func (*Registry) StateFields ¶
func (*Registry) StateTypeName ¶
type RegistryImpl ¶
type RegistryImpl interface { // Get searches for a queue with the given name, if it exists, the queue is // used to create a new FD, return it and return true. If the queue doesn't // exist, return false and no error. An error is returned if creation fails. Get(ctx context.Context, name string, access AccessType, block bool, flags uint32) (*vfs.FileDescription, bool, error) // New creates a new inode and file description using the given queue, // inserts the inode into the filesystem tree using the given name, and // returns the file description. An error is returned if creation fails, or // if the name already exists. New(ctx context.Context, name string, q *Queue, access AccessType, block bool, perm linux.FileMode, flags uint32) (*vfs.FileDescription, error) // Unlink removes the queue with given name from the registry, and returns // an error if the name doesn't exist. Unlink(ctx context.Context, name string) error // Destroy destroys the registry. Destroy(context.Context) }
RegistryImpl defines utilities needed by a Registry to provide actual registry implementation. It works mainly as an abstraction layer used by Registry to avoid dealing directly with the filesystem. RegistryImpl should be implemented by mqfs and provided to Registry at initialization.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber represents a task registered for async notification from a Queue.
+stateify savable
func (*Subscriber) StateFields ¶
func (s *Subscriber) StateFields() []string
func (*Subscriber) StateLoad ¶
func (s *Subscriber) StateLoad(ctx context.Context, stateSourceObject state.Source)
+checklocksignore
func (*Subscriber) StateSave ¶
func (s *Subscriber) StateSave(stateSinkObject state.Sink)
+checklocksignore
func (*Subscriber) StateTypeName ¶
func (s *Subscriber) StateTypeName() string
type View ¶
type View interface { // Flush checks if the calling process has attached a notification request // to this queue, if yes, then the request is removed, and another process // can attach a request. Flush(ctx context.Context) waiter.Waitable }
View is a view into a message queue. Views should only be used in file descriptions, but not inodes, because we use inodes to retrieve the actual queue, and only FDs are responsible for providing user functionality.
type Writer ¶
type Writer struct { *Queue // contains filtered or unexported fields }
Writer provides a receive-only view into a queue.
+stateify savable