Documentation ¶
Overview ¶
Package replica extends Ringpop functionality by providing a mechanism to replicate a request to multiple nodes in the ring.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FanoutMode ¶
type FanoutMode int
FanoutMode defines how a replicator should fanout it's requests
const ( // Parallel fanout mode for replicator read write requests. Sends out requests // in parallel. Parallel FanoutMode = iota // SerialSequential fanout mode for replicator read write requests. Sends out // requests one at a time going through the preference list sequentially SerialSequential // SerialBalanced fanout mode for replicator read write requests. Sends out // requests one at a time, going through the preference list in a random order SerialBalanced )
type Options ¶
type Options struct {
NValue, RValue, WValue int
FanoutMode FanoutMode
}
Options for sending a read/write replicator request
type Replicator ¶
type Replicator struct {
// contains filtered or unexported fields
}
A Replicator is used to replicate a request across nodes such that they share ownership of some data.
func NewReplicator ¶
func NewReplicator(s Sender, channel shared.SubChannel, logger log.Logger, opts *Options) *Replicator
NewReplicator returns a new Replicator instance that makes calls with the given SubChannel to the service defined by SubChannel.GetServiceName(). The given n/w/r values will be used as defaults for the replicator when none are provided Deprecation: logger is no longer used.
func (*Replicator) Read ¶
func (r *Replicator) Read(keys []string, request []byte, operation string, fopts *forward.Options, opts *Options) (responses []Response, err error)
Read replicates a read request. It takes key(s) to be used for lookup of the requests destination, a request to send, the operation to perform at the destination, options for forwarding the request as well as options for ffanning out the request. It also takes a response type, which is the type of struct that will be returned in each responses.Body in response. Response type must be a concrete struct. The body field will contain a pointer to that type of struct.
func (*Replicator) Write ¶
func (r *Replicator) Write(keys []string, request []byte, operation string, fopts *forward.Options, opts *Options) (responses []Response, err error)
Write replicates a write request. It takes key(s) to be used for lookup of the requests destination, a request to send, the operation to perform at the destination, options for forwarding the request as well as options for ffanning out the request. It also takes a response type, which is the type of struct that will be returned in each responses.Body in response. Response type must be a concrete struct. The body field will contain a pointer to that type of struct.
type Sender ¶
type Sender interface { // Lookup should return a server address Lookup(string) (string, error) // LookupN should return n server addresses LookupN(string, int) ([]string, error) // WhoAmI should return the local address of the sender WhoAmI() (string, error) }
A Sender is used to lookup the destinations for requests given a key.