memorytopo

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: 12 Imported by: 0

Documentation

Overview

Package memorytopo contains an implementation of the topo.Backend API based on an in-process memory map.

It also contains the plumbing to make it a topo.Impl as well. Eventually we will ove the difference to go/vt/topo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

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

NewServer returns a topo.Server based on a MemoryTopo.

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 MemoryTopo

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

MemoryTopo is a memory-based implementation of topo.Backend. 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.

func New

func New(cells ...string) *MemoryTopo

New returns a new MemoryTopo for all the cells. It will create one cell for each parameter passed in. It will log.Fatal out in case of a problem.

func (*MemoryTopo) Close

func (mt *MemoryTopo) Close()

Close is part of the topo.Impl interface.

func (*MemoryTopo) Create

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

Create is part of topo.Backend interface.

func (*MemoryTopo) CreateKeyspace

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

CreateKeyspace implements topo.Impl.CreateKeyspace

func (*MemoryTopo) CreateShard

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

CreateShard implements topo.Impl.CreateShard

func (*MemoryTopo) CreateTablet

func (mt *MemoryTopo) CreateTablet(ctx context.Context, tablet *topodatapb.Tablet) error

CreateTablet implements topo.Impl.CreateTablet

func (*MemoryTopo) Delete

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

Delete is part of topo.Backend interface.

func (*MemoryTopo) DeleteKeyspace

func (mt *MemoryTopo) DeleteKeyspace(ctx context.Context, keyspace string) error

DeleteKeyspace implements topo.Impl.DeleteKeyspace

func (*MemoryTopo) DeleteKeyspaceReplication

func (mt *MemoryTopo) DeleteKeyspaceReplication(ctx context.Context, cell, keyspace string) error

DeleteKeyspaceReplication implements topo.Impl.DeleteKeyspaceReplication

func (*MemoryTopo) DeleteShard

func (mt *MemoryTopo) DeleteShard(ctx context.Context, keyspace, shard string) error

DeleteShard implements topo.Impl.DeleteShard

func (*MemoryTopo) DeleteShardReplication

func (mt *MemoryTopo) DeleteShardReplication(ctx context.Context, cell, keyspace, shard string) error

DeleteShardReplication implements topo.Impl.DeleteShardReplication

func (*MemoryTopo) DeleteSrvKeyspace

func (mt *MemoryTopo) DeleteSrvKeyspace(ctx context.Context, cell, keyspace string) error

DeleteSrvKeyspace implements topo.Impl.DeleteSrvKeyspace

func (*MemoryTopo) DeleteTablet

func (mt *MemoryTopo) DeleteTablet(ctx context.Context, alias *topodatapb.TabletAlias) error

DeleteTablet implements topo.Impl.DeleteTablet

func (*MemoryTopo) Get

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

Get is part of topo.Backend interface.

func (*MemoryTopo) GetKeyspace

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

GetKeyspace implements topo.Impl.GetKeyspace

func (*MemoryTopo) GetKeyspaces

func (mt *MemoryTopo) GetKeyspaces(ctx context.Context) ([]string, error)

GetKeyspaces implements topo.Impl.GetKeyspaces

func (*MemoryTopo) GetKnownCells

func (mt *MemoryTopo) GetKnownCells(ctx context.Context) ([]string, error)

GetKnownCells is part of the topo.Server interface.

func (*MemoryTopo) GetShard

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

GetShard implements topo.Impl.GetShard

func (*MemoryTopo) GetShardNames

func (mt *MemoryTopo) GetShardNames(ctx context.Context, keyspace string) ([]string, error)

GetShardNames implements topo.Impl.GetShardNames

func (*MemoryTopo) GetShardReplication

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

GetShardReplication implements topo.Impl.GetShardReplication

func (*MemoryTopo) GetSrvKeyspace

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

GetSrvKeyspace implements topo.Impl.GetSrvKeyspace

func (*MemoryTopo) GetSrvKeyspaceNames

func (mt *MemoryTopo) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error)

GetSrvKeyspaceNames implements topo.Impl.GetSrvKeyspaceNames

func (*MemoryTopo) GetSrvVSchema

func (mt *MemoryTopo) GetSrvVSchema(ctx context.Context, cell string) (*vschemapb.SrvVSchema, error)

GetSrvVSchema implements topo.Impl.GetSrvVSchema

func (*MemoryTopo) GetTablet

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

GetTablet implements topo.Impl.GetTablet

func (*MemoryTopo) GetTabletsByCell

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

GetTabletsByCell implements topo.Impl.GetTabletsByCell

func (*MemoryTopo) GetVSchema

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

GetVSchema fetches the vschema from the topo.

func (*MemoryTopo) ListDir

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

ListDir is part of the topo.Backend interface.

func (*MemoryTopo) LockKeyspaceForAction

func (mt *MemoryTopo) LockKeyspaceForAction(ctx context.Context, keyspace, contents string) (string, error)

LockKeyspaceForAction implements topo.Server.

func (*MemoryTopo) LockShardForAction

func (mt *MemoryTopo) LockShardForAction(ctx context.Context, keyspace, shard, contents string) (string, error)

LockShardForAction implements topo.Server.

func (*MemoryTopo) NewMasterParticipation

func (mt *MemoryTopo) NewMasterParticipation(name, id string) (topo.MasterParticipation, error)

NewMasterParticipation is part of the topo.Server interface

func (*MemoryTopo) SaveVSchema

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

SaveVSchema saves the JSON vschema into the topo.

func (*MemoryTopo) UnlockKeyspaceForAction

func (mt *MemoryTopo) UnlockKeyspaceForAction(ctx context.Context, keyspace, actionPath, results string) error

UnlockKeyspaceForAction implements topo.Server.

func (*MemoryTopo) UnlockShardForAction

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

UnlockShardForAction implements topo.Server.

func (*MemoryTopo) Update

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

Update is part of topo.Backend interface.

func (*MemoryTopo) UpdateKeyspace

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

UpdateKeyspace implements topo.Impl.UpdateKeyspace

func (*MemoryTopo) UpdateShard

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

UpdateShard implements topo.Impl.UpdateShard

func (*MemoryTopo) UpdateShardReplicationFields

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

UpdateShardReplicationFields implements topo.Impl.UpdateShardReplicationFields

func (*MemoryTopo) UpdateSrvKeyspace

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

UpdateSrvKeyspace implements topo.Impl.UpdateSrvKeyspace

func (*MemoryTopo) UpdateSrvVSchema

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

UpdateSrvVSchema implements topo.Impl.UpdateSrvVSchema

func (*MemoryTopo) UpdateTablet

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

UpdateTablet implements topo.Impl.UpdateTablet

func (*MemoryTopo) Watch

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

Watch is part of the topo.Backend interface.

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