go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/topo/memorytopo Index | Files

package memorytopo

import "gopkg.in/src-d/go-vitess.v1/vt/topo/memorytopo"

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

Package Files

directory.go election.go file.go lock.go memorytopo.go version.go watch.go

func NewServer Uses

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

NewServer returns the new server

func VersionFromInt Uses

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.

type Conn Uses

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 Uses

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 Uses

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

Create is part of topo.Conn interface.

func (*Conn) Delete Uses

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

Delete is part of topo.Conn interface.

func (*Conn) Get Uses

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

Get is part of topo.Conn interface.

func (*Conn) ListDir Uses

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 Uses

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

Lock is part of the topo.Conn interface.

func (*Conn) NewMasterParticipation Uses

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

NewMasterParticipation is part of the topo.Server interface

func (*Conn) Update Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

Create is part of the topo.Factory interface.

func (*Factory) HasGlobalReadOnlyCell Uses

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

HasGlobalReadOnlyCell is part of the topo.Factory interface.

func (*Factory) Lock Uses

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 Uses

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 Uses

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 Uses

type NodeVersion uint64

NodeVersion is the local topo.Version implementation

func (NodeVersion) String Uses

func (v NodeVersion) String() string

Package memorytopo imports 12 packages (graph) and is imported by 9 packages. Updated 2019-06-13. Refresh now. Tools for package owners.