socketdriver

package
v0.0.0-...-a852efd Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBuffer

func GetBuffer() ([]byte, func())

GetBuffer returns a buffer and a done func to call at defer.

Types

type Publisher

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

Publisher implementation of `pubsub.DriverPublisher` for `SocketDriver`. Implements Unix-domain socket or directory publication, and directory-based persistence.

func (*Publisher) CheckMaxSize

func (s *Publisher) CheckMaxSize(key string, val []byte) error

CheckMaxSize returns an error if too large

func (*Publisher) LargeDirName

func (s *Publisher) LargeDirName() string

LargeDirName where to put large fields Note that this is in /persist to avoid using overlayfs aka memory for content which might be Megabytes in size, but there is no assumption that it is persisted across reboots. In fact, the directory should be cleaned up on boot since we do not garbage collect old files from here.

func (*Publisher) Load

func (s *Publisher) Load() (map[string][]byte, int, error)

Load load entire persisted data set into a map

func (*Publisher) Publish

func (s *Publisher) Publish(key string, item []byte) error

Publish publish a key-value pair

func (*Publisher) Restart

func (s *Publisher) Restart(restartCounter int) error

Restart indicate that the topic is restarted if counter is non-zero

func (*Publisher) Start

func (s *Publisher) Start() error

Start start publishing on the socket

func (*Publisher) Stop

func (s *Publisher) Stop() error

Stop the publisher

func (*Publisher) Unpublish

func (s *Publisher) Unpublish(key string) error

Unpublish delete a key and publish its deletion

type SocketDriver

type SocketDriver struct {
	Logger  *logrus.Logger
	Log     *base.LogObject
	RootDir string // Default is "/"; tests can override
}

SocketDriver driver for pubsub using local unix-domain socket and files

func (*SocketDriver) DefaultName

func (s *SocketDriver) DefaultName() string

DefaultName default name for an agent when none is provided

func (*SocketDriver) Publisher

func (s *SocketDriver) Publisher(global bool, name, topic string, persistent bool, updaterList *pubsub.Updaters, restarted pubsub.Restarted, differ pubsub.Differ) (pubsub.DriverPublisher, error)

Publisher return an implementation of `pubsub.DriverPublisher` for `SocketDriver`

func (*SocketDriver) Subscriber

func (s *SocketDriver) Subscriber(global bool, name, topic string, persistent bool, C chan pubsub.Change) (pubsub.DriverSubscriber, error)

Subscriber return an implementation of `pubsub.DriverSubscriber` for `SocketDriver`

type Subscriber

type Subscriber struct {
	C chan<- pubsub.Change
	// contains filtered or unexported fields
}

Subscriber implementation of `pubsub.DriverSubscriber` for `SocketDriver`. Implements Unix-domain socket or directory subscription, and directory-based persistence.

func (*Subscriber) LargeDirName

func (s *Subscriber) LargeDirName() string

LargeDirName where to put large fields

func (*Subscriber) Load

func (s *Subscriber) Load() (map[string][]byte, int, error)

Load load entire persisted data set into a map

func (*Subscriber) Start

func (s *Subscriber) Start() error

Start start the subscriber listening on the given name and topic internally, will watch for changes on either the socket or the file, and then send the change summary to s.C

func (*Subscriber) Stop

func (s *Subscriber) Stop() error

Stop the subscriber listening on the given name and topic

Jump to

Keyboard shortcuts

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