Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterServer ¶
RegisterServer registers a service server
func RegisterServers ¶
RegisterServers registers service servers on the given gRPC server
func RegisterService ¶
func RegisterService(serviceType service.ServiceType, service func(scheduler service.Scheduler, context service.Context) service.Service)
RegisterService registers a new service
Types ¶
type Context ¶
type Context interface { // Node is the local node identifier Node() string // Index returns the current index of the state machine Index() uint64 // Timestamp returns a deterministic, monotonically increasing timestamp Timestamp() time.Time }
Context provides information about the context within which a state machine is running
type Partition ¶
type Partition interface { // MustLeader returns whether the client can only be used on the leader MustLeader() bool // IsLeader returns whether the client is the leader IsLeader() bool // Leader returns the current leader Leader() string // Write sends a write request Write(ctx context.Context, input []byte, stream stream.WriteStream) error // Read sends a read request Read(ctx context.Context, input []byte, stream stream.WriteStream) error }
Partition is the interface for a partition client
type Protocol ¶
type Protocol interface { // Start starts the protocol Start(cluster cluster.Cluster, registry *Registry) error // Partition returns a partition Partition(partitionID int) Partition // Partitions returns the protocol partitions Partitions() []Partition // Stop stops the protocol Stop() error }
Protocol is the interface to be implemented by replication protocols
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a registry of service types
func (*Registry) GetType ¶
func (r *Registry) GetType(serviceType service.ServiceType) func(scheduler service.Scheduler, context service.Context) service.Service
GetType returns a service type by name
func (*Registry) RegisterServer ¶
RegisterServer registers a new primitive server
type StateMachine ¶
type StateMachine interface { // Snapshot writes the state machine snapshot to the given writer Snapshot(writer io.Writer) error // Install reads the state machine snapshot from the given reader Install(reader io.Reader) error // Command applies a command to the state machine Command(bytes []byte, stream streams.WriteStream) // Query applies a query to the state machine Query(bytes []byte, stream streams.WriteStream) }
StateMachine applies commands from a protocol to a collection of state machines
Click to show internal directories.
Click to hide internal directories.