dev

package
v0.1.0-gogo Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package dev is a generated protocol buffer package.

Package dev provides a blueprint for testing the various call semantics provided by Gorums. The following table explains the differences in call semantics.

Replies per server      Gorums termination check    # times qfunc can update result     Server-side reply type

------------------------------------------------------------------------------------------------------------------------------------------------ Quorum call 1 Reply + error count 1 Single response Correctable Quorum Call 1 Reply + error count N Single response Correctable Stream QC M Error count M Stream of responses

It is generated from these files:

dev/storage.proto

It has these top-level messages:

State
MyState
WriteResponse
ReadRequest
Empty

Index

Constants

View Source
const LevelNotSet = -1

LevelNotSet is the zero value level used to indicate that no level (and thereby no reply) has been set for a correctable quorum call.

Variables

View Source
var (
	ErrInvalidLengthStorage = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowStorage   = fmt.Errorf("proto: integer overflow")
)
View Source
var Error = func(n1, n2 *Node) bool {
	if n1.lastErr != nil && n2.lastErr == nil {
		return false
	}
	return true
}

Error sorts nodes by their LastErr() status in increasing order. A node with LastErr() != nil is larger than a node with LastErr() == nil.

View Source
var ID = func(n1, n2 *Node) bool {
	return n1.id < n2.id
}

ID sorts nodes by their identifier in increasing order.

View Source
var Latency = func(n1, n2 *Node) bool {
	if n1.latency < 0 {
		return false
	}
	return n1.latency < n2.latency

}

Latency sorts nodes by latency in increasing order. Latencies less then zero (sentinel value) are considered greater than any positive latency.

View Source
var Port = func(n1, n2 *Node) bool {
	p1, _ := strconv.Atoi(n1.Port())
	p2, _ := strconv.Atoi(n2.Port())
	return p1 < p2
}

Port sorts nodes by their port number in increasing order. Warning: This function may be removed in the future.

Functions

func Equal

func Equal(a, b *Configuration) bool

Equal returns a boolean reporting whether a and b represents the same configuration.

func ManagerCreationError

func ManagerCreationError(err error) error

ManagerCreationError returns an error reporting that a Manager could not be created due to err.

func RegisterStorageServer

func RegisterStorageServer(s *grpc.Server, srv StorageServer)

Types

type ConfigNotFoundError

type ConfigNotFoundError uint32

A ConfigNotFoundError reports that a specified configuration could not be found.

func (ConfigNotFoundError) Error

func (e ConfigNotFoundError) Error() string

type Configuration

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

A Configuration represents a static set of nodes on which quorum remote procedure calls may be invoked.

func (*Configuration) ID

func (c *Configuration) ID() uint32

ID reports the identifier for the configuration.

func (*Configuration) NodeIDs

func (c *Configuration) NodeIDs() []uint32

NodeIDs returns a slice containing the local ids of all the nodes in the configuration. IDs are returned in the same order as they were provided in the creation of the Configuration.

func (*Configuration) Nodes

func (c *Configuration) Nodes() []*Node

Nodes returns a slice of each available node. IDs are returned in the same order as they were provided in the creation of the Configuration.

func (*Configuration) Read

func (c *Configuration) Read(ctx context.Context, a *ReadRequest) (resp *State, err error)

Read is invoked as a quorum call on all nodes in configuration c, using the same argument arg, and returns the result.

func (*Configuration) ReadCorrectable

func (c *Configuration) ReadCorrectable(ctx context.Context, arg *ReadRequest) *CorrectableState

ReadCorrectable asynchronously invokes a correctable ReadCorrectable quorum call on configuration c and returns a CorrectableState which can be used to inspect any replies or errors when available.

func (*Configuration) ReadCorrectableStream

func (c *Configuration) ReadCorrectableStream(ctx context.Context, arg *ReadRequest) *CorrectableStreamState

ReadCorrectableStream asynchronously invokes a correctable ReadCorrectableStream quorum call with server side preliminary reply support on configuration c and returns a CorrectableStreamState which can be used to inspect any replies or errors when available.

func (*Configuration) ReadCustomReturn

func (c *Configuration) ReadCustomReturn(ctx context.Context, a *ReadRequest) (resp *MyState, err error)

ReadCustomReturn is invoked as a quorum call on all nodes in configuration c, using the same argument arg, and returns the result.

func (*Configuration) ReadFuture

func (c *Configuration) ReadFuture(ctx context.Context, arg *ReadRequest) *FutureState

ReadFuture asynchronously invokes a quorum call on configuration c and returns a FutureState which can be used to inspect the quorum call reply and error when available.

func (*Configuration) Size

func (c *Configuration) Size() int

Size returns the number of nodes in the configuration.

func (*Configuration) String

func (c *Configuration) String() string

func (*Configuration) SubError

func (c *Configuration) SubError() <-chan GRPCError

SubError returns a channel for listening to individual node errors. Currently only a single listener is supported.

func (*Configuration) Write

func (c *Configuration) Write(ctx context.Context, a *State) (resp *WriteResponse, err error)

Write is invoked as a quorum call on all nodes in configuration c, using the same argument arg, and returns the result.

func (*Configuration) WriteAsync

func (c *Configuration) WriteAsync(arg *State) error

WriteAsync is a one-way multicast call on all nodes in configuration c, using the same argument arg. The call is asynchronous and has no return value.

func (*Configuration) WriteFuture

func (c *Configuration) WriteFuture(ctx context.Context, arg *State) *FutureWriteResponse

WriteFuture asynchronously invokes a quorum call on configuration c and returns a FutureWriteResponse which can be used to inspect the quorum call reply and error when available.

func (*Configuration) WritePerNode

func (c *Configuration) WritePerNode(ctx context.Context, a *State, f func(arg State, nodeID uint32) *State) (resp *WriteResponse, err error)

WritePerNode is invoked as a quorum call on each node in configuration c, with the argument returned by the provided perNode function and returns the result. The perNode function takes a request arg and returns a State object to be passed to the given nodeID. The perNode function should be thread-safe.

type CorrectableState

type CorrectableState struct {

	// the actual reply
	*State
	NodeIDs []uint32
	// contains filtered or unexported fields
}

CorrectableState for processing correctable State replies.

func (*CorrectableState) Done

func (c *CorrectableState) Done() <-chan struct{}

Done returns a channel that's closed when the correctable ReadCorrectable quorum call is done. A call is considered done when the quorum function has signaled that a quorum of replies was received or that the call returned an error.

func (*CorrectableState) Get

func (c *CorrectableState) Get() (*State, int, error)

Get returns the reply, level and any error associated with the ReadCorrectable. The method does not block until a (possibly itermidiate) reply or error is available. Level is set to LevelNotSet if no reply has yet been received. The Done or Watch methods should be used to ensure that a reply is available.

func (*CorrectableState) Watch

func (c *CorrectableState) Watch(level int) <-chan struct{}

Watch returns a channel that's closed when a reply or error at or above the specified level is available. If the call is done, the channel is closed disregardless of the specified level.

type CorrectableStreamState

type CorrectableStreamState struct {

	// the actual reply
	*State
	NodeIDs []uint32
	// contains filtered or unexported fields
}

CorrectableStreamState for processing correctable State replies.

func (*CorrectableStreamState) Done

func (c *CorrectableStreamState) Done() <-chan struct{}

Done returns a channel that's closed when the correctable ReadCorrectableStream quorum call is done. A call is considered done when the quorum function has signaled that a quorum of replies was received or that the call returned an error.

func (*CorrectableStreamState) Get

func (c *CorrectableStreamState) Get() (*State, int, error)

Get returns the reply, level and any error associated with the ReadCorrectableStream. The method does not block until a (possibly itermidiate) reply or error is available. Level is set to LevelNotSet if no reply has yet been received. The Done or Watch methods should be used to ensure that a reply is available.

func (*CorrectableStreamState) Watch

func (c *CorrectableStreamState) Watch(level int) <-chan struct{}

Watch returns a channel that's closed when a reply or error at or above the specified level is available. If the call is done, the channel is closed disregardless of the specified level.

type Empty

type Empty struct {
}

func (*Empty) Descriptor

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

func (*Empty) Marshal

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

func (*Empty) MarshalTo

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

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) Size

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

func (*Empty) String

func (this *Empty) String() string

func (*Empty) Unmarshal

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

type FutureState

type FutureState struct {
	// the actual reply
	*State
	NodeIDs []uint32
	// contains filtered or unexported fields
}

FutureState is a future object for an asynchronous quorum call invocation.

func (*FutureState) Done

func (f *FutureState) Done() bool

Done reports if a reply and/or error is available for the ReadFuture.

func (*FutureState) Get

func (f *FutureState) Get() (*State, error)

Get returns the reply and any error associated with the ReadFuture. The method blocks until a reply or error is available.

type FutureWriteResponse

type FutureWriteResponse struct {
	// the actual reply
	*WriteResponse
	NodeIDs []uint32
	// contains filtered or unexported fields
}

FutureWriteResponse is a future object for an asynchronous quorum call invocation.

func (*FutureWriteResponse) Done

func (f *FutureWriteResponse) Done() bool

Done reports if a reply and/or error is available for the WriteFuture.

func (*FutureWriteResponse) Get

Get returns the reply and any error associated with the WriteFuture. The method blocks until a reply or error is available.

type GRPCError

type GRPCError struct {
	NodeID uint32
	Cause  error
}

GRPCError is used to report that a single gRPC call failed.

func (GRPCError) Error

func (e GRPCError) Error() string

type IllegalConfigError

type IllegalConfigError string

An IllegalConfigError reports that a specified configuration could not be created.

func (IllegalConfigError) Error

func (e IllegalConfigError) Error() string

type Manager

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

Manager manages a pool of node configurations on which quorum remote procedure calls can be made.

func NewManager

func NewManager(nodeAddrs []string, opts ...ManagerOption) (*Manager, error)

NewManager attempts to connect to the given set of node addresses and if successful returns a new Manager containing connections to those nodes.

func (*Manager) AddNode

func (m *Manager) AddNode(addr string) error

AddNode attempts to dial to the provide node address. The node is added to the Manager's pool of nodes if a connection was established.

func (*Manager) Close

func (m *Manager) Close()

Close closes all node connections and any client streams.

func (*Manager) Configuration

func (m *Manager) Configuration(id uint32) (config *Configuration, found bool)

Configuration returns the configuration with the given global identifier if present.

func (*Manager) ConfigurationIDs

func (m *Manager) ConfigurationIDs() []uint32

ConfigurationIDs returns the identifier of each available configuration.

func (*Manager) Configurations

func (m *Manager) Configurations() []*Configuration

Configurations returns a slice of each available configuration.

func (*Manager) NewConfiguration

func (m *Manager) NewConfiguration(ids []uint32, qspec QuorumSpec) (*Configuration, error)

NewConfiguration returns a new configuration given quorum specification and a timeout.

func (*Manager) Node

func (m *Manager) Node(id uint32) (node *Node, found bool)

Node returns the node with the given identifier if present.

func (*Manager) NodeIDs

func (m *Manager) NodeIDs() []uint32

NodeIDs returns the identifier of each available node. IDs are returned in the same order as they were provided in the creation of the Manager.

func (*Manager) Nodes

func (m *Manager) Nodes() []*Node

Nodes returns a slice of each available node. IDs are returned in the same order as they were provided in the creation of the Manager.

func (*Manager) Size

func (m *Manager) Size() (nodes, configs int)

Size returns the number of nodes and configurations in the Manager.

type ManagerOption

type ManagerOption func(*managerOptions)

ManagerOption provides a way to set different options on a new Manager.

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) ManagerOption

WithDialTimeout returns a ManagerOption which is used to set the dial context timeout to be used when initially connecting to each node in its pool.

func WithGrpcDialOptions

func WithGrpcDialOptions(opts ...grpc.DialOption) ManagerOption

WithGrpcDialOptions returns a ManagerOption which sets any gRPC dial options the Manager should use when initially connecting to each node in its pool.

func WithLogger

func WithLogger(logger *log.Logger) ManagerOption

WithLogger returns a ManagerOption which sets an optional error logger for the Manager.

func WithNoConnect

func WithNoConnect() ManagerOption

WithNoConnect returns a ManagerOption which instructs the Manager not to connect to any of its nodes. Mainly used for testing purposes.

func WithTracing

func WithTracing() ManagerOption

WithTracing controls whether to trace qourum calls for this Manager instance using the golang.org/x/net/trace package. Tracing is currently only supported for regular quorum calls.

type MultiSorter

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

MultiSorter implements the Sort interface, sorting the nodes within.

func OrderedBy

func OrderedBy(less ...lessFunc) *MultiSorter

OrderedBy returns a Sorter that sorts using the less functions, in order. Call its Sort method to sort the data.

func (*MultiSorter) Len

func (ms *MultiSorter) Len() int

Len is part of sort.Interface.

func (*MultiSorter) Less

func (ms *MultiSorter) Less(i, j int) bool

Less is part of sort.Interface. It is implemented by looping along the less functions until it finds a comparison that is either Less or !Less. Note that it can call the less functions twice per call. We could change the functions to return -1, 0, 1 and reduce the number of calls for greater efficiency: an exercise for the reader.

func (*MultiSorter) Sort

func (ms *MultiSorter) Sort(nodes []*Node)

Sort sorts the argument slice according to the less functions passed to OrderedBy.

func (*MultiSorter) Swap

func (ms *MultiSorter) Swap(i, j int)

Swap is part of sort.Interface.

type MyState

type MyState struct {
	Value     string `protobuf:"bytes,1,opt,name=Value,proto3" json:"Value,omitempty"`
	Timestamp int64  `protobuf:"varint,2,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"`
	Extra     int64  `protobuf:"varint,3,opt,name=Extra,proto3" json:"Extra,omitempty"`
}

func (*MyState) Descriptor

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

func (*MyState) GetExtra

func (m *MyState) GetExtra() int64

func (*MyState) GetTimestamp

func (m *MyState) GetTimestamp() int64

func (*MyState) GetValue

func (m *MyState) GetValue() string

func (*MyState) Marshal

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

func (*MyState) MarshalTo

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

func (*MyState) ProtoMessage

func (*MyState) ProtoMessage()

func (*MyState) Reset

func (m *MyState) Reset()

func (*MyState) Size

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

func (*MyState) String

func (this *MyState) String() string

func (*MyState) Unmarshal

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

type Node

type Node struct {
	StorageClient StorageClient

	WriteAsyncClient Storage_WriteAsyncClient
	// contains filtered or unexported fields
}

Node encapsulates the state of a node on which a remote procedure call can be made.

func (*Node) Address

func (n *Node) Address() string

Address returns network address of n.

func (*Node) FullString

func (n *Node) FullString() string

FullString returns a more descriptive string representation of n that includes id, network address and latency information.

func (*Node) ID

func (n *Node) ID() uint32

ID returns the ID of n.

func (*Node) LastErr

func (n *Node) LastErr() error

LastErr returns the last error encountered (if any) when invoking a remote procedure call on this node.

func (*Node) Latency

func (n *Node) Latency() time.Duration

Latency returns the latency of the last successful remote procedure call made to this node.

func (*Node) Port

func (n *Node) Port() string

Port returns network port of n.

func (*Node) String

func (n *Node) String() string

type NodeNotFoundError

type NodeNotFoundError uint32

A NodeNotFoundError reports that a specified node could not be found.

func (NodeNotFoundError) Error

func (e NodeNotFoundError) Error() string

type QuorumCallError

type QuorumCallError struct {
	Reason     string
	ReplyCount int
	Errors     []GRPCError
}

A QuorumCallError is used to report that a quorum call failed.

func (QuorumCallError) Error

func (e QuorumCallError) Error() string

type QuorumSpec

type QuorumSpec interface {
	// ReadQF is the quorum function for the Read
	// quorum call method.
	ReadQF(replies []*State) (*State, bool)

	// ReadCorrectableQF is the quorum function for the ReadCorrectable
	// correctable quorum call method.
	ReadCorrectableQF(replies []*State) (*State, int, bool)

	// ReadCorrectableStreamQF is the quorum function for the ReadCorrectableStream
	// correctable stream quourm call method.
	ReadCorrectableStreamQF(replies []*State) (*State, int, bool)

	// ReadCustomReturnQF is the quorum function for the ReadCustomReturn
	// quorum call method.
	ReadCustomReturnQF(replies []*State) (*MyState, bool)

	// ReadFutureQF is the quorum function for the ReadFuture
	// asynchronous quorum call method.
	ReadFutureQF(replies []*State) (*State, bool)

	// WriteQF is the quorum function for the Write
	// quorum call method.
	WriteQF(req *State, replies []*WriteResponse) (*WriteResponse, bool)

	// WriteFutureQF is the quorum function for the WriteFuture
	// asynchronous quorum call method.
	WriteFutureQF(req *State, replies []*WriteResponse) (*WriteResponse, bool)

	// WritePerNodeQF is the quorum function for the WritePerNode
	// quorum call method.
	WritePerNodeQF(replies []*WriteResponse) (*WriteResponse, bool)
}

QuorumSpec is the interface that wraps every quorum function.

type ReadRequest

type ReadRequest struct {
}

func (*ReadRequest) Descriptor

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

func (*ReadRequest) Marshal

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

func (*ReadRequest) MarshalTo

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

func (*ReadRequest) ProtoMessage

func (*ReadRequest) ProtoMessage()

func (*ReadRequest) Reset

func (m *ReadRequest) Reset()

func (*ReadRequest) Size

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

func (*ReadRequest) String

func (this *ReadRequest) String() string

func (*ReadRequest) Unmarshal

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

type State

type State struct {
	Value     string `protobuf:"bytes,1,opt,name=Value,proto3" json:"Value,omitempty"`
	Timestamp int64  `protobuf:"varint,2,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"`
}

func (*State) Descriptor

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

func (*State) GetTimestamp

func (m *State) GetTimestamp() int64

func (*State) GetValue

func (m *State) GetValue() string

func (*State) Marshal

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

func (*State) MarshalTo

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

func (*State) ProtoMessage

func (*State) ProtoMessage()

func (*State) Reset

func (m *State) Reset()

func (*State) Size

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

func (*State) String

func (this *State) String() string

func (*State) Unmarshal

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

type StorageClient

type StorageClient interface {
	// ReadNoQC is a plain gRPC call.
	ReadNoQC(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*State, error)
	// Read is a synchronous quorum call that returns a single State object
	// once a quorum of replies have been received. The returned State object
	// is computed by the quorum function.
	Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*State, error)
	// ReadFuture is an asynchronous quorum call that
	// returns a FutureState object for retrieving results.
	ReadFuture(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*State, error)
	// ReadCustomReturn is a synchronous quorum call with a custom return type MyState.
	ReadCustomReturn(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*State, error)
	// ReadCorrectable is an asynchronous correctable quorum call that
	// returns a CorrectableState object for retrieving results.
	// Each server will reply with at most one result that the client
	// can process in its quorum function.
	ReadCorrectable(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*State, error)
	// ReadCorrectableStream is an asynchronous correctable stream call that
	// returns a CorrectableStreamState object for retrieving results.
	// Each server can send a stream of responses that the client can process
	// in its quorum function.
	ReadCorrectableStream(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (Storage_ReadCorrectableStreamClient, error)
	// Write is a synchronous quorum call, in which the State request argument
	// is also passed to the associated quorum function, WriteQF, for this method.
	Write(ctx context.Context, in *State, opts ...grpc.CallOption) (*WriteResponse, error)
	// WriteFuture is an asynchronous quorum call that
	// returns a FutureWriteResponse object for retrieving results.
	// The request argument (State) is also passed to the associated
	// quorum function, WriteFutureQF, for this method.
	WriteFuture(ctx context.Context, in *State, opts ...grpc.CallOption) (*WriteResponse, error)
	// WriteAsync is an asynchronous multicast to all nodes in a configuration.
	// No replies are collected.
	WriteAsync(ctx context.Context, opts ...grpc.CallOption) (Storage_WriteAsyncClient, error)
	// WritePerNode is a synchronous quorum call, where, for each node,
	// a provided function is called to determine the argument to be sent
	// to that node. This is useful for quorum calls where the different
	// servers/nodes expect a variation over the input argument.
	WritePerNode(ctx context.Context, in *State, opts ...grpc.CallOption) (*WriteResponse, error)
}

func NewStorageClient

func NewStorageClient(cc *grpc.ClientConn) StorageClient

type StorageServer

type StorageServer interface {
	// ReadNoQC is a plain gRPC call.
	ReadNoQC(context.Context, *ReadRequest) (*State, error)
	// Read is a synchronous quorum call that returns a single State object
	// once a quorum of replies have been received. The returned State object
	// is computed by the quorum function.
	Read(context.Context, *ReadRequest) (*State, error)
	// ReadFuture is an asynchronous quorum call that
	// returns a FutureState object for retrieving results.
	ReadFuture(context.Context, *ReadRequest) (*State, error)
	// ReadCustomReturn is a synchronous quorum call with a custom return type MyState.
	ReadCustomReturn(context.Context, *ReadRequest) (*State, error)
	// ReadCorrectable is an asynchronous correctable quorum call that
	// returns a CorrectableState object for retrieving results.
	// Each server will reply with at most one result that the client
	// can process in its quorum function.
	ReadCorrectable(context.Context, *ReadRequest) (*State, error)
	// ReadCorrectableStream is an asynchronous correctable stream call that
	// returns a CorrectableStreamState object for retrieving results.
	// Each server can send a stream of responses that the client can process
	// in its quorum function.
	ReadCorrectableStream(*ReadRequest, Storage_ReadCorrectableStreamServer) error
	// Write is a synchronous quorum call, in which the State request argument
	// is also passed to the associated quorum function, WriteQF, for this method.
	Write(context.Context, *State) (*WriteResponse, error)
	// WriteFuture is an asynchronous quorum call that
	// returns a FutureWriteResponse object for retrieving results.
	// The request argument (State) is also passed to the associated
	// quorum function, WriteFutureQF, for this method.
	WriteFuture(context.Context, *State) (*WriteResponse, error)
	// WriteAsync is an asynchronous multicast to all nodes in a configuration.
	// No replies are collected.
	WriteAsync(Storage_WriteAsyncServer) error
	// WritePerNode is a synchronous quorum call, where, for each node,
	// a provided function is called to determine the argument to be sent
	// to that node. This is useful for quorum calls where the different
	// servers/nodes expect a variation over the input argument.
	WritePerNode(context.Context, *State) (*WriteResponse, error)
}

type StorageServerBasic

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

StorageServerBasic represents a single state storage.

func NewStorageBasic

func NewStorageBasic() *StorageServerBasic

NewStorageBasic returns a new basic storage server.

func NewStorageBasicWithState

func NewStorageBasicWithState(state *State) *StorageServerBasic

NewStorageBasicWithState returns a new basic storage server with an initial state set.

func (*StorageServerBasic) Read

func (s *StorageServerBasic) Read(ctx context.Context, rq *ReadRequest) (*State, error)

Read implements the Read method.

func (*StorageServerBasic) ReadCorrectable

func (s *StorageServerBasic) ReadCorrectable(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCorrectable implements the ReadCorrectable method.

func (*StorageServerBasic) ReadCorrectableStream

func (s *StorageServerBasic) ReadCorrectableStream(rq *ReadRequest, srts Storage_ReadCorrectableStreamServer) error

ReadCorrectableStream implements the ReadCorrectableStream method from the StorageServer interface.

func (*StorageServerBasic) ReadCustomReturn

func (s *StorageServerBasic) ReadCustomReturn(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCustomReturn implements the ReadCustomReturn method.

func (*StorageServerBasic) ReadExecuted

func (s *StorageServerBasic) ReadExecuted()

ReadExecuted returns when s has completed a read.

func (*StorageServerBasic) ReadFuture

func (s *StorageServerBasic) ReadFuture(ctx context.Context, rq *ReadRequest) (*State, error)

ReadFuture implements the ReadFuture method.

func (*StorageServerBasic) ReadNoQC

func (s *StorageServerBasic) ReadNoQC(ctx context.Context, rq *ReadRequest) (*State, error)

ReadNoQC implements the ReadNoQC method from the StorageServer interface.

func (*StorageServerBasic) Write

func (s *StorageServerBasic) Write(ctx context.Context, state *State) (*WriteResponse, error)

Write implements the Write method.

func (*StorageServerBasic) WriteAsync

func (s *StorageServerBasic) WriteAsync(stream Storage_WriteAsyncServer) error

WriteAsync implements the WriteAsync method from the StorageServer interface.

func (*StorageServerBasic) WriteExecuted

func (s *StorageServerBasic) WriteExecuted()

WriteExecuted returns when s has completed a write.

func (*StorageServerBasic) WriteFuture

func (s *StorageServerBasic) WriteFuture(ctx context.Context, state *State) (*WriteResponse, error)

WriteFuture implements the WriteFuture method.

func (*StorageServerBasic) WritePerNode

func (s *StorageServerBasic) WritePerNode(ctx context.Context, state *State) (*WriteResponse, error)

WritePerNode implements the WritePerNode method.

type StorageServerBench

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

StorageServerBench represents a single State storage used for benchmarking.

func NewStorageBench

func NewStorageBench() *StorageServerBench

NewStorageBench returns a new storage benchmark server.

func (*StorageServerBench) Read

func (s *StorageServerBench) Read(ctx context.Context, rq *ReadRequest) (*State, error)

Read implements the Read method.

func (*StorageServerBench) ReadCorrectable

func (s *StorageServerBench) ReadCorrectable(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCorrectable implements the ReadCorrectable method.

func (*StorageServerBench) ReadCorrectableStream

func (s *StorageServerBench) ReadCorrectableStream(rq *ReadRequest, srts Storage_ReadCorrectableStreamServer) error

ReadCorrectableStream implements the ReadCorrectableStream method from the StorageServer interface.

func (*StorageServerBench) ReadCustomReturn

func (s *StorageServerBench) ReadCustomReturn(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCustomReturn implements the ReadCustomReturn method.

func (*StorageServerBench) ReadExecuted

func (s *StorageServerBench) ReadExecuted()

ReadExecuted is a no-op.

func (*StorageServerBench) ReadFuture

func (s *StorageServerBench) ReadFuture(ctx context.Context, rq *ReadRequest) (*State, error)

ReadFuture implements the ReadFuture method.

func (*StorageServerBench) ReadNoQC

func (s *StorageServerBench) ReadNoQC(ctx context.Context, rq *ReadRequest) (*State, error)

ReadNoQC implements the ReadNoQC method from the StorageServer interface.

func (*StorageServerBench) Write

func (s *StorageServerBench) Write(ctx context.Context, state *State) (*WriteResponse, error)

Write implements the Write method.

func (*StorageServerBench) WriteAsync

func (s *StorageServerBench) WriteAsync(stream Storage_WriteAsyncServer) error

WriteAsync implements the WriteAsync method from the StorageServer interface.

func (*StorageServerBench) WriteExecuted

func (s *StorageServerBench) WriteExecuted()

WriteExecuted is no-op.

func (*StorageServerBench) WriteFuture

func (s *StorageServerBench) WriteFuture(ctx context.Context, state *State) (*WriteResponse, error)

WriteFuture implements the WriteFuture method.

func (*StorageServerBench) WritePerNode

func (s *StorageServerBench) WritePerNode(ctx context.Context, state *State) (*WriteResponse, error)

WritePerNode implements the WritePerNode method.

type StorageServerError

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

StorageServerError represents a storage server that for any of its methods always returns an error.

func NewStorageError

func NewStorageError(err error) *StorageServerError

NewStorageError returns a new error storage server.

func (*StorageServerError) Read

func (s *StorageServerError) Read(ctx context.Context, rq *ReadRequest) (*State, error)

Read implements the Read method.

func (*StorageServerError) ReadCorrectable

func (s *StorageServerError) ReadCorrectable(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCorrectable implements the ReadCorrectable method.

func (*StorageServerError) ReadCorrectableStream

func (s *StorageServerError) ReadCorrectableStream(rq *ReadRequest, srts Storage_ReadCorrectableStreamServer) error

ReadCorrectableStream implements the ReadCorrectableStream method from the StorageServer interface.

func (*StorageServerError) ReadCustomReturn

func (s *StorageServerError) ReadCustomReturn(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCustomReturn implements the ReadCustomReturn method.

func (*StorageServerError) ReadExecuted

func (s *StorageServerError) ReadExecuted()

ReadExecuted never returns since s always returns an error for Read.

func (*StorageServerError) ReadFuture

func (s *StorageServerError) ReadFuture(ctx context.Context, rq *ReadRequest) (*State, error)

ReadFuture implements the ReadFuture method.

func (*StorageServerError) ReadNoQC

func (s *StorageServerError) ReadNoQC(ctx context.Context, rq *ReadRequest) (*State, error)

ReadNoQC implements the ReadNoQC method from the StorageServer interface.

func (*StorageServerError) Write

func (s *StorageServerError) Write(ctx context.Context, state *State) (*WriteResponse, error)

Write implements the Write method.

func (*StorageServerError) WriteAsync

func (s *StorageServerError) WriteAsync(stream Storage_WriteAsyncServer) error

WriteAsync implements the WriteAsync method from the StorageServer interface.

func (*StorageServerError) WriteExecuted

func (s *StorageServerError) WriteExecuted()

WriteExecuted never returns since s always returns an error for Write.

func (*StorageServerError) WriteFuture

func (s *StorageServerError) WriteFuture(ctx context.Context, state *State) (*WriteResponse, error)

WriteFuture implements the WriteFuture method.

func (*StorageServerError) WritePerNode

func (s *StorageServerError) WritePerNode(ctx context.Context, state *State) (*WriteResponse, error)

WritePerNode implements the WritePerNode method.

type StorageServerLockedWithState

type StorageServerLockedWithState struct {
	ReadCorrectableStreamNumReplies int
	ReadCorrectableStreamLockChan   chan struct{}
	// contains filtered or unexported fields
}

StorageServerLockedWithState represents a storage server with an initial state that does not reply to any requests before it's unlocked.

func NewStorageServerLockedWithState

func NewStorageServerLockedWithState(state *State, ReadCorrectableStreamNumReplies int) *StorageServerLockedWithState

NewStorageServerLockedWithState returns a new locked storage server with an initial state.

func (*StorageServerLockedWithState) PerformSingleReadCorrectableStream

func (s *StorageServerLockedWithState) PerformSingleReadCorrectableStream()

PerformSingleReadCorrectableStream lets the storage server send a single reply from a single ReadCorrectableStream method handler.

func (*StorageServerLockedWithState) Read

Read implements the Read method.

func (*StorageServerLockedWithState) ReadCorrectable

func (s *StorageServerLockedWithState) ReadCorrectable(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCorrectable implements the ReadCorrectable method.

func (*StorageServerLockedWithState) ReadCorrectableStream

ReadCorrectableStream implements the ReadCorrectableStream method from the StorageServer interface.

func (*StorageServerLockedWithState) ReadCustomReturn

func (s *StorageServerLockedWithState) ReadCustomReturn(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCustomReturn implements the ReadCustomReturn method.

func (*StorageServerLockedWithState) ReadExecuted

func (s *StorageServerLockedWithState) ReadExecuted()

ReadExecuted returns when r has has completed a read.

func (*StorageServerLockedWithState) ReadFuture

func (s *StorageServerLockedWithState) ReadFuture(ctx context.Context, rq *ReadRequest) (*State, error)

ReadFuture implements the ReadFuture method.

func (*StorageServerLockedWithState) ReadNoQC

ReadNoQC implements the ReadNoQC method from the StorageServer interface.

func (*StorageServerLockedWithState) Unlock

func (s *StorageServerLockedWithState) Unlock()

Unlock unlocks the storage server.

func (*StorageServerLockedWithState) Write

func (*StorageServerLockedWithState) WriteAsync

WriteAsync implements the WriteAsync method from the StorageServer interface.

func (*StorageServerLockedWithState) WriteExecuted

func (s *StorageServerLockedWithState) WriteExecuted()

WriteExecuted returns when r has has completed a write.

func (*StorageServerLockedWithState) WriteFuture

func (s *StorageServerLockedWithState) WriteFuture(ctx context.Context, state *State) (*WriteResponse, error)

WriteFuture implements the WriteFuture method.

func (*StorageServerLockedWithState) WritePerNode

func (s *StorageServerLockedWithState) WritePerNode(ctx context.Context, state *State) (*WriteResponse, error)

WritePerNode implements the WritePerNode method.

type StorageServerSlow

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

StorageServerSlow represents a storage server that for any of its methods waits a given duration before returning a reply.

func NewStorageSlow

func NewStorageSlow(dur time.Duration) *StorageServerSlow

NewStorageSlow returns a slow storage server.

func NewStorageSlowWithState

func NewStorageSlowWithState(dur time.Duration, state *State) *StorageServerSlow

NewStorageSlowWithState returns a slow storage server with some initial state.

func (*StorageServerSlow) Read

func (s *StorageServerSlow) Read(ctx context.Context, rq *ReadRequest) (*State, error)

Read implements the Read method.

func (*StorageServerSlow) ReadCorrectable

func (s *StorageServerSlow) ReadCorrectable(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCorrectable implements the ReadCorrectable method.

func (*StorageServerSlow) ReadCorrectableStream

func (s *StorageServerSlow) ReadCorrectableStream(rq *ReadRequest, srts Storage_ReadCorrectableStreamServer) error

ReadCorrectableStream implements the ReadCorrectableStream method from the StorageServer interface.

func (*StorageServerSlow) ReadCustomReturn

func (s *StorageServerSlow) ReadCustomReturn(ctx context.Context, rq *ReadRequest) (*State, error)

ReadCustomReturn implements the ReadCustomReturn method.

func (*StorageServerSlow) ReadExecuted

func (s *StorageServerSlow) ReadExecuted()

ReadExecuted returns when r has has completed a read.

func (*StorageServerSlow) ReadFuture

func (s *StorageServerSlow) ReadFuture(ctx context.Context, rq *ReadRequest) (*State, error)

ReadFuture implements the ReadFuture method.

func (*StorageServerSlow) ReadNoQC

func (s *StorageServerSlow) ReadNoQC(ctx context.Context, rq *ReadRequest) (*State, error)

ReadNoQC implements the ReadNoQC method from the StorageServer interface.

func (*StorageServerSlow) Write

func (s *StorageServerSlow) Write(ctx context.Context, state *State) (*WriteResponse, error)

Write implements the Write method.

func (*StorageServerSlow) WriteAsync

func (s *StorageServerSlow) WriteAsync(stream Storage_WriteAsyncServer) error

WriteAsync implements the WriteAsync method from the StorageServer interface.

func (*StorageServerSlow) WriteExecuted

func (s *StorageServerSlow) WriteExecuted()

WriteExecuted returns when r has has completed a write.

func (*StorageServerSlow) WriteFuture

func (s *StorageServerSlow) WriteFuture(ctx context.Context, state *State) (*WriteResponse, error)

WriteFuture implements the WriteFuture method.

func (*StorageServerSlow) WritePerNode

func (s *StorageServerSlow) WritePerNode(ctx context.Context, state *State) (*WriteResponse, error)

WritePerNode implements the WritePerNode method.

type StorageTestServer

type StorageTestServer interface {
	StorageServer
	ReadExecuted()
	WriteExecuted()
}

StorageTestServer is a basic storage server that in addition also can signal when a read or write has completed.

type Storage_ReadCorrectableStreamClient

type Storage_ReadCorrectableStreamClient interface {
	Recv() (*State, error)
	grpc.ClientStream
}

type Storage_ReadCorrectableStreamServer

type Storage_ReadCorrectableStreamServer interface {
	Send(*State) error
	grpc.ServerStream
}

type Storage_WriteAsyncClient

type Storage_WriteAsyncClient interface {
	Send(*State) error
	CloseAndRecv() (*Empty, error)
	grpc.ClientStream
}

type Storage_WriteAsyncServer

type Storage_WriteAsyncServer interface {
	SendAndClose(*Empty) error
	Recv() (*State, error)
	grpc.ServerStream
}

type WriteResponse

type WriteResponse struct {
	New bool `protobuf:"varint,1,opt,name=New,proto3" json:"New,omitempty"`
}

func (*WriteResponse) Descriptor

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

func (*WriteResponse) GetNew

func (m *WriteResponse) GetNew() bool

func (*WriteResponse) Marshal

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

func (*WriteResponse) MarshalTo

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

func (*WriteResponse) ProtoMessage

func (*WriteResponse) ProtoMessage()

func (*WriteResponse) Reset

func (m *WriteResponse) Reset()

func (*WriteResponse) Size

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

func (*WriteResponse) String

func (this *WriteResponse) String() string

func (*WriteResponse) Unmarshal

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

Jump to

Keyboard shortcuts

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