node

package
v0.0.0-...-1bf965b Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthTest        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTest          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTest = fmt.Errorf("proto: unexpected end of group")
)

Functions

func RegisterServer

func RegisterServer(server func(*grpc.Server, Protocol))

RegisterServer registers a service server

func RegisterServers

func RegisterServers(server *grpc.Server, protocol Protocol)

RegisterServers registers service servers on the given gRPC server

func RegisterService

func RegisterService(name string, service func(ctx service.Context) service.Service)

RegisterService registers a new service

Types

type Client

type Client 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
}

Client is the interface for protocol clients

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

	// OperationType returns the type of the operation currently being executed against the state machine
	OperationType() service.OperationType
}

Context provides information about the context within which a state machine is running

type GetRequest

type GetRequest struct {
}

Get request

func (*GetRequest) Descriptor

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

func (*GetRequest) Marshal

func (m *GetRequest) Marshal() (dAtA []byte, err error)

func (*GetRequest) MarshalTo

func (m *GetRequest) MarshalTo(dAtA []byte) (int, error)

func (*GetRequest) MarshalToSizedBuffer

func (m *GetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) Reset

func (m *GetRequest) Reset()

func (*GetRequest) Size

func (m *GetRequest) Size() (n int)

func (*GetRequest) String

func (m *GetRequest) String() string

func (*GetRequest) Unmarshal

func (m *GetRequest) Unmarshal(dAtA []byte) error

func (*GetRequest) XXX_DiscardUnknown

func (m *GetRequest) XXX_DiscardUnknown()

func (*GetRequest) XXX_Marshal

func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetRequest) XXX_Merge

func (m *GetRequest) XXX_Merge(src proto.Message)

func (*GetRequest) XXX_Size

func (m *GetRequest) XXX_Size() int

func (*GetRequest) XXX_Unmarshal

func (m *GetRequest) XXX_Unmarshal(b []byte) error

type GetResponse

type GetResponse struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
}

Get response

func (*GetResponse) Descriptor

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

func (*GetResponse) GetValue

func (m *GetResponse) GetValue() string

func (*GetResponse) Marshal

func (m *GetResponse) Marshal() (dAtA []byte, err error)

func (*GetResponse) MarshalTo

func (m *GetResponse) MarshalTo(dAtA []byte) (int, error)

func (*GetResponse) MarshalToSizedBuffer

func (m *GetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GetResponse) ProtoMessage

func (*GetResponse) ProtoMessage()

func (*GetResponse) Reset

func (m *GetResponse) Reset()

func (*GetResponse) Size

func (m *GetResponse) Size() (n int)

func (*GetResponse) String

func (m *GetResponse) String() string

func (*GetResponse) Unmarshal

func (m *GetResponse) Unmarshal(dAtA []byte) error

func (*GetResponse) XXX_DiscardUnknown

func (m *GetResponse) XXX_DiscardUnknown()

func (*GetResponse) XXX_Marshal

func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetResponse) XXX_Merge

func (m *GetResponse) XXX_Merge(src proto.Message)

func (*GetResponse) XXX_Size

func (m *GetResponse) XXX_Size() int

func (*GetResponse) XXX_Unmarshal

func (m *GetResponse) XXX_Unmarshal(b []byte) error

type Protocol

type Protocol interface {
	// Start starts the protocol
	Start(cluster cluster.Cluster, registry *Registry) error

	// Client returns the protocol client
	Client() Client

	// 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 GetRegistry

func GetRegistry() *Registry

GetRegistry returns the service registry

func (*Registry) RegisterServer

func (r *Registry) RegisterServer(server func(*grpc.Server, Protocol))

RegisterServer registers a new primitive server

func (*Registry) RegisterService

func (r *Registry) RegisterService(name string, service func(ctx service.Context) service.Service)

RegisterService registers a new primitive service

type SetRequest

type SetRequest struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
}

Set request

func (*SetRequest) Descriptor

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

func (*SetRequest) GetValue

func (m *SetRequest) GetValue() string

func (*SetRequest) Marshal

func (m *SetRequest) Marshal() (dAtA []byte, err error)

func (*SetRequest) MarshalTo

func (m *SetRequest) MarshalTo(dAtA []byte) (int, error)

func (*SetRequest) MarshalToSizedBuffer

func (m *SetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SetRequest) ProtoMessage

func (*SetRequest) ProtoMessage()

func (*SetRequest) Reset

func (m *SetRequest) Reset()

func (*SetRequest) Size

func (m *SetRequest) Size() (n int)

func (*SetRequest) String

func (m *SetRequest) String() string

func (*SetRequest) Unmarshal

func (m *SetRequest) Unmarshal(dAtA []byte) error

func (*SetRequest) XXX_DiscardUnknown

func (m *SetRequest) XXX_DiscardUnknown()

func (*SetRequest) XXX_Marshal

func (m *SetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SetRequest) XXX_Merge

func (m *SetRequest) XXX_Merge(src proto.Message)

func (*SetRequest) XXX_Size

func (m *SetRequest) XXX_Size() int

func (*SetRequest) XXX_Unmarshal

func (m *SetRequest) XXX_Unmarshal(b []byte) error

type SetResponse

type SetResponse struct {
}

Set response

func (*SetResponse) Descriptor

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

func (*SetResponse) Marshal

func (m *SetResponse) Marshal() (dAtA []byte, err error)

func (*SetResponse) MarshalTo

func (m *SetResponse) MarshalTo(dAtA []byte) (int, error)

func (*SetResponse) MarshalToSizedBuffer

func (m *SetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SetResponse) ProtoMessage

func (*SetResponse) ProtoMessage()

func (*SetResponse) Reset

func (m *SetResponse) Reset()

func (*SetResponse) Size

func (m *SetResponse) Size() (n int)

func (*SetResponse) String

func (m *SetResponse) String() string

func (*SetResponse) Unmarshal

func (m *SetResponse) Unmarshal(dAtA []byte) error

func (*SetResponse) XXX_DiscardUnknown

func (m *SetResponse) XXX_DiscardUnknown()

func (*SetResponse) XXX_Marshal

func (m *SetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SetResponse) XXX_Merge

func (m *SetResponse) XXX_Merge(src proto.Message)

func (*SetResponse) XXX_Size

func (m *SetResponse) XXX_Size() int

func (*SetResponse) XXX_Unmarshal

func (m *SetResponse) XXX_Unmarshal(b []byte) error

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

	// CanDelete returns a bool indicating whether the node can delete changes up to the given index without affecting
	// the correctness of the state machine
	CanDelete(index uint64) bool

	// 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

func NewPrimitiveStateMachine

func NewPrimitiveStateMachine(registry *Registry, ctx Context) StateMachine

NewPrimitiveStateMachine returns a new primitive state machine

type TestService

type TestService struct {
	*service.SessionizedService
	// contains filtered or unexported fields
}

TestService is a state machine for a test primitive

func (*TestService) Backup

func (s *TestService) Backup() ([]byte, error)

Backup backs up the map service

func (*TestService) Get

func (s *TestService) Get(value []byte) ([]byte, error)

Get gets the value

func (*TestService) Restore

func (s *TestService) Restore(bytes []byte) error

Restore restores the map service

func (*TestService) Set

func (s *TestService) Set(value []byte) ([]byte, error)

Set sets the value

type TestValueSnapshot

type TestValueSnapshot struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
}

Test value snapshot

func (*TestValueSnapshot) Descriptor

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

func (*TestValueSnapshot) GetValue

func (m *TestValueSnapshot) GetValue() string

func (*TestValueSnapshot) Marshal

func (m *TestValueSnapshot) Marshal() (dAtA []byte, err error)

func (*TestValueSnapshot) MarshalTo

func (m *TestValueSnapshot) MarshalTo(dAtA []byte) (int, error)

func (*TestValueSnapshot) MarshalToSizedBuffer

func (m *TestValueSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*TestValueSnapshot) ProtoMessage

func (*TestValueSnapshot) ProtoMessage()

func (*TestValueSnapshot) Reset

func (m *TestValueSnapshot) Reset()

func (*TestValueSnapshot) Size

func (m *TestValueSnapshot) Size() (n int)

func (*TestValueSnapshot) String

func (m *TestValueSnapshot) String() string

func (*TestValueSnapshot) Unmarshal

func (m *TestValueSnapshot) Unmarshal(dAtA []byte) error

func (*TestValueSnapshot) XXX_DiscardUnknown

func (m *TestValueSnapshot) XXX_DiscardUnknown()

func (*TestValueSnapshot) XXX_Marshal

func (m *TestValueSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TestValueSnapshot) XXX_Merge

func (m *TestValueSnapshot) XXX_Merge(src proto.Message)

func (*TestValueSnapshot) XXX_Size

func (m *TestValueSnapshot) XXX_Size() int

func (*TestValueSnapshot) XXX_Unmarshal

func (m *TestValueSnapshot) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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