trtl

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespacePeers    = "peers"
	NamespaceIndex    = "index"
	NamespaceDefault  = "default"
	NamespaceSequence = "sequence"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextKey

type ContextKey string

type MetricsService

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

A MetricsService manages Prometheus metrics

func NewMetricsService

func NewMetricsService() (*MetricsService, error)

func (*MetricsService) Serve

func (m *MetricsService) Serve(addr string) error

Serve serves the Prometheus metrics

func (*MetricsService) Shutdown

func (m *MetricsService) Shutdown() error

Gracefully shutdown the Prometheus metrics service

type PeerInfo

type PeerInfo struct {
	Name        *pkix.Name
	DNSNames    []string
	IPAddresses []net.IP
}

PeerInfo stores information about the identity of a remote peer.

type PeerService

type PeerService struct {
	peers.UnimplementedPeerManagementServer
	// contains filtered or unexported fields
}

A PeerService implements the RPCs for managing remote peers.

func NewPeerService

func NewPeerService(s *Server) (*PeerService, error)

func (*PeerService) AddPeers

func (p *PeerService) AddPeers(ctx context.Context, in *peers.Peer) (out *peers.PeersStatus, err error)

AddPeers adds a peer and returns a report of the status of all peers in the network.

func (*PeerService) GetPeers

func (p *PeerService) GetPeers(ctx context.Context, in *peers.PeersFilter) (out *peers.PeersList, err error)

GetPeers queries the data store to determine which peers it contains, and returns them

func (*PeerService) RmPeers

func (p *PeerService) RmPeers(ctx context.Context, in *peers.Peer) (out *peers.PeersStatus, err error)

type ReplicaService

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

A ReplicaService manages anti-entropy replication between peers.

func NewReplicaService

func NewReplicaService(s *Server) (*ReplicaService, error)

func (*ReplicaService) AntiEntropy

func (*ReplicaService) AntiEntropy()

AntiEntropy is a service that periodically selects a remote peer to synchronize with via bilateral anti-entropy using the Gossip service. Jitter is applied to the interval between anti-entropy synchronizations to ensure that message traffic isn't bursty to disrupt normal messages to the GDS service. TODO: this background routine is currently untested.

func (*ReplicaService) Gossip

func (r *ReplicaService) Gossip(ctx context.Context, in *replica.VersionVectors) (out *replica.Updates, err error)

During gossip, the initiating replica sends a randomly selected remote peer the version vectors of all objects it currently stores. The remote peer should respond with updates that correspond to more recent versions of the objects. The remote peer can than also make a reciprocal request for updates by sending the set of versions requested that were more recent on the initiating replica, and use a partial flag to indicate that it is requesting specific versions. This mechanism implements bilateral anti-entropy: a push and pull gossip.

func (*ReplicaService) SelectPeer

func (r *ReplicaService) SelectPeer() (peer *peers.Peer)

SelectPeer randomly that is not self to perform anti-entropy with. If a peer cannot be selected, then nil is returned.

type Server

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

A Trtl server implements the following services 1. A database service for interacting with a database 2. A peers management service for interacting with remote peers 3. A replication service which implements auto-adapting anti-entropy replication.

func New

func New(conf config.Config) (s *Server, err error)

New creates a new trtl server given a configuration.

func (*Server) GetDB

func (t *Server) GetDB() *honu.DB

GetDB returns the underlying Honu database used by all sub-services.

func (*Server) Run

func (t *Server) Run(sock net.Listener)

Run the gRPC server. This method is extracted from the Serve function so that it can be run in its own go routine and to allow tests to Run a bufconn server without starting a live server with all of the various go routines and channels running.

func (*Server) Serve

func (t *Server) Serve() (err error)

Serve gRPC requests on the specified bind address.

func (*Server) Shutdown

func (t *Server) Shutdown() (err error)

Shutdown the trtl server gracefully.

type TrtlService

type TrtlService struct {
	pb.UnimplementedTrtlServer
	// contains filtered or unexported fields
}

A TrtlService implements the RPCs for interacting with a Honu database.

func NewTrtlService

func NewTrtlService(s *Server) (*TrtlService, error)

func (*TrtlService) Batch

func (h *TrtlService) Batch(stream pb.Trtl_BatchServer) error

Batch is a client-side streaming request to issue multiple commands, usually Put and Delete.

func (*TrtlService) Cursor

func (h *TrtlService) Cursor(in *pb.CursorRequest, stream pb.Trtl_CursorServer) (err error)

Cursor is a server-side streaming request to fetch a collection of key/value pairs based on a shared prefix. If no prefix is specified an entire namespace may be returned. The pairs are streamed one value at a time so that the client can control iteration and materialization without overloading either the server or the network.

Note that there is a snapshot guarantee during iteration, meaning that if the underlying database changes via a concurrent request, the cursor stream will not be effected. Use Cursor instead of Iter if you require snapshot isolation reads.

There are several options that modulate the Cursor stream:

  • return_meta: each key/value pair will contain the object metadata
  • iter_no_keys: each key/value pair will not have a key associated with it
  • iter_no_values: each key/value pair will not have a value associated with it
  • page_token: the page of results that the user wishes to fetch
  • page_size: the number of results to be returned in the request

func (*TrtlService) Delete

func (h *TrtlService) Delete(ctx context.Context, in *pb.DeleteRequest) (out *pb.DeleteReply, err error)

Delete is a unary request to delete a key. If a namespace is provided, the namespace is passed to the internal honu Options, to delete the key from a specific namespace. Note that this does not delete tombstones.

func (*TrtlService) Get

func (h *TrtlService) Get(ctx context.Context, in *pb.GetRequest) (*pb.GetReply, error)

Get is a unary request to retrieve a value for a key. If metadata is requested in the GetRequest, the request will use honu.Object() to retrieve the entire object, including the metadata. If no metadata is requested, the request will use honu.Get() to get only the value. If a namespace is provided, the namespace is passed to the internal honu Options, to look in that namespace only.

func (*TrtlService) Iter

func (h *TrtlService) Iter(ctx context.Context, in *pb.IterRequest) (out *pb.IterReply, err error)

Iter is a unary request to fetch a materialized collection of key/value pairs based on a shared prefix. If no prefix is specified an entire namespace may be returned. This RPC supports pagination to ensure that replies do not get too large. The default page size is 100 items, though this can be modified in the options. The next page token in the result will contain the next page to request, or will be empty if there are no more results to be supplied.

Note that there are no snapshot guarantees during iteration, meaning that if the underlying database changes between requests, these changes could be reflected during iteration. For snapshot isolation in iteration, use the Cursor RPC.

There are several options that modulate the Iter response:

  • return_meta: each key/value pair will contain the object metadata
  • iter_no_keys: each key/value pair will not have a key associated with it
  • iter_no_values: each key/value pair will not have a value associated with it
  • page_token: the page of results that the user wishes to fetch
  • page_size: the number of results to be returned in the request

func (*TrtlService) Put

func (h *TrtlService) Put(ctx context.Context, in *pb.PutRequest) (out *pb.PutReply, err error)

Put is a unary request to store a value for a key. If a namespace is provided, the namespace is passed to the internal honu Options, to put the value to that namespace.

func (*TrtlService) Sync

func (h *TrtlService) Sync(stream pb.Trtl_SyncServer) (err error)

Directories

Path Synopsis
Package jitter provides a stochastic ticker that returns ticks at a random interval specified by a normal distribution with a mean periodicity and a standard deviation, sigma both of which are time.Durations.
Package jitter provides a stochastic ticker that returns ticks at a random interval specified by a normal distribution with a mean periodicity and a standard deviation, sigma both of which are time.Durations.
pb
v1
peers
v1

Jump to

Keyboard shortcuts

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