faketopo

package
v0.19.8 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeTopoServer

func NewFakeTopoServer(ctx context.Context, factory *FakeFactory) *topo.Server

NewFakeTopoServer creates a new fake topo server

Types

type FakeConn

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

FakeConn implements the Conn interface. It is used only for testing

func (*FakeConn) AddGetError

func (f *FakeConn) AddGetError(shouldErr bool)

AddGetError is used to add a get error to the fake connection

func (*FakeConn) AddUpdateError

func (f *FakeConn) AddUpdateError(shouldErr bool, writePersists bool)

AddUpdateError is used to add an update error to the fake connection

func (*FakeConn) Close

func (f *FakeConn) Close()

Close implements the Conn interface

func (*FakeConn) Create

func (f *FakeConn) Create(ctx context.Context, filePath string, contents []byte) (topo.Version, error)

Create implements the Conn interface

func (*FakeConn) Delete

func (f *FakeConn) Delete(ctx context.Context, filePath string, version topo.Version) error

Delete implements the Conn interface

func (*FakeConn) Get

func (f *FakeConn) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error)

Get implements the Conn interface

func (*FakeConn) List

func (f *FakeConn) List(ctx context.Context, filePathPrefix string) ([]topo.KVInfo, error)

List is part of the topo.Conn interface.

func (*FakeConn) ListDir

func (f *FakeConn) ListDir(ctx context.Context, dirPath string, full bool) ([]topo.DirEntry, error)

ListDir implements the Conn interface

func (*FakeConn) Lock

func (f *FakeConn) Lock(ctx context.Context, dirPath, contents string) (topo.LockDescriptor, error)

Lock implements the Conn interface

func (*FakeConn) NewLeaderParticipation

func (f *FakeConn) NewLeaderParticipation(string, string) (topo.LeaderParticipation, error)

NewLeaderParticipation implements the Conn interface

func (*FakeConn) TryLock added in v0.16.0

func (f *FakeConn) TryLock(ctx context.Context, dirPath, contents string) (topo.LockDescriptor, error)

TryLock is part of the topo.Conn interface. Its implementation is same as Lock

func (*FakeConn) Update

func (f *FakeConn) Update(ctx context.Context, filePath string, contents []byte, version topo.Version) (topo.Version, error)

Update implements the Conn interface

func (*FakeConn) Watch

func (f *FakeConn) Watch(ctx context.Context, filePath string) (*topo.WatchData, <-chan *topo.WatchData, error)

Watch implements the Conn interface

func (*FakeConn) WatchRecursive added in v0.15.0

func (f *FakeConn) WatchRecursive(ctx context.Context, path string) ([]*topo.WatchDataRecursive, <-chan *topo.WatchDataRecursive, error)

type FakeFactory

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

FakeFactory implements the Factory interface. This is supposed to be used only for testing

func NewFakeTopoFactory

func NewFakeTopoFactory() *FakeFactory

NewFakeTopoFactory creates a new fake topo factory

func (*FakeFactory) AddCell

func (f *FakeFactory) AddCell(cell string) *FakeConn

AddCell is used to add a cell to the factory. It returns the fake connection created. This connection can then be used to set get and update errors

func (*FakeFactory) Create

func (f *FakeFactory) Create(cell, serverAddr, root string) (topo.Conn, error)

Create implements the Factory interface It creates a fake connection which is supposed to be used only for testing

func (*FakeFactory) HasGlobalReadOnlyCell

func (f *FakeFactory) HasGlobalReadOnlyCell(serverAddr, root string) bool

HasGlobalReadOnlyCell implements the Factory interface

Jump to

Keyboard shortcuts

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