consultopo

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2017 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package consultopo implements topo.Server with consul as the backend.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadResponse is returned from this package if the
	// response from the consul server does not contain the data
	// that the API promises. The consul client unmarshals JSON
	// from the server into a Response struct that uses pointers,
	// so we need to check for nil pointers, or else a misbehaving
	// consul could cause us to panic.
	ErrBadResponse = errors.New("consul request returned success, but response is missing required data")
)

Errors specific to this package.

Functions

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 ConsulVersion object.

Types

type ConsulVersion

type ConsulVersion uint64

ConsulVersion is consul's idea of a version. It implements topo.Version. We use the native consul version type, uint64.

func (ConsulVersion) String

func (v ConsulVersion) String() string

String is part of the topo.Version interface.

type Server

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

Server is the implementation of topo.Server for consul.

func NewServer

func NewServer(serverAddr, root string) (*Server, error)

NewServer returns a new consultopo.Server.

func (*Server) Close

func (s *Server) Close()

Close implements topo.Server.Close. It will nil out the global and cells fields, so any attempt to re-use this server will panic.

func (*Server) Create

func (s *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 (s *Server) CreateKeyspace(ctx context.Context, keyspace string, value *topodatapb.Keyspace) error

CreateKeyspace implements topo.Server.

func (*Server) CreateShard

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

CreateShard implements topo.Server.

func (*Server) CreateTablet

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

CreateTablet implements topo.Server.

func (*Server) Delete

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

Delete is part of the topo.Backend interface.

func (*Server) DeleteKeyspace

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

DeleteKeyspace implements topo.Server.

func (*Server) DeleteKeyspaceReplication

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

DeleteKeyspaceReplication implements topo.Server.

func (*Server) DeleteShard

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

DeleteShard implements topo.Server.

func (*Server) DeleteShardReplication

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

DeleteShardReplication implements topo.Server.

func (*Server) DeleteSrvKeyspace

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

DeleteSrvKeyspace implements topo.Server.

func (*Server) DeleteTablet

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

DeleteTablet implements topo.Server.

func (*Server) Get

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

Get is part of the topo.Backend interface.

func (*Server) GetKeyspace

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

GetKeyspace implements topo.Server.

func (*Server) GetKeyspaces

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

GetKeyspaces implements topo.Server.

func (*Server) GetKnownCells

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

GetKnownCells implements topo.Server.GetKnownCells.

func (*Server) GetShard

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

GetShard implements topo.Server.

func (*Server) GetShardNames

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

GetShardNames implements topo.Server.

func (*Server) GetShardReplication

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

GetShardReplication implements topo.Server.

func (*Server) GetSrvKeyspace

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

GetSrvKeyspace implements topo.Server.

func (*Server) GetSrvKeyspaceNames

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

GetSrvKeyspaceNames implements topo.Server.

func (*Server) GetSrvVSchema

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

GetSrvVSchema implements topo.Server.

func (*Server) GetTablet

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

GetTablet implements topo.Server.

func (*Server) GetTabletsByCell

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

GetTabletsByCell implements topo.Server.

func (*Server) GetVSchema

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

GetVSchema fetches the vschema from the topo.

func (*Server) ListDir

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

ListDir is part of the topo.Backend interface.

func (*Server) LockKeyspaceForAction

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

LockKeyspaceForAction implements topo.Server.

func (*Server) LockShardForAction

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

LockShardForAction implements topo.Server.

func (*Server) NewMasterParticipation

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

NewMasterParticipation is part of the topo.Server interface

func (*Server) SaveVSchema

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

SaveVSchema saves the JSON vschema into the topo.

func (*Server) UnlockKeyspaceForAction

func (s *Server) UnlockKeyspaceForAction(ctx context.Context, keyspace, actionPath, results string) error

UnlockKeyspaceForAction implements topo.Server.

func (*Server) UnlockShardForAction

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

UnlockShardForAction implements topo.Server.

func (*Server) Update

func (s *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 (s *Server) UpdateKeyspace(ctx context.Context, keyspace string, value *topodatapb.Keyspace, existingVersion int64) (int64, error)

UpdateKeyspace implements topo.Server.

func (*Server) UpdateShard

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

UpdateShard implements topo.Server.

func (*Server) UpdateShardReplicationFields

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

UpdateShardReplicationFields implements topo.Server.

func (*Server) UpdateSrvKeyspace

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

UpdateSrvKeyspace implements topo.Server.

func (*Server) UpdateSrvVSchema

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

UpdateSrvVSchema implements topo.Server.

func (*Server) UpdateTablet

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

UpdateTablet implements topo.Server.

func (*Server) Watch

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

Watch is part of the topo.Backend interface.

Jump to

Keyboard shortcuts

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