memorytopo

package
v3.0.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2018 License: Apache-2.0 Imports: 10 Imported by: 13

Documentation

Overview

Package memorytopo contains an implementation of the topo.Factory / topo.Conn interfaces based on an in-memory tree of data. It is constructed with an immutable set of cells.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(cells ...string) *topo.Server

NewServer returns the new server

func VersionFromInt

func VersionFromInt(version int64) topo.Version

VersionFromInt is used by old-style functions to create a proper Version: if version is -1, returns nil. Otherwise returns the NodeVersion object.

Types

type Conn

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

Conn implements the topo.Conn interface. It remembers the cell, and points at the Factory that has all the data.

func (*Conn) Close

func (c *Conn) Close()

Close is part of the topo.Conn interface. It nils out factory, so any subsequent call will panic.

func (*Conn) Create

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

Create is part of topo.Conn interface.

func (*Conn) Delete

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

Delete is part of topo.Conn interface.

func (*Conn) Get

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

Get is part of topo.Conn interface.

func (*Conn) ListDir

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

ListDir is part of the topo.Conn interface.

func (*Conn) Lock

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

Lock is part of the topo.Conn interface.

func (*Conn) NewMasterParticipation

func (c *Conn) NewMasterParticipation(name, id string) (topo.MasterParticipation, error)

NewMasterParticipation is part of the topo.Server interface

func (*Conn) Update

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

Update is part of topo.Conn interface.

func (*Conn) Watch

func (c *Conn) Watch(ctx context.Context, filePath string) (*topo.WatchData, <-chan *topo.WatchData, topo.CancelFunc)

Watch is part of the topo.Conn interface.

type Factory

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

Factory is a memory-based implementation of topo.Factory. It takes a file-system like approach, with directories at each level being an actual directory node. This is meant to be closer to file-system like servers, like ZooKeeper or Chubby. etcd or Consul implementations would be closer to a node-based implementation.

It contains a single tree of nodes. Each cell topo.Conn will use a sub-directory in that tree.

func NewServerAndFactory

func NewServerAndFactory(cells ...string) (*topo.Server, *Factory)

NewServerAndFactory returns a new MemoryTopo and the backing factory for all the cells. It will create one cell for each parameter passed in. It will log.Exit out in case of a problem.

func (*Factory) Create

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

Create is part of the topo.Factory interface.

func (*Factory) HasGlobalReadOnlyCell

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

HasGlobalReadOnlyCell is part of the topo.Factory interface.

func (*Factory) Lock

func (f *Factory) Lock()

Lock blocks all requests to the topo and is exposed to allow tests to simulate an unresponsive topo server

func (*Factory) SetError

func (f *Factory) SetError(err error)

SetError forces the given error to be returned from all calls and propagates the error to all active watches.

func (*Factory) Unlock

func (f *Factory) Unlock()

Unlock unblocks all requests to the topo and is exposed to allow tests to simulate an unresponsive topo server

type NodeVersion

type NodeVersion uint64

NodeVersion is the local topo.Version implementation

func (NodeVersion) String

func (v NodeVersion) String() string

Jump to

Keyboard shortcuts

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