cluster

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cluster is for clustering SPV Wallet Engine(s) or servers to work together for chainstate monitoring and other tasks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel string

Channel all keys used in cluster coordinator

var (
	// DestinationNew is a message sent when a new destination is created
	DestinationNew Channel = "new-destination"
)

type Client

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

Client is the client (configuration)

func NewClient

func NewClient(ctx context.Context, opts ...ClientOps) (*Client, error)

NewClient create new cluster client

func (*Client) GetClusterPrefix

func (c *Client) GetClusterPrefix() string

GetClusterPrefix returns the cluster key prefix that can be used in things like Redis

func (*Client) IsDebug

func (c *Client) IsDebug() bool

IsDebug returns whether debugging is on or off

type ClientInterface

type ClientInterface interface {
	IsDebug() bool
	GetClusterPrefix() string
	// contains filtered or unexported methods
}

ClientInterface interface for the internal pub/sub functionality for clusters

type ClientOps

type ClientOps func(c *clientOptions)

ClientOps allow functional options to be supplied that overwrite default client options.

func WithDebugging

func WithDebugging() ClientOps

WithDebugging will enable debugging mode

func WithKeyPrefix

func WithKeyPrefix(prefix string) ClientOps

WithKeyPrefix will set the prefix to use for all keys in the cluster coordinator

func WithNewRelic

func WithNewRelic() ClientOps

WithNewRelic will enable the NewRelic wrapper

func WithRedis

func WithRedis(redisOptions *redis.Options) ClientOps

WithRedis will enable redis cluster coordinator

type Coordinator

type Coordinator string

Coordinator the coordinators supported in cluster mode

var (
	// CoordinatorRedis definition
	CoordinatorRedis Coordinator = "redis"

	// CoordinatorMemory definition - use only in single server setups of SPV Wallet Engine!
	CoordinatorMemory Coordinator = "memory"
)

type MemoryPubSub

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

MemoryPubSub struct

func NewMemoryPubSub

func NewMemoryPubSub(ctx context.Context) (*MemoryPubSub, error)

NewMemoryPubSub create a new memory pub/sub client this is the default (mock) implementation for the internal pub/sub communications on standalone servers for clusters, use another solution, like RedisPubSub

func (*MemoryPubSub) Logger

func (m *MemoryPubSub) Logger() *zerolog.Logger

Logger returns the logger to use

func (*MemoryPubSub) Publish

func (m *MemoryPubSub) Publish(channel Channel, data string) error

Publish to a channel

func (*MemoryPubSub) Subscribe

func (m *MemoryPubSub) Subscribe(channel Channel, callback func(data string)) (func() error, error)

Subscribe to a channel

type RedisPubSub

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

RedisPubSub struct

func NewRedisPubSub

func NewRedisPubSub(ctx context.Context, options *redis.Options) (*RedisPubSub, error)

NewRedisPubSub create a new redis pub/sub client

func (*RedisPubSub) Logger

func (r *RedisPubSub) Logger() *zerolog.Logger

Logger returns the logger to use

func (*RedisPubSub) Publish

func (r *RedisPubSub) Publish(channel Channel, data string) error

Publish to a channel

func (*RedisPubSub) Subscribe

func (r *RedisPubSub) Subscribe(channel Channel, callback func(data string)) (func() error, error)

Subscribe to a channel

Jump to

Keyboard shortcuts

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