shard

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package shard is a generated protocol buffer package.

It is generated from these files:

client/pkg/shard/shard.proto

It has these top-level messages:

ServerState
FrontendState
ServerRole
Addresses
StartRegister
FinishRegister
Version
StartAssignRoles
FinishAssignRoles
FailedToAssignRoles
SetServerState
SetFrontendState
AddServerRole
RemoveServerRole
SetServerRole
DeleteServerRole
SetAddresses
GetAddress
GetShardToAddress

Index

Constants

View Source
const InvalidVersion int64 = -1

InvalidVersion is defined as -1 since valid versions are non-negative.

Variables

View Source
var (

	// ErrCancelled is returned when an action is cancelled by the user
	ErrCancelled = fmt.Errorf("cancelled by user")
)

Functions

This section is empty.

Types

type AddServerRole

type AddServerRole struct {
	ServerRole *ServerRole `protobuf:"bytes,1,opt,name=serverRole" json:"serverRole,omitempty"`
	Error      string      `protobuf:"bytes,2,opt,name=error" json:"error,omitempty"`
}

func (*AddServerRole) Descriptor

func (*AddServerRole) Descriptor() ([]byte, []int)

func (*AddServerRole) GetServerRole

func (m *AddServerRole) GetServerRole() *ServerRole

func (*AddServerRole) ProtoMessage

func (*AddServerRole) ProtoMessage()

func (*AddServerRole) Reset

func (m *AddServerRole) Reset()

func (*AddServerRole) String

func (m *AddServerRole) String() string

type Addresses

type Addresses struct {
	Version   int64             `protobuf:"varint,1,opt,name=version" json:"version,omitempty"`
	Addresses map[uint64]string `` /* 139-byte string literal not displayed */
}

func (*Addresses) Descriptor

func (*Addresses) Descriptor() ([]byte, []int)

func (*Addresses) GetAddresses

func (m *Addresses) GetAddresses() map[uint64]string

func (*Addresses) ProtoMessage

func (*Addresses) ProtoMessage()

func (*Addresses) Reset

func (m *Addresses) Reset()

func (*Addresses) String

func (m *Addresses) String() string

type DeleteServerRole

type DeleteServerRole struct {
	ServerRole *ServerRole `protobuf:"bytes,2,opt,name=serverRole" json:"serverRole,omitempty"`
}

func (*DeleteServerRole) Descriptor

func (*DeleteServerRole) Descriptor() ([]byte, []int)

func (*DeleteServerRole) GetServerRole

func (m *DeleteServerRole) GetServerRole() *ServerRole

func (*DeleteServerRole) ProtoMessage

func (*DeleteServerRole) ProtoMessage()

func (*DeleteServerRole) Reset

func (m *DeleteServerRole) Reset()

func (*DeleteServerRole) String

func (m *DeleteServerRole) String() string

type FailedToAssignRoles

type FailedToAssignRoles struct {
	ServerStates map[string]*ServerState `` /* 164-byte string literal not displayed */
	NumShards    uint64                  `protobuf:"varint,2,opt,name=num_shards,json=numShards" json:"num_shards,omitempty"`
	NumReplicas  uint64                  `protobuf:"varint,3,opt,name=num_replicas,json=numReplicas" json:"num_replicas,omitempty"`
}

func (*FailedToAssignRoles) Descriptor

func (*FailedToAssignRoles) Descriptor() ([]byte, []int)

func (*FailedToAssignRoles) GetServerStates

func (m *FailedToAssignRoles) GetServerStates() map[string]*ServerState

func (*FailedToAssignRoles) ProtoMessage

func (*FailedToAssignRoles) ProtoMessage()

func (*FailedToAssignRoles) Reset

func (m *FailedToAssignRoles) Reset()

func (*FailedToAssignRoles) String

func (m *FailedToAssignRoles) String() string

type FinishAssignRoles

type FinishAssignRoles struct {
	Error string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
}

func (*FinishAssignRoles) Descriptor

func (*FinishAssignRoles) Descriptor() ([]byte, []int)

func (*FinishAssignRoles) ProtoMessage

func (*FinishAssignRoles) ProtoMessage()

func (*FinishAssignRoles) Reset

func (m *FinishAssignRoles) Reset()

func (*FinishAssignRoles) String

func (m *FinishAssignRoles) String() string

type FinishRegister

type FinishRegister struct {
	Address string `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
	Error   string `protobuf:"bytes,2,opt,name=error" json:"error,omitempty"`
}

func (*FinishRegister) Descriptor

func (*FinishRegister) Descriptor() ([]byte, []int)

func (*FinishRegister) ProtoMessage

func (*FinishRegister) ProtoMessage()

func (*FinishRegister) Reset

func (m *FinishRegister) Reset()

func (*FinishRegister) String

func (m *FinishRegister) String() string

type Frontend

type Frontend interface {
	// Version tells the Frontend a new version exists.
	// Version should block until the Frontend is done using the previous version.
	Version(version int64) error
}

A Frontend represents a frontend which receives new versions.

type FrontendState

type FrontendState struct {
	Address string `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
	Version int64  `protobuf:"varint,2,opt,name=version" json:"version,omitempty"`
}

func (*FrontendState) Descriptor

func (*FrontendState) Descriptor() ([]byte, []int)

func (*FrontendState) ProtoMessage

func (*FrontendState) ProtoMessage()

func (*FrontendState) Reset

func (m *FrontendState) Reset()

func (*FrontendState) String

func (m *FrontendState) String() string

type GetAddress

type GetAddress struct {
	Shard   uint64 `protobuf:"varint,1,opt,name=shard" json:"shard,omitempty"`
	Version int64  `protobuf:"varint,2,opt,name=version" json:"version,omitempty"`
	Result  string `protobuf:"bytes,3,opt,name=result" json:"result,omitempty"`
	Ok      bool   `protobuf:"varint,4,opt,name=ok" json:"ok,omitempty"`
	Error   string `protobuf:"bytes,5,opt,name=error" json:"error,omitempty"`
}

func (*GetAddress) Descriptor

func (*GetAddress) Descriptor() ([]byte, []int)

func (*GetAddress) ProtoMessage

func (*GetAddress) ProtoMessage()

func (*GetAddress) Reset

func (m *GetAddress) Reset()

func (*GetAddress) String

func (m *GetAddress) String() string

type GetShardToAddress

type GetShardToAddress struct {
	Version int64             `protobuf:"varint,1,opt,name=version" json:"version,omitempty"`
	Result  map[uint64]string `` /* 133-byte string literal not displayed */
	Error   string            `protobuf:"bytes,3,opt,name=error" json:"error,omitempty"`
}

func (*GetShardToAddress) Descriptor

func (*GetShardToAddress) Descriptor() ([]byte, []int)

func (*GetShardToAddress) GetResult

func (m *GetShardToAddress) GetResult() map[uint64]string

func (*GetShardToAddress) ProtoMessage

func (*GetShardToAddress) ProtoMessage()

func (*GetShardToAddress) Reset

func (m *GetShardToAddress) Reset()

func (*GetShardToAddress) String

func (m *GetShardToAddress) String() string

type RemoveServerRole

type RemoveServerRole struct {
	ServerRole *ServerRole `protobuf:"bytes,1,opt,name=serverRole" json:"serverRole,omitempty"`
	Error      string      `protobuf:"bytes,2,opt,name=error" json:"error,omitempty"`
}

func (*RemoveServerRole) Descriptor

func (*RemoveServerRole) Descriptor() ([]byte, []int)

func (*RemoveServerRole) GetServerRole

func (m *RemoveServerRole) GetServerRole() *ServerRole

func (*RemoveServerRole) ProtoMessage

func (*RemoveServerRole) ProtoMessage()

func (*RemoveServerRole) Reset

func (m *RemoveServerRole) Reset()

func (*RemoveServerRole) String

func (m *RemoveServerRole) String() string

type Router

type Router interface {
	GetShards(version int64) (map[uint64]bool, error)
	GetClientConn(shard uint64, version int64) (*grpc.ClientConn, error)
	GetAllClientConns(version int64) ([]*grpc.ClientConn, error)
	CloseClientConns() error // close all outstanding client connections
}

Router represents a router from shard id and version to grpc connections.

func NewRouter

func NewRouter(
	sharder Sharder,
	dialer grpcutil.Dialer,
	localAddress string,
) Router

NewRouter creates a Router.

type Server

type Server interface {
	// AddShard tells the server it now has a role for a shard.
	AddShard(shard uint64) error
	// RemoveShard tells the server it no longer has a role for a shard.
	DeleteShard(shard uint64) error
}

A Server represents a server that has roles for shards.

type ServerRole

type ServerRole struct {
	Address string          `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
	Version int64           `protobuf:"varint,2,opt,name=version" json:"version,omitempty"`
	Shards  map[uint64]bool `` /* 134-byte string literal not displayed */
}

func (*ServerRole) Descriptor

func (*ServerRole) Descriptor() ([]byte, []int)

func (*ServerRole) GetShards

func (m *ServerRole) GetShards() map[uint64]bool

func (*ServerRole) ProtoMessage

func (*ServerRole) ProtoMessage()

func (*ServerRole) Reset

func (m *ServerRole) Reset()

func (*ServerRole) String

func (m *ServerRole) String() string

type ServerState

type ServerState struct {
	Address string `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
	Version int64  `protobuf:"varint,2,opt,name=version" json:"version,omitempty"`
}

func (*ServerState) Descriptor

func (*ServerState) Descriptor() ([]byte, []int)

func (*ServerState) ProtoMessage

func (*ServerState) ProtoMessage()

func (*ServerState) Reset

func (m *ServerState) Reset()

func (*ServerState) String

func (m *ServerState) String() string

type SetAddresses

type SetAddresses struct {
	Addresses *Addresses `protobuf:"bytes,1,opt,name=addresses" json:"addresses,omitempty"`
}

func (*SetAddresses) Descriptor

func (*SetAddresses) Descriptor() ([]byte, []int)

func (*SetAddresses) GetAddresses

func (m *SetAddresses) GetAddresses() *Addresses

func (*SetAddresses) ProtoMessage

func (*SetAddresses) ProtoMessage()

func (*SetAddresses) Reset

func (m *SetAddresses) Reset()

func (*SetAddresses) String

func (m *SetAddresses) String() string

type SetFrontendState

type SetFrontendState struct {
	FrontendState *FrontendState `protobuf:"bytes,1,opt,name=frontendState" json:"frontendState,omitempty"`
}

func (*SetFrontendState) Descriptor

func (*SetFrontendState) Descriptor() ([]byte, []int)

func (*SetFrontendState) GetFrontendState

func (m *SetFrontendState) GetFrontendState() *FrontendState

func (*SetFrontendState) ProtoMessage

func (*SetFrontendState) ProtoMessage()

func (*SetFrontendState) Reset

func (m *SetFrontendState) Reset()

func (*SetFrontendState) String

func (m *SetFrontendState) String() string

type SetServerRole

type SetServerRole struct {
	ServerRole *ServerRole `protobuf:"bytes,2,opt,name=serverRole" json:"serverRole,omitempty"`
}

func (*SetServerRole) Descriptor

func (*SetServerRole) Descriptor() ([]byte, []int)

func (*SetServerRole) GetServerRole

func (m *SetServerRole) GetServerRole() *ServerRole

func (*SetServerRole) ProtoMessage

func (*SetServerRole) ProtoMessage()

func (*SetServerRole) Reset

func (m *SetServerRole) Reset()

func (*SetServerRole) String

func (m *SetServerRole) String() string

type SetServerState

type SetServerState struct {
	ServerState *ServerState `protobuf:"bytes,1,opt,name=serverState" json:"serverState,omitempty"`
}

func (*SetServerState) Descriptor

func (*SetServerState) Descriptor() ([]byte, []int)

func (*SetServerState) GetServerState

func (m *SetServerState) GetServerState() *ServerState

func (*SetServerState) ProtoMessage

func (*SetServerState) ProtoMessage()

func (*SetServerState) Reset

func (m *SetServerState) Reset()

func (*SetServerState) String

func (m *SetServerState) String() string

type Sharder

type Sharder interface {
	GetAddress(shard uint64, version int64) (string, bool, error)
	GetShardToAddress(version int64) (map[uint64]string, error)

	Register(cancel chan bool, address string, servers []Server) error
	RegisterFrontends(cancel chan bool, address string, frontends []Frontend) error
	AssignRoles(address string, cancel chan bool) error
}

Sharder distributes shards between a set of servers.

func NewLocalSharder

func NewLocalSharder(addresses []string, numShards uint64) Sharder

NewLocalSharder creates a Sharder user a list of addresses.

func NewSharder

func NewSharder(discoveryClient discovery.Client, numShards uint64, namespace string) Sharder

NewSharder creates a Sharder using a discovery client.

type StartAssignRoles

type StartAssignRoles struct {
}

func (*StartAssignRoles) Descriptor

func (*StartAssignRoles) Descriptor() ([]byte, []int)

func (*StartAssignRoles) ProtoMessage

func (*StartAssignRoles) ProtoMessage()

func (*StartAssignRoles) Reset

func (m *StartAssignRoles) Reset()

func (*StartAssignRoles) String

func (m *StartAssignRoles) String() string

type StartRegister

type StartRegister struct {
	Address string `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
}

func (*StartRegister) Descriptor

func (*StartRegister) Descriptor() ([]byte, []int)

func (*StartRegister) ProtoMessage

func (*StartRegister) ProtoMessage()

func (*StartRegister) Reset

func (m *StartRegister) Reset()

func (*StartRegister) String

func (m *StartRegister) String() string

type Version

type Version struct {
	Result int64  `protobuf:"varint,1,opt,name=result" json:"result,omitempty"`
	Error  string `protobuf:"bytes,2,opt,name=error" json:"error,omitempty"`
}

func (*Version) Descriptor

func (*Version) Descriptor() ([]byte, []int)

func (*Version) ProtoMessage

func (*Version) ProtoMessage()

func (*Version) Reset

func (m *Version) Reset()

func (*Version) String

func (m *Version) String() string

Jump to

Keyboard shortcuts

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