mq

package
v0.0.0-...-973e103 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0, MIT Imports: 10 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

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.

type Reader

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

Reader provides a send-only view into a queue.

+stateify savable

type ReaderWriter

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

ReaderWriter provides a send and receive view into a queue.

+stateify savable

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

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

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

Jump to

Keyboard shortcuts

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