trtl

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespacePeers         = wire.NamespaceReplicas
	NamespaceIndex         = wire.NamespaceIndices
	NamespaceDefault       = "default"
	NamespaceUnknown       = "unknown"
	NamespaceSequence      = wire.NamespaceSequence
	NamespaceVASPs         = wire.NamespaceVASPs
	NamespaceCertReqs      = wire.NamespaceCertReqs
	NamespaceCerts         = wire.NamespaceCerts
	NamespaceContacts      = wire.NamespaceContacts
	NamespaceAnnouncements = wire.NamespaceAnnouncements
	NamespaceOrganizations = wire.NamespaceOrganizations
)

TODO: need functionality to actually extract namespaces from db

Variables

This section is empty.

Functions

func SeekCursor added in v1.3.1

func SeekCursor(pageSize int32, nextKey []byte, namespace string) (string, error)

SeekCursor returns a next page token that will cause the iter method to start pagination at the specified key. This is a hack to support the Seek() method in the trtl store iterator interface. In the future, the Iter method should be able to seek via an RPC.

Types

type BackupManager added in v1.3.1

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

BackupManager runs as an independent service which periodically copies the trtl storage to a compressed backup location on disk. The backup manager is started when the trtl service is started, but if it is not able to run it will force the database to exit before continuing.

TODO: allow storage to cloud storage rather than to disk TODO: encrypt the backup storage file

func NewBackupManager added in v1.3.1

func NewBackupManager(conf config.BackupConfig, db *honu.DB) (*BackupManager, error)

func (*BackupManager) Run added in v1.3.1

func (m *BackupManager) Run()

Runs the main BackupManager routine which periodically wakes up and creates a backup of the trtl database.

func (*BackupManager) Shutdown added in v1.3.1

func (m *BackupManager) Shutdown() error

type Monitor added in v1.7.0

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

Monitor is an independent service which periodically scans the trtl storage and determines how many objects, tombstones, size, etc. is utilized by the internal db.

func NewMonitor added in v1.7.0

func NewMonitor(conf config.MetricsConfig, db *honu.DB) (*Monitor, error)

func (*Monitor) Measure added in v1.7.0

func (m *Monitor) Measure() (err error)

func (*Monitor) MeasureNamespace added in v1.7.0

func (m *Monitor) MeasureNamespace(namespace string) error

func (*Monitor) Run added in v1.7.0

func (m *Monitor) Run()

Run the monitor which periodically wakes up and measures the metrics in the database.

func (*Monitor) Shutdown added in v1.7.0

func (m *Monitor) Shutdown() error

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

func (*Server) StreamInterceptors added in v1.7.0

func (t *Server) StreamInterceptors() []grpc.StreamServerInterceptor

Prepares the interceptors (middleware) for the stream RPC endpoints of the server. The first interceptor will be the outer-most handler and the last will be the inner-most wrapper around the final handler. All stream interceptors returned by this method should be chained using grpc.ChainStreamInterceptor().

func (*Server) UnaryInterceptors added in v1.7.0

func (t *Server) UnaryInterceptors() []grpc.UnaryServerInterceptor

Prepares the interceptors (middleware) for the unary RPC endpoints of the server. The first interceptor will be the outer-most handler and the last will be the inner-most wrapper around the final handler. All unary interceptors returned by this method should be chained using grpc.ChainUnaryInterceptor().

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. TODO: should we track individual Put and Delete commands? TODO: this method is not fully implemented yet.

func (*TrtlService) Count added in v1.7.4

func (h *TrtlService) Count(ctx context.Context, in *pb.CountRequest) (out *pb.CountReply, err error)

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) (out *pb.GetReply, err 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) Status added in v1.3.1

func (h *TrtlService) Status(ctx context.Context, in *pb.HealthCheck) (out *pb.ServerStatus, err error)

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
Package replica implements bilateral anti-entropy replication for the trtl database.
Package replica implements bilateral anti-entropy replication for the trtl database.

Jump to

Keyboard shortcuts

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