zk2topo

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 22, 2017 License: BSD-3-Clause Imports: 20 Imported by: 8

Documentation

Index

Constants

View Source
const (

	// PermDirectory are default permissions for a node.
	PermDirectory = zk.PermAdmin | zk.PermCreate | zk.PermDelete | zk.PermRead | zk.PermWrite

	// PermFile allows a zk node to emulate file behavior by
	// disallowing child nodes.
	PermFile = zk.PermAdmin | zk.PermRead | zk.PermWrite
)

Variables

This section is empty.

Functions

func ChildrenRecursive

func ChildrenRecursive(ctx context.Context, zconn Conn, zkPath string) ([]string, error)

ChildrenRecursive returns the relative path of all the children of the provided node.

func CreateRecursive

func CreateRecursive(ctx context.Context, conn Conn, zkPath string, value []byte, flags int32, aclv []zk.ACL, maxCreationDepth int) (pathCreated string, err error)

CreateRecursive is a helper function on top of Create. It will create a path and any pieces required, think mkdir -p. Intermediate znodes are always created empty.

func DeleteRecursive

func DeleteRecursive(ctx context.Context, zconn Conn, zkPath string, version int32) error

DeleteRecursive will delete all children of the given path.

func ResolveWildcards

func ResolveWildcards(ctx context.Context, zconn Conn, zkPaths []string) ([]string, error)

ResolveWildcards resolves paths like: /zk/nyc/vt/tablets/*/action /zk/global/vt/keyspaces/*/shards/*/action /zk/*/vt/tablets/*/action into real existing paths

If you send paths that don't contain any wildcard and don't exist, this function will return an empty array.

func Time

func Time(i int64) time.Time

Time returns a time.Time from a ZK int64 milliseconds since Epoch time.

func ZkTime

func ZkTime(t time.Time) int64

ZkTime returns a ZK time (int64) from a time.Time

Types

type Conn

type Conn interface {
	Get(ctx context.Context, path string) (data []byte, stat *zk.Stat, err error)
	GetW(ctx context.Context, path string) (data []byte, stat *zk.Stat, watch <-chan zk.Event, err error)

	Children(ctx context.Context, path string) (children []string, stat *zk.Stat, err error)
	ChildrenW(ctx context.Context, path string) (children []string, stat *zk.Stat, watch <-chan zk.Event, err error)

	Exists(ctx context.Context, path string) (exists bool, stat *zk.Stat, err error)
	ExistsW(ctx context.Context, path string) (exists bool, stat *zk.Stat, watch <-chan zk.Event, err error)

	Create(ctx context.Context, path string, value []byte, flags int32, aclv []zk.ACL) (pathCreated string, err error)

	Set(ctx context.Context, path string, value []byte, version int32) (stat *zk.Stat, err error)

	Delete(ctx context.Context, path string, version int32) (err error)

	GetACL(ctx context.Context, path string) ([]zk.ACL, *zk.Stat, error)
	SetACL(ctx context.Context, path string, aclv []zk.ACL, version int32) error

	Close() error
}

Conn is really close to the Zookeeper library connection interface. So refer to the Zookeeper docs for the conventions used here (for instance, using -1 as version to specify any version)

func Connect

func Connect(addr string) Conn

Connect returns a Conn connecting to a real Zookeeper server.

type Server

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

Server is the zookeeper topo.Impl implementation.

func NewServer

func NewServer(serverAddr, root string) *Server

NewServer returns a Server connecting to real Zookeeper processes.

func (*Server) Close

func (zs *Server) Close()

Close is part of topo.Impl interface.

func (*Server) Create

func (zs *Server) Create(ctx context.Context, cell, filePath string, contents []byte) (topo.Version, error)

Create is part of the topo.Backend interface.

func (*Server) CreateKeyspace

func (zs *Server) CreateKeyspace(ctx context.Context, keyspace string, value *topodatapb.Keyspace) error

CreateKeyspace is part of the topo.Server interface

func (*Server) CreateShard

func (zs *Server) CreateShard(ctx context.Context, keyspace, shard string, value *topodatapb.Shard) error

CreateShard is part of the topo.Server interface.

func (*Server) CreateTablet

func (zs *Server) CreateTablet(ctx context.Context, tablet *topodatapb.Tablet) error

CreateTablet is part of the topo.Server interface

func (*Server) Delete

func (zs *Server) Delete(ctx context.Context, cell, filePath string, version topo.Version) error

Delete is part of the topo.Backend interface.

func (*Server) DeleteKeyspace

func (zs *Server) DeleteKeyspace(ctx context.Context, keyspace string) error

DeleteKeyspace is part of the topo.Server interface.

func (*Server) DeleteKeyspaceReplication

func (zs *Server) DeleteKeyspaceReplication(ctx context.Context, cell, keyspace string) error

DeleteKeyspaceReplication is part of the topo.Server interface

func (*Server) DeleteShard

func (zs *Server) DeleteShard(ctx context.Context, keyspace, shard string) error

DeleteShard is part of the topo.Server interface.

func (*Server) DeleteShardReplication

func (zs *Server) DeleteShardReplication(ctx context.Context, cell, keyspace, shard string) error

DeleteShardReplication is part of the topo.Server interface

func (*Server) DeleteSrvKeyspace

func (zs *Server) DeleteSrvKeyspace(ctx context.Context, cell, keyspace string) error

DeleteSrvKeyspace is part of the topo.Server interface.

func (*Server) DeleteTablet

func (zs *Server) DeleteTablet(ctx context.Context, alias *topodatapb.TabletAlias) error

DeleteTablet is part of the topo.Server interface

func (*Server) Get

func (zs *Server) Get(ctx context.Context, cell, filePath string) ([]byte, topo.Version, error)

Get is part of the topo.Backend interface.

func (*Server) GetKeyspace

func (zs *Server) GetKeyspace(ctx context.Context, keyspace string) (*topodatapb.Keyspace, int64, error)

GetKeyspace is part of the topo.Server interface

func (*Server) GetKeyspaces

func (zs *Server) GetKeyspaces(ctx context.Context) ([]string, error)

GetKeyspaces is part of the topo.Server interface

func (*Server) GetKnownCells

func (zs *Server) GetKnownCells(ctx context.Context) ([]string, error)

GetKnownCells is part of the topo.Server interface.

func (*Server) GetShard

func (zs *Server) GetShard(ctx context.Context, keyspace, shard string) (*topodatapb.Shard, int64, error)

GetShard is part of the topo.Server interface.

func (*Server) GetShardNames

func (zs *Server) GetShardNames(ctx context.Context, keyspace string) ([]string, error)

GetShardNames is part of the topo.Server interface.

func (*Server) GetShardReplication

func (zs *Server) GetShardReplication(ctx context.Context, cell, keyspace, shard string) (*topo.ShardReplicationInfo, error)

GetShardReplication is part of the topo.Server interface

func (*Server) GetSrvKeyspace

func (zs *Server) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error)

GetSrvKeyspace is part of the topo.Server interface.

func (*Server) GetSrvKeyspaceNames

func (zs *Server) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error)

GetSrvKeyspaceNames is part of the topo.Server interface.

func (*Server) GetSrvVSchema

func (zs *Server) GetSrvVSchema(ctx context.Context, cell string) (*vschemapb.SrvVSchema, error)

GetSrvVSchema is part of the topo.Server interface

func (*Server) GetTablet

func (zs *Server) GetTablet(ctx context.Context, alias *topodatapb.TabletAlias) (*topodatapb.Tablet, int64, error)

GetTablet is part of the topo.Server interface

func (*Server) GetTabletsByCell

func (zs *Server) GetTabletsByCell(ctx context.Context, cell string) ([]*topodatapb.TabletAlias, error)

GetTabletsByCell is part of the topo.Server interface

func (*Server) GetVSchema

func (zs *Server) GetVSchema(ctx context.Context, keyspace string) (*vschemapb.Keyspace, error)

GetVSchema fetches the vschema from the topo.

func (*Server) ListDir

func (zs *Server) ListDir(ctx context.Context, cell, dirPath string) ([]string, error)

ListDir is part of the topo.Backend interface.

func (*Server) LockKeyspaceForAction

func (zs *Server) LockKeyspaceForAction(ctx context.Context, keyspace, contents string) (string, error)

LockKeyspaceForAction is part of topo.Server interface

func (*Server) LockShardForAction

func (zs *Server) LockShardForAction(ctx context.Context, keyspace, shard, contents string) (string, error)

LockShardForAction is part of topo.Server interface

func (*Server) NewMasterParticipation

func (zs *Server) NewMasterParticipation(name, id string) (topo.MasterParticipation, error)

NewMasterParticipation is part of the topo.Server interface. We use the full path: <root path>/election/<name>

func (*Server) SaveVSchema

func (zs *Server) SaveVSchema(ctx context.Context, keyspace string, vschema *vschemapb.Keyspace) error

SaveVSchema saves the vschema into the topo.

func (*Server) UnlockKeyspaceForAction

func (zs *Server) UnlockKeyspaceForAction(ctx context.Context, keyspace, lockPath, results string) error

UnlockKeyspaceForAction is part of topo.Server interface

func (*Server) UnlockShardForAction

func (zs *Server) UnlockShardForAction(ctx context.Context, keyspace, shard, lockPath, results string) error

UnlockShardForAction is part of topo.Server interface

func (*Server) Update

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

Update is part of the topo.Backend interface.

func (*Server) UpdateKeyspace

func (zs *Server) UpdateKeyspace(ctx context.Context, keyspace string, value *topodatapb.Keyspace, existingVersion int64) (int64, error)

UpdateKeyspace is part of the topo.Server interface

func (*Server) UpdateShard

func (zs *Server) UpdateShard(ctx context.Context, keyspace, shard string, value *topodatapb.Shard, existingVersion int64) (int64, error)

UpdateShard is part of the topo.Server interface.

func (*Server) UpdateShardReplicationFields

func (zs *Server) UpdateShardReplicationFields(ctx context.Context, cell, keyspace, shard string, update func(*topodatapb.ShardReplication) error) error

UpdateShardReplicationFields is part of the topo.Server interface

func (*Server) UpdateSrvKeyspace

func (zs *Server) UpdateSrvKeyspace(ctx context.Context, cell, keyspace string, srvKeyspace *topodatapb.SrvKeyspace) error

UpdateSrvKeyspace is part of the topo.Server interface.

func (*Server) UpdateSrvVSchema

func (zs *Server) UpdateSrvVSchema(ctx context.Context, cell string, srvVSchema *vschemapb.SrvVSchema) error

UpdateSrvVSchema is part of the topo.Server interface

func (*Server) UpdateTablet

func (zs *Server) UpdateTablet(ctx context.Context, tablet *topodatapb.Tablet, existingVersion int64) (int64, error)

UpdateTablet is part of the topo.Server interface

func (*Server) Watch

func (zs *Server) Watch(ctx context.Context, cell, filePath string) (*topo.WatchData, <-chan *topo.WatchData, topo.CancelFunc)

Watch is part of the topo.Backend interface

type ZKVersion

type ZKVersion int32

ZKVersion is zookeeper's idea of a version. It implements topo.Version. We use the native zookeeper.Stat.Version type, int32.

func (ZKVersion) String

func (v ZKVersion) String() string

String is part of the topo.Version interface.

Jump to

Keyboard shortcuts

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