Documentation
¶
Overview ¶
Package byzq is a generated protocol buffer package.
It is generated from these files:
byzq.proto
It has these top-level messages:
Key Content Value WriteResponse
Index ¶
- Constants
- Variables
- func Equal(a, b *Configuration) bool
- func GenerateKeyfile(keyFile string) error
- func ManagerCreationError(err error) error
- func ParseKey(pemKey string) (*ecdsa.PrivateKey, error)
- func ReadKeyfile(keyFile string) (*ecdsa.PrivateKey, error)
- func RegisterStorageServer(s *grpc.Server, srv StorageServer)
- type AuthDataQ
- func (aq *AuthDataQ) ConcurrentVerifyIndexChanReadQF(replies []*Value) (*Content, bool)
- func (aq *AuthDataQ) ConcurrentVerifyWGReadQF(replies []*Value) (*Content, bool)
- func (aq *AuthDataQ) ReadQF(replies []*Value) (*Content, bool)
- func (aq *AuthDataQ) SequentialVerifyReadQF(replies []*Value) (*Content, bool)
- func (aq *AuthDataQ) Sign(content *Content) (*Value, error)
- func (aq *AuthDataQ) VerfiyLastReplyFirstReadQF(replies []*Value) (*Content, bool)
- func (aq *AuthDataQ) WriteQF(req *Value, replies []*WriteResponse) (reply *WriteResponse, quorum bool)
- type ConfigNotFoundError
- type Configuration
- func (c *Configuration) ID() uint32
- func (c *Configuration) NodeIDs() []uint32
- func (c *Configuration) Nodes() []*Node
- func (c *Configuration) Read(ctx context.Context, arg *Key) (*Content, error)
- func (c *Configuration) Size() int
- func (c *Configuration) String() string
- func (c *Configuration) Write(ctx context.Context, arg *Value) (*WriteResponse, error)
- type Content
- func (*Content) Descriptor() ([]byte, []int)
- func (this *Content) Equal(that interface{}) bool
- func (m *Content) GetKey() string
- func (m *Content) GetTimestamp() int64
- func (m *Content) GetValue() string
- func (m *Content) Marshal() (dAtA []byte, err error)
- func (m *Content) MarshalTo(dAtA []byte) (int, error)
- func (*Content) ProtoMessage()
- func (m *Content) Reset()
- func (m *Content) Size() (n int)
- func (this *Content) String() string
- func (m *Content) Unmarshal(dAtA []byte) error
- type IllegalConfigError
- type Key
- func (*Key) Descriptor() ([]byte, []int)
- func (this *Key) Equal(that interface{}) bool
- func (m *Key) GetKey() string
- func (m *Key) Marshal() (dAtA []byte, err error)
- func (m *Key) MarshalTo(dAtA []byte) (int, error)
- func (*Key) ProtoMessage()
- func (m *Key) Reset()
- func (m *Key) Size() (n int)
- func (this *Key) String() string
- func (m *Key) Unmarshal(dAtA []byte) error
- 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
- type MultiSorter
- type Node
- type NodeNotFoundError
- type QuorumCallError
- type QuorumSpec
- type StorageClient
- type StorageServer
- type Value
- func (*Value) Descriptor() ([]byte, []int)
- func (this *Value) Equal(that interface{}) bool
- func (m *Value) GetC() *Content
- func (m *Value) GetSignatureR() []byte
- func (m *Value) GetSignatureS() []byte
- func (m *Value) Marshal() (dAtA []byte, err error)
- func (m *Value) MarshalTo(dAtA []byte) (int, error)
- func (*Value) ProtoMessage()
- func (m *Value) Reset()
- func (m *Value) Size() (n int)
- func (this *Value) String() string
- func (m *Value) Unmarshal(dAtA []byte) error
- type WriteResponse
- func (*WriteResponse) Descriptor() ([]byte, []int)
- func (this *WriteResponse) Equal(that interface{}) bool
- func (m *WriteResponse) GetTimestamp() int64
- func (m *WriteResponse) Marshal() (dAtA []byte, err error)
- func (m *WriteResponse) MarshalTo(dAtA []byte) (int, error)
- func (*WriteResponse) ProtoMessage()
- func (m *WriteResponse) Reset()
- func (m *WriteResponse) Size() (n int)
- func (this *WriteResponse) String() string
- func (m *WriteResponse) Unmarshal(dAtA []byte) error
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 ( ErrInvalidLengthByzq = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowByzq = fmt.Errorf("proto: integer overflow") )
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 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.
Functions ¶
func Equal ¶
func Equal(a, b *Configuration) bool
Equal returns a boolean reporting whether a and b represents the same configuration.
func GenerateKeyfile ¶
GenerateKeyfile generates a private key and writes it to the given keyFile. Note that if the file exists it will be overwritten.
func ManagerCreationError ¶
ManagerCreationError returns an error reporting that a Manager could not be created due to err.
func ParseKey ¶
func ParseKey(pemKey string) (*ecdsa.PrivateKey, error)
ParseKey takes a PEM formatted string and returns a private key.
func ReadKeyfile ¶
func ReadKeyfile(keyFile string) (*ecdsa.PrivateKey, error)
ReadKeyfile reads the provided keyFile and returns the private key stored in the file.
func RegisterStorageServer ¶
func RegisterStorageServer(s *grpc.Server, srv StorageServer)
Types ¶
type AuthDataQ ¶
type AuthDataQ struct {
// contains filtered or unexported fields
}
AuthDataQ is the quorum specification for the Authenticated-Data Byzantine Quorum algorithm described in RSDP, Algorithm 4.15, page 181.
func NewAuthDataQ ¶
NewAuthDataQ returns a quorum specification or nil and an error if the quorum requirements are not satisfied. Pre-condition: n>3f and f>0 Post-condition:
func (*AuthDataQ) ConcurrentVerifyIndexChanReadQF ¶
ConcurrentVerifyIndexChanReadQF returns nil and false until the supplied replies constitute a Byzantine quorum, at which point the method returns the single highest value and true.
func (*AuthDataQ) ConcurrentVerifyWGReadQF ¶
ConcurrentVerifyWGReadQF returns nil and false until the supplied replies constitute a Byzantine quorum, at which point the method returns the single highest value and true.
func (*AuthDataQ) ReadQF ¶
ReadQF returns nil and false until the supplied replies constitute a Byzantine quorum, at which point the method returns the single highest value and true.
func (*AuthDataQ) SequentialVerifyReadQF ¶
SequentialVerifyReadQF returns nil and false until the supplied replies constitute a Byzantine quorum, at which point the method returns the single highest value and true.
func (*AuthDataQ) Sign ¶
Sign signs the provided content and returns a value to be passed into Write. (This function must currently be exported since our writer client code is not in the byzq package.)
func (*AuthDataQ) VerfiyLastReplyFirstReadQF ¶
VerfiyLastReplyFirstReadQF returns nil and false until the supplied replies constitute a Byzantine quorum, at which point the method returns the single highest value and true.
func (*AuthDataQ) WriteQF ¶
func (aq *AuthDataQ) WriteQF(req *Value, replies []*WriteResponse) (reply *WriteResponse, quorum bool)
WriteQF returns nil and false until it is possible to check for a quorum. If enough replies with the same timestamp is found, we return true.
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 ¶
Read is invoked as a quorum call on all nodes in configuration c, using the same argument arg, and returns the result.
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) Write ¶
func (c *Configuration) Write(ctx context.Context, arg *Value) (*WriteResponse, error)
Write is invoked as a quorum call on all nodes in configuration c, using the same argument arg, and returns the result.
type Content ¶
type Content struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` }
func (*Content) Descriptor ¶
func (*Content) GetTimestamp ¶
func (*Content) ProtoMessage ¶
func (*Content) ProtoMessage()
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 Key ¶
type Key struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}
[Read, requestID]
func (*Key) Descriptor ¶
func (*Key) ProtoMessage ¶
func (*Key) ProtoMessage()
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 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) 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 { StorageClient StorageClient // contains filtered or unexported fields }
Node encapsulates the state of a node on which a remote procedure call can be made.
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 QuorumSpec ¶
type QuorumSpec interface { // ReadQF is the quorum function for the Read // quorum call method. ReadQF(replies []*Value) (*Content, bool) // WriteQF is the quorum function for the Write // quorum call method. WriteQF(req *Value, replies []*WriteResponse) (*WriteResponse, bool) }
QuorumSpec is the interface that wraps every quorum function.
type StorageClient ¶
type StorageClient interface { Read(ctx context.Context, in *Key, opts ...grpc.CallOption) (*Value, error) Write(ctx context.Context, in *Value, opts ...grpc.CallOption) (*WriteResponse, error) }
func NewStorageClient ¶
func NewStorageClient(cc *grpc.ClientConn) StorageClient
type StorageServer ¶
type Value ¶
type Value struct { C *Content `protobuf:"bytes,1,opt,name=c" json:"c,omitempty"` SignatureR []byte `protobuf:"bytes,2,opt,name=signatureR,proto3" json:"signatureR,omitempty"` SignatureS []byte `protobuf:"bytes,3,opt,name=signatureS,proto3" json:"signatureS,omitempty"` }
[Value, requestID, ts, val, signature] [Write, wts, val, signature]
func (*Value) Descriptor ¶
func (*Value) GetSignatureR ¶
func (*Value) GetSignatureS ¶
func (*Value) ProtoMessage ¶
func (*Value) ProtoMessage()
type WriteResponse ¶
type WriteResponse struct {
Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
}
[Ack, ts]
func (*WriteResponse) Descriptor ¶
func (*WriteResponse) Descriptor() ([]byte, []int)
func (*WriteResponse) Equal ¶
func (this *WriteResponse) Equal(that interface{}) bool
func (*WriteResponse) GetTimestamp ¶
func (m *WriteResponse) GetTimestamp() int64
func (*WriteResponse) Marshal ¶
func (m *WriteResponse) Marshal() (dAtA []byte, err 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