cluster

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrActorNotFound is return when an actor is not found
	ErrActorNotFound = errors.New("actor not found")
)

Functions

This section is empty.

Types

type Event added in v1.4.0

type Event struct {
	Type *anypb.Any
}

Event defines the cluster event

type Interface added in v0.6.0

type Interface interface {
	// Start starts the Node engine
	Start(ctx context.Context) error
	// Stop stops the Node engine
	Stop(ctx context.Context) error
	// NodeHost returns the cluster startNode host address
	NodeHost() string
	// NodeRemotingPort returns the cluster startNode remoting port
	NodeRemotingPort() int
	// PutActor replicates onto the Node the metadata of an actor
	PutActor(ctx context.Context, actor *internalpb.WireActor) error
	// GetActor fetches an actor from the Node
	GetActor(ctx context.Context, actorName string) (*internalpb.WireActor, error)
	// GetPartition returns the partition where a given actor is stored
	GetPartition(actorName string) int
	// SetKey sets a given key to the cluster
	SetKey(ctx context.Context, key string) error
	// KeyExists checks the existence of a given key
	KeyExists(ctx context.Context, key string) (bool, error)
	// RemoveActor removes a given actor from the cluster.
	// An actor is removed from the cluster when this actor has been passivated.
	RemoveActor(ctx context.Context, actorName string) error
	// Events returns a channel where cluster events are published
	Events() <-chan *Event
	// AdvertisedAddress returns the cluster node cluster address that is known by the
	// peers in the cluster
	AdvertisedAddress() string
}

Interface defines the Node interface

type Node added in v1.4.0

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

Node represents the Node

func NewNode added in v1.4.0

func NewNode(name string, serviceDiscovery *discovery.ServiceDiscovery, opts ...Option) (*Node, error)

NewNode creates an instance of cluster Node

func (*Node) AdvertisedAddress added in v1.4.0

func (n *Node) AdvertisedAddress() string

AdvertisedAddress returns the cluster node cluster address that is known by the peers in the cluster

func (*Node) Events added in v1.4.0

func (n *Node) Events() <-chan *Event

Events returns a channel where cluster events are published

func (*Node) GetActor added in v1.4.0

func (n *Node) GetActor(ctx context.Context, actorName string) (*internalpb.WireActor, error)

GetActor fetches an actor from the Node

func (*Node) GetPartition added in v1.4.0

func (n *Node) GetPartition(actorName string) int

GetPartition returns the partition where a given actor is stored

func (*Node) KeyExists added in v1.4.0

func (n *Node) KeyExists(ctx context.Context, key string) (bool, error)

KeyExists checks the existence of a given key

func (*Node) NodeHost added in v1.4.0

func (n *Node) NodeHost() string

NodeHost returns the Node Host

func (*Node) NodeRemotingPort added in v1.4.0

func (n *Node) NodeRemotingPort() int

NodeRemotingPort returns the Node remoting port

func (*Node) PutActor added in v1.4.0

func (n *Node) PutActor(ctx context.Context, actor *internalpb.WireActor) error

PutActor replicates onto the Node the metadata of an actor

func (*Node) RemoveActor added in v1.4.0

func (n *Node) RemoveActor(ctx context.Context, actorName string) error

RemoveActor removes a given actor from the cluster. An actor is removed from the cluster when this actor has been passivated.

func (*Node) SetKey added in v1.4.0

func (n *Node) SetKey(ctx context.Context, key string) error

SetKey sets a given key to the cluster

func (*Node) Start added in v1.4.0

func (n *Node) Start(ctx context.Context) error

Start starts the Node.

func (*Node) Stop added in v1.4.0

func (n *Node) Stop(ctx context.Context) error

Stop stops the Node gracefully

type Option

type Option interface {
	// Apply sets the Option value of a config.
	Apply(cl *Node)
}

Option is the interface that applies a configuration option.

func WithHasher added in v0.5.0

func WithHasher(hasher hash.Hasher) Option

WithHasher sets the custom hasher

func WithLogger added in v0.3.0

func WithLogger(logger log.Logger) Option

WithLogger sets the logger

func WithPartitionsCount added in v0.3.0

func WithPartitionsCount(count uint64) Option

WithPartitionsCount sets the total number of partitions

func WithReadTimeout added in v0.3.0

func WithReadTimeout(timeout time.Duration) Option

WithReadTimeout sets the Node read timeout. This timeout specifies the timeout of a data retrieval

func WithShutdownTimeout added in v0.3.0

func WithShutdownTimeout(timeout time.Duration) Option

WithShutdownTimeout sets the Node shutdown timeout.

func WithWriteTimeout added in v0.3.0

func WithWriteTimeout(timeout time.Duration) Option

WithWriteTimeout sets the Node write timeout. This timeout specifies the timeout of a data replication

type OptionFunc

type OptionFunc func(cl *Node)

OptionFunc implements the Option interface.

func (OptionFunc) Apply

func (f OptionFunc) Apply(c *Node)

Apply applies the Node's option

Jump to

Keyboard shortcuts

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