session

package
v0.0.0-...-80327fb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// Ch is used to send recieved values.
	Ch chan<- *MessageCloser

	// Done is used to indicate a session has expired or was otherwise
	// closed.
	Done chan<- struct{}
}

Handler contains details on how to route values.

type HandlerFunc

type HandlerFunc func(rpcid []byte) *Handler

HandlerFunc returns fresh handlers.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is a cache of expiring sessions with registered handlers.

func NewManager

func NewManager(capacity int, hf HandlerFunc) *Manager

NewManager constructs a manager with a default handler hf and cache capacity.

func (*Manager) Close

func (m *Manager) Close() error

Close the manager. All stored sessions will also be closed.

func (*Manager) Enqueue

func (m *Manager) Enqueue(msg *MessageCloser) error

Enqueue a value and route it to a handler.

func (*Manager) Register

func (m *Manager) Register(rpcid []byte, exp time.Time, handler *Handler) error

Register a custom handler for a session, which will be used in favor of the default handler until the session expires.

func (*Manager) Remove

func (m *Manager) Remove(rpcid []byte) error

Remove a session by its rpcid from the cache.

type MessageCloser

type MessageCloser struct {
	*core.Message
	io.Closer
}

MessageCloser is a message which may need to be closed.

Jump to

Keyboard shortcuts

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