curator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildrenInput

type ChildrenInput struct {
	Path     string
	Callback func(resp zk.ChildrenResponse, err error)
	Watch    bool
	Watcher  func(ev zk.Event)
}

type Client

type Client interface {
	Get(path string, callback func(resp zk.GetResponse, err error))
	GetW(path string,
		callback func(resp zk.GetResponse, err error),
		watcher func(ev zk.Event),
	)

	Children(path string, callback func(resp zk.ChildrenResponse, err error))
	ChildrenW(path string,
		callback func(resp zk.ChildrenResponse, err error),
		watcher func(ev zk.Event),
	)

	Create(
		path string, data []byte, flags int32,
		callback func(resp zk.CreateResponse, err error),
	)
	Set(
		path string, data []byte, version int32,
		callback func(resp zk.SetResponse, err error),
	)
	Delete(path string, version int32, callback func(resp zk.DeleteResponse, err error))
}

func NewClient

func NewClient(zkClient *zk.Client, acl []zk.ACL) Client

type ClientFactory

type ClientFactory interface {
	Start(runner SessionRunner)
	Close()
}

func NewClientFactory

func NewClientFactory(servers []string, username string, password string) ClientFactory

func NewFakeClientFactory

func NewFakeClientFactory(store *FakeZookeeper, clientID FakeClientID) ClientFactory

type CreateInput

type CreateInput struct {
	Path     string
	Data     []byte
	Flags    int32
	Callback func(resp zk.CreateResponse, err error)
}

type Curator

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

func New

func New(
	initFunc func(sess *Session),
) *Curator

func NewChain

func NewChain(
	initFuncList ...SessionCallback,
) *Curator

func (*Curator) Begin

func (c *Curator) Begin(client Client)

func (*Curator) End

func (c *Curator) End()

func (*Curator) Retry

func (c *Curator) Retry()

type DeleteInput

type DeleteInput struct {
	Path     string
	Version  int32
	Callback func(resp zk.DeleteResponse, err error)
}

type FakeClientID

type FakeClientID string

type FakeSessionState

type FakeSessionState struct {
	SessionID  int64
	HasSession bool
}

type FakeZookeeper

type FakeZookeeper struct {
	States   map[FakeClientID]*FakeSessionState
	Sessions map[FakeClientID]SessionRunner
	Clients  map[FakeClientID]Client
	Pending  map[FakeClientID][]any

	Root *ZNode // root znode

	NextSessionID int64

	Zxid int64
}

func NewFakeZookeeper

func NewFakeZookeeper() *FakeZookeeper

func (*FakeZookeeper) Begin

func (s *FakeZookeeper) Begin(clientID FakeClientID)

func (*FakeZookeeper) ChildrenApply

func (s *FakeZookeeper) ChildrenApply(clientID FakeClientID)

func (*FakeZookeeper) ConnError

func (s *FakeZookeeper) ConnError(clientID FakeClientID)

func (*FakeZookeeper) CreateApply

func (s *FakeZookeeper) CreateApply(clientID FakeClientID)

func (*FakeZookeeper) CreateApplyError

func (s *FakeZookeeper) CreateApplyError(clientID FakeClientID)

func (*FakeZookeeper) CreateCall

func (s *FakeZookeeper) CreateCall(clientID FakeClientID) CreateInput

func (*FakeZookeeper) DeleteApply

func (s *FakeZookeeper) DeleteApply(clientID FakeClientID)

func (*FakeZookeeper) GetApply

func (s *FakeZookeeper) GetApply(clientID FakeClientID)

func (*FakeZookeeper) PendingCalls

func (s *FakeZookeeper) PendingCalls(clientID FakeClientID) []string

func (*FakeZookeeper) PrintData

func (s *FakeZookeeper) PrintData()

func (*FakeZookeeper) PrintPendingCalls

func (s *FakeZookeeper) PrintPendingCalls()

func (*FakeZookeeper) Retry

func (s *FakeZookeeper) Retry(clientID FakeClientID)

func (*FakeZookeeper) SessionExpired

func (s *FakeZookeeper) SessionExpired(clientID FakeClientID)

func (*FakeZookeeper) SetApply

func (s *FakeZookeeper) SetApply(clientID FakeClientID)

type GetInput

type GetInput struct {
	Path     string
	Callback func(resp zk.GetResponse, err error)
	Watch    bool
	Watcher  func(ev zk.Event)
}

type RetryInput

type RetryInput struct {
}

type Session

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

func (*Session) AddRetry

func (s *Session) AddRetry(callback func(sess *Session))

func (*Session) Run

func (s *Session) Run(fn func(client Client))

type SessionCallback

type SessionCallback func(sess *Session, next func(sess *Session))

type SessionRunner

type SessionRunner interface {
	Begin(client Client)
	Retry()
	End()
}

func NewParallelRunner

func NewParallelRunner(runners ...SessionRunner) SessionRunner

type SetInput

type SetInput struct {
	Path     string
	Data     []byte
	Version  int32
	Callback func(resp zk.SetResponse, err error)
}

type ZNode

type ZNode struct {
	Name     string
	Data     []byte
	Flags    int32
	Children []*ZNode

	SessionID int64

	NextSeq int64

	Stat zk.Stat

	ChildrenWatches []func(ev zk.Event)
	DataWatches     []func(ev zk.Event)
}

Jump to

Keyboard shortcuts

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