Documentation
¶
Index ¶
- Constants
- Variables
- func Equal(a, b *Configuration) bool
- func ManagerCreationError(err error) error
- func RegisterQuorumFunctionServer(s *grpc.Server, srv QuorumFunctionServer)
- type ConfigNotFoundError
- type Configuration
- func (c *Configuration) ID() uint32
- func (c *Configuration) IgnoreReq(ctx context.Context, in *Request, opts ...grpc.CallOption) (resp *Response, err error)
- func (c *Configuration) NodeIDs() []uint32
- func (c *Configuration) Nodes() []*Node
- func (c *Configuration) Size() int
- func (c *Configuration) String() string
- func (c *Configuration) SubError() <-chan GRPCError
- func (c *Configuration) UseReq(ctx context.Context, in *Request, opts ...grpc.CallOption) (resp *Response, err error)
- type GRPCError
- type GorumsServer
- type IllegalConfigError
- type Manager
- func (m *Manager) AddNode(addr string) error
- func (m *Manager) Close()
- func (m *Manager) Configuration(id uint32) (config *Configuration, found bool)
- func (m *Manager) ConfigurationIDs() []uint32
- func (m *Manager) Configurations() []*Configuration
- func (m *Manager) NewConfiguration(ids []uint32, qspec QuorumSpec) (*Configuration, error)
- func (m *Manager) Node(id uint32) (node *Node, found bool)
- func (m *Manager) NodeIDs() []uint32
- func (m *Manager) Nodes() []*Node
- func (m *Manager) Size() (nodes, configs int)
- type ManagerOption
- func WithBackoff(backoff backoff.Config) ManagerOption
- func WithDialTimeout(timeout time.Duration) ManagerOption
- func WithGrpcDialOptions(opts ...grpc.DialOption) ManagerOption
- func WithLogger(logger *log.Logger) ManagerOption
- func WithNoConnect() ManagerOption
- func WithSendBufferSize(size uint) ManagerOption
- func WithTracing() ManagerOption
- type MultiSorter
- type Node
- func (n *Node) Address() string
- func (n *Node) FullString() string
- func (n *Node) ID() uint32
- func (n *Node) IgnoreReq(ctx context.Context, in *Request, replyChan chan<- internalResponse)
- func (n *Node) LastErr() error
- func (n *Node) Latency() time.Duration
- func (n *Node) Port() string
- func (n *Node) String() string
- func (n *Node) UseReq(ctx context.Context, in *Request, replyChan chan<- internalResponse)
- type NodeNotFoundError
- type QuorumCallError
- type QuorumFunction
- type QuorumFunctionClient
- type QuorumFunctionServer
- type QuorumSpec
- type Request
- type Response
- type ServerOption
- type UnimplementedQuorumFunctionServer
Constants ¶
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 ¶
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.
var File_qf_qf_proto protoreflect.FileDescriptor
var ID = func(n1, n2 *Node) bool {
return n1.id < n2.id
}
ID sorts nodes by their identifier in increasing order.
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.
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 ¶
ManagerCreationError returns an error reporting that a Manager could not be created due to err.
func RegisterQuorumFunctionServer ¶
func RegisterQuorumFunctionServer(s *grpc.Server, srv QuorumFunctionServer)
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 NewConfig ¶
func NewConfig(addrs []string, qspec QuorumSpec, opts ...ManagerOption) (*Configuration, func(), error)
NewConfig returns a configuration for the given node addresses and quorum spec. The returned func() must be called to close the underlying connections. This is experimental API.
func (*Configuration) ID ¶
func (c *Configuration) ID() uint32
ID reports the identifier for the configuration.
func (*Configuration) IgnoreReq ¶
func (c *Configuration) IgnoreReq(ctx context.Context, in *Request, opts ...grpc.CallOption) (resp *Response, err error)
IgnoreReq is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.
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) 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) UseReq ¶
func (c *Configuration) UseReq(ctx context.Context, in *Request, opts ...grpc.CallOption) (resp *Response, err error)
UseReq is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.
type GorumsServer ¶
type GorumsServer struct {
// contains filtered or unexported fields
}
GorumsServer serves all ordering based RPCs using registered handlers.
func NewGorumsServer ¶
func NewGorumsServer(opts ...ServerOption) *GorumsServer
NewGorumsServer returns a new instance of GorumsServer.
func (*GorumsServer) GracefulStop ¶
func (s *GorumsServer) GracefulStop()
GracefulStop waits for all RPCs to finish before stopping.
func (*GorumsServer) RegisterQuorumFunctionServer ¶
func (s *GorumsServer) RegisterQuorumFunctionServer(srv QuorumFunction)
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 ¶
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 ¶
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) NodeIDs ¶
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.
type ManagerOption ¶
type ManagerOption func(*managerOptions)
ManagerOption provides a way to set different options on a new Manager.
func WithBackoff ¶
func WithBackoff(backoff backoff.Config) ManagerOption
WithBackoff allows for changing the backoff delays used by Gorums.
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 WithSendBufferSize ¶
func WithSendBufferSize(size uint) ManagerOption
WithSendBufferSize allows for changing the size of the send buffer used by Gorums. A larger buffer might achieve higher throughput for asynchronous calltypes, but at the cost of latency.
func WithTracing ¶
func WithTracing() ManagerOption
WithTracing controls whether to trace quorum 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) 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.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node encapsulates the state of a node on which a remote procedure call can be performed.
func (*Node) FullString ¶
FullString returns a more descriptive string representation of n that includes id, network address and latency information.
func (*Node) LastErr ¶
LastErr returns the last error encountered (if any) when invoking a remote procedure call on this node.
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 ¶
A QuorumCallError is used to report that a quorum call failed.
func (QuorumCallError) Error ¶
func (e QuorumCallError) Error() string
type QuorumFunction ¶
type QuorumFunction interface { }
QuorumFunction is the server-side API for the QuorumFunction Service
type QuorumFunctionClient ¶
type QuorumFunctionClient interface { UseReq(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) IgnoreReq(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) }
QuorumFunctionClient is the client API for QuorumFunction service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewQuorumFunctionClient ¶
func NewQuorumFunctionClient(cc grpc.ClientConnInterface) QuorumFunctionClient
type QuorumFunctionServer ¶
type QuorumFunctionServer interface { UseReq(context.Context, *Request) (*Response, error) IgnoreReq(context.Context, *Request) (*Response, error) // contains filtered or unexported methods }
QuorumFunctionServer is the server API for QuorumFunction service. All implementations must embed UnimplementedQuorumFunctionServer for forward compatibility
type QuorumSpec ¶
type QuorumSpec interface { // UseReqQF is the quorum function for the UseReq // quorum call method. The in parameter is the request object // supplied to the UseReq method at call time, and may or may not // be used by the quorum function. If the in parameter is not needed // you should implement your quorum function with '_ *Request'. UseReqQF(in *Request, replies []*Response) (*Response, bool) // IgnoreReqQF is the quorum function for the IgnoreReq // quorum call method. The in parameter is the request object // supplied to the IgnoreReq method at call time, and may or may not // be used by the quorum function. If the in parameter is not needed // you should implement your quorum function with '_ *Request'. IgnoreReqQF(in *Request, replies []*Response) (*Response, bool) }
QuorumSpec is the interface of quorum functions for QuorumFunction.
type Request ¶
type Request struct { Value int64 `protobuf:"varint,1,opt,name=Value,proto3" json:"Value,omitempty"` // contains filtered or unexported fields }
func (*Request) Descriptor
deprecated
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
func (*Request) ProtoReflect ¶
func (x *Request) ProtoReflect() protoreflect.Message
type Response ¶
type Response struct { Result int64 `protobuf:"varint,1,opt,name=Result,proto3" json:"Result,omitempty"` // contains filtered or unexported fields }
func (*Response) Descriptor
deprecated
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type ServerOption ¶
type ServerOption func(*serverOptions)
ServerOption is used to change settings for the GorumsServer
func WithGRPCServerOptions ¶
func WithGRPCServerOptions(opts ...grpc.ServerOption) ServerOption
func WithServerBufferSize ¶
func WithServerBufferSize(size uint) ServerOption
WithServerBufferSize sets the buffer size for the server. A larger buffer may result in higher throughput at the cost of higher latency.
type UnimplementedQuorumFunctionServer ¶
type UnimplementedQuorumFunctionServer struct { }
UnimplementedQuorumFunctionServer must be embedded to have forward compatible implementations.