zk

package
v0.0.0-...-99a34e4 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithEventCallback

func WithEventCallback(cb zk.EventCallback) zkConnOpt

Types

type Node

type Node struct {
	ID      string            `json:"id"`
	Name    string            `json:"name"`
	Host    string            `json:"host"`
	Address string            `json:"address"`
	Port    int               `json:"port"`
	Kinds   []string          `json:"kinds"`
	Meta    map[string]string `json:"-"`
	Alive   bool              `json:"alive"`
}

func NewNode

func NewNode(name, host string, port int, kinds []string) *Node

func (*Node) Deserialize

func (n *Node) Deserialize(data []byte) error

func (*Node) Equal

func (n *Node) Equal(other *Node) bool

func (*Node) GetAddress

func (n *Node) GetAddress() (host string, port int)

func (*Node) GetAddressString

func (n *Node) GetAddressString() string

func (*Node) GetMeta

func (n *Node) GetMeta(name string) (string, bool)

func (*Node) GetSeq

func (n *Node) GetSeq() int

func (*Node) MemberStatus

func (n *Node) MemberStatus() *cluster.Member

func (*Node) Serialize

func (n *Node) Serialize() ([]byte, error)

func (*Node) SetMeta

func (n *Node) SetMeta(name string, val string)

type OnRoleChangedFunc

type OnRoleChangedFunc func(RoleType)

func (OnRoleChangedFunc) OnRoleChanged

func (fn OnRoleChangedFunc) OnRoleChanged(rt RoleType)

type Option

type Option func(*config)

func WithAuth

func WithAuth(scheme string, credential string) Option

WithAuth set zk auth

func WithBaseKey

func WithBaseKey(key string) Option

WithBaseKey set actors base key

func WithRoleChangedFunc

func WithRoleChangedFunc(f OnRoleChangedFunc) Option

func WithRoleChangedListener

func WithRoleChangedListener(l RoleChangedListener) Option

WithRoleChangedListener triggered on self role changed

func WithSessionTimeout

func WithSessionTimeout(tm time.Duration) Option

WithSessionTimeout set zk session timeout

type Provider

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

func New

func New(endpoints []string, opts ...Option) (*Provider, error)

New zk cluster provider with config

func (*Provider) GetHealthStatus

func (p *Provider) GetHealthStatus() error

GetHealthStatus returns an error if the cluster health status has problems

func (*Provider) IsLeader

func (p *Provider) IsLeader() bool

func (*Provider) Shutdown

func (p *Provider) Shutdown(graceful bool) error

func (*Provider) StartClient

func (p *Provider) StartClient(c *cluster.Cluster) error

func (*Provider) StartMember

func (p *Provider) StartMember(c *cluster.Cluster) error

type RoleChangedListener

type RoleChangedListener interface {
	OnRoleChanged(RoleType)
}

type RoleType

type RoleType int
const (
	Follower RoleType = iota
	Leader
)

func (RoleType) String

func (r RoleType) String() string

type SingletonScheduler

type SingletonScheduler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSingletonScheduler

func NewSingletonScheduler(rc *actor.RootContext) *SingletonScheduler

func (*SingletonScheduler) FromFunc

func (*SingletonScheduler) FromProducer

func (*SingletonScheduler) OnRoleChanged

func (s *SingletonScheduler) OnRoleChanged(rt RoleType)

Jump to

Keyboard shortcuts

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