mq

package
v0.0.0-...-5477640 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2024 License: Apache-2.0, MIT Imports: 12 Imported by: 9

Documentation

Overview

Package mq provides an implementation for POSIX message queues.

Index

Constants

View Source
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 (m *Message) StateFields() []string

func (*Message) StateLoad

func (m *Message) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*Message) StateSave

func (m *Message) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Message) StateTypeName

func (m *Message) StateTypeName() string

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

func (q *Queue) EventRegister(e *waiter.Entry) error

EventRegister implements Waitable.EventRegister.

func (*Queue) EventUnregister

func (q *Queue) EventUnregister(e *waiter.Entry)

EventUnregister implements Waitable.EventUnregister.

func (*Queue) Flush

func (q *Queue) Flush(ctx context.Context)

Flush implements View.Flush.

func (*Queue) Generate

func (q *Queue) Generate(ctx context.Context, buf *bytes.Buffer) error

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) Readiness

func (q *Queue) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness implements Waitable.Readiness.

func (*Queue) StateFields

func (q *Queue) StateFields() []string

func (*Queue) StateLoad

func (q *Queue) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*Queue) StateSave

func (q *Queue) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Queue) StateTypeName

func (q *Queue) StateTypeName() string

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 (r *Reader) StateFields() []string

func (*Reader) StateLoad

func (r *Reader) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*Reader) StateSave

func (r *Reader) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Reader) StateTypeName

func (r *Reader) StateTypeName() string

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) Destroy

func (r *Registry) Destroy(ctx context.Context)

Destroy destroys the registry and releases all held references.

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) Impl

func (r *Registry) Impl() RegistryImpl

Impl returns RegistryImpl inside r.

func (*Registry) Remove

func (r *Registry) Remove(ctx context.Context, name string) error

Remove removes the queue with the given name from the registry. See mq_unlink(2).

func (*Registry) StateFields

func (r *Registry) StateFields() []string

func (*Registry) StateLoad

func (r *Registry) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*Registry) StateSave

func (r *Registry) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Registry) StateTypeName

func (r *Registry) StateTypeName() string

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.

func NewView

func NewView(q *Queue, access AccessType, block bool) (View, error)

NewView creates a new view into a queue and returns it.

type Writer

type Writer struct {
	*Queue
	// contains filtered or unexported fields
}

Writer provides a receive-only view into a queue.

+stateify savable

func (*Writer) StateFields

func (w *Writer) StateFields() []string

func (*Writer) StateLoad

func (w *Writer) StateLoad(ctx context.Context, stateSourceObject state.Source)

+checklocksignore

func (*Writer) StateSave

func (w *Writer) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Writer) StateTypeName

func (w *Writer) StateTypeName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL