proto

package
v0.0.0-...-e7ce532 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_storage_proto_storage_proto protoreflect.FileDescriptor

Functions

func RegisterStorageServer

func RegisterStorageServer(srv *gorums.Server, impl Storage)

Types

type Configuration

type Configuration struct {
	gorums.RawConfiguration
	// contains filtered or unexported fields
}

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

func ConfigurationFromRaw

func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error)

ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec.

This function may for example be used to "clone" a configuration but install a different QuorumSpec:

cfg1, err := mgr.NewConfiguration(qspec1, opts...)
cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2)

func (Configuration) And

And returns a NodeListOption that can be used to create a new configuration combining c and d.

func (Configuration) Except

Except returns a NodeListOption that can be used to create a new configuration from c without the nodes in rm.

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 Manager.

NOTE: mutating the returned slice is not supported.

func (*Configuration) ReadQC

func (c *Configuration) ReadQC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error)

ReadQC executes the Read Quorum Call on a configuration of Nodes and returns the most recent value.

func (*Configuration) WriteMulticast

func (c *Configuration) WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption)

WriteMulticast is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.

func (*Configuration) WriteQC

func (c *Configuration) WriteQC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error)

WriteQC executes the Write Quorum Call on a configuration of Nodes and returns true if a majority of Nodes were updated.

type Manager

type Manager struct {
	*gorums.RawManager
}

Manager maintains a connection pool of nodes on which quorum calls can be performed.

func NewManager

func NewManager(opts ...gorums.ManagerOption) *Manager

NewManager returns a new Manager for managing connection to nodes added to the manager. This function accepts manager options used to configure various aspects of the manager.

func (*Manager) NewConfiguration

func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error)

NewConfiguration returns a configuration based on the provided list of nodes (required) and an optional quorum specification. The QuorumSpec is necessary for call types that must process replies. For configurations only used for unicast or multicast call types, a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. A new configuration can also be created from an existing configuration, using the And, WithNewNodes, Except, and WithoutNodes methods.

func (*Manager) Nodes

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

Nodes returns a slice of available nodes on this manager. IDs are returned in the order they were added at creation of the manager.

type Node

type Node struct {
	*gorums.RawNode
}

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

func (*Node) ReadRPC

func (n *Node) ReadRPC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error)

ReadRPC executes the Read RPC on a single Node

func (*Node) WriteRPC

func (n *Node) WriteRPC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error)

WriteRPC executes the Write RPC on a single Node

type QuorumSpec

type QuorumSpec interface {
	gorums.ConfigOption

	// ReadQCQF is the quorum function for the ReadQC
	// quorum call method. The in parameter is the request object
	// supplied to the ReadQC 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 '_ *ReadRequest'.
	ReadQCQF(in *ReadRequest, replies map[uint32]*ReadResponse) (*ReadResponse, bool)

	// WriteQCQF is the quorum function for the WriteQC
	// quorum call method. The in parameter is the request object
	// supplied to the WriteQC 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 '_ *WriteRequest'.
	WriteQCQF(in *WriteRequest, replies map[uint32]*WriteResponse) (*WriteResponse, bool)
}

QuorumSpec is the interface of quorum functions for Storage.

type ReadRequest

type ReadRequest struct {
	Key string `protobuf:"bytes,1,opt,name=Key,proto3" json:"Key,omitempty"`
	// contains filtered or unexported fields
}

func (*ReadRequest) Descriptor deprecated

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

Deprecated: Use ReadRequest.ProtoReflect.Descriptor instead.

func (*ReadRequest) GetKey

func (x *ReadRequest) GetKey() string

func (*ReadRequest) ProtoMessage

func (*ReadRequest) ProtoMessage()

func (*ReadRequest) ProtoReflect

func (x *ReadRequest) ProtoReflect() protoreflect.Message

func (*ReadRequest) Reset

func (x *ReadRequest) Reset()

func (*ReadRequest) String

func (x *ReadRequest) String() string

type ReadResponse

type ReadResponse struct {
	OK    bool                   `protobuf:"varint,1,opt,name=OK,proto3" json:"OK,omitempty"`
	Value string                 `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"`
	Time  *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=Time,proto3" json:"Time,omitempty"`
	// contains filtered or unexported fields
}

func (*ReadResponse) Descriptor deprecated

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

Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead.

func (*ReadResponse) GetOK

func (x *ReadResponse) GetOK() bool

func (*ReadResponse) GetTime

func (x *ReadResponse) GetTime() *timestamppb.Timestamp

func (*ReadResponse) GetValue

func (x *ReadResponse) GetValue() string

func (*ReadResponse) ProtoMessage

func (*ReadResponse) ProtoMessage()

func (*ReadResponse) ProtoReflect

func (x *ReadResponse) ProtoReflect() protoreflect.Message

func (*ReadResponse) Reset

func (x *ReadResponse) Reset()

func (*ReadResponse) String

func (x *ReadResponse) String() string

type Storage

type Storage interface {
	ReadRPC(ctx gorums.ServerCtx, request *ReadRequest) (response *ReadResponse, err error)
	WriteRPC(ctx gorums.ServerCtx, request *WriteRequest) (response *WriteResponse, err error)
	ReadQC(ctx gorums.ServerCtx, request *ReadRequest) (response *ReadResponse, err error)
	WriteQC(ctx gorums.ServerCtx, request *WriteRequest) (response *WriteResponse, err error)
	WriteMulticast(ctx gorums.ServerCtx, request *WriteRequest)
}

Storage is the server-side API for the Storage Service

type WriteRequest

type WriteRequest struct {
	Key   string                 `protobuf:"bytes,1,opt,name=Key,proto3" json:"Key,omitempty"`
	Value string                 `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"`
	Time  *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=Time,proto3" json:"Time,omitempty"`
	// contains filtered or unexported fields
}

func (*WriteRequest) Descriptor deprecated

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

Deprecated: Use WriteRequest.ProtoReflect.Descriptor instead.

func (*WriteRequest) GetKey

func (x *WriteRequest) GetKey() string

func (*WriteRequest) GetTime

func (x *WriteRequest) GetTime() *timestamppb.Timestamp

func (*WriteRequest) GetValue

func (x *WriteRequest) GetValue() string

func (*WriteRequest) ProtoMessage

func (*WriteRequest) ProtoMessage()

func (*WriteRequest) ProtoReflect

func (x *WriteRequest) ProtoReflect() protoreflect.Message

func (*WriteRequest) Reset

func (x *WriteRequest) Reset()

func (*WriteRequest) String

func (x *WriteRequest) String() string

type WriteResponse

type WriteResponse struct {
	New bool `protobuf:"varint,1,opt,name=New,proto3" json:"New,omitempty"`
	// contains filtered or unexported fields
}

func (*WriteResponse) Descriptor deprecated

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

Deprecated: Use WriteResponse.ProtoReflect.Descriptor instead.

func (*WriteResponse) GetNew

func (x *WriteResponse) GetNew() bool

func (*WriteResponse) ProtoMessage

func (*WriteResponse) ProtoMessage()

func (*WriteResponse) ProtoReflect

func (x *WriteResponse) ProtoReflect() protoreflect.Message

func (*WriteResponse) Reset

func (x *WriteResponse) Reset()

func (*WriteResponse) String

func (x *WriteResponse) String() string

Jump to

Keyboard shortcuts

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