praefect

package
v1.86.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 45 Imported by: 0

Documentation

Overview

Package praefect is a Gitaly reverse proxy for transparently routing gRPC calls to a set of Gitaly services.

Index

Constants

This section is empty.

Variables

View Source
var ErrPrimaryNotHealthy = errors.New("primary is not healthy")

ErrPrimaryNotHealthy indicates the primary of a shard is not in a healthy state and hence should not be used for a new request

Functions

func GetBuildTime added in v1.53.0

func GetBuildTime() string

GetBuildTime returns the time at which the build took place

func GetVersion added in v1.53.0

func GetVersion() string

GetVersion returns the semver compatible version number

func GetVersionString added in v1.53.0

func GetVersionString() string

GetVersionString returns a standard version header

func WithLatencyMetric added in v1.79.0

func WithLatencyMetric(h metrics.Histogram) func(*ReplMgr)

WithLatencyMetric is an option to set the queue size prometheus metric

func WithQueueMetric added in v1.79.0

func WithQueueMetric(g metrics.Gauge) func(*ReplMgr)

WithQueueMetric is an option to set the queue size prometheus metric

Types

type Coordinator

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

Coordinator takes care of directing client requests to the appropriate downstream server. The coordinator is thread safe; concurrent calls to register nodes are safe.

func NewCoordinator added in v1.34.0

func NewCoordinator(l *logrus.Entry, ds datastore.Datastore, clientConnections *conn.ClientConnections, conf config.Config, fileDescriptors ...*descriptor.FileDescriptorProto) *Coordinator

NewCoordinator returns a new Coordinator that utilizes the provided logger

func (*Coordinator) FailoverRotation added in v1.56.0

func (c *Coordinator) FailoverRotation()

FailoverRotation waits for the SIGUSR1 signal, then promotes the next secondary to be primary

func (*Coordinator) RegisterProtos added in v1.35.1

func (c *Coordinator) RegisterProtos(protos ...*descriptor.FileDescriptorProto) error

RegisterProtos allows coordinator to register new protos on the fly

type Node added in v1.34.0

type Node interface {
	GetStorage() string
	GetAddress() string
	GetToken() string
	GetConnection() *grpc.ClientConn
}

Node represents some metadata of a node as well as a connection

type NodeManager added in v1.86.0

type NodeManager interface {
	GetShard(virtualStorageName string) (Shard, error)
}

NodeManager is responsible for returning shards for virtual storages

type NodeMgr added in v1.86.0

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

NodeMgr is a concrete type that adheres to the NodeManager interface

func NewNodeManager added in v1.86.0

func NewNodeManager(log *logrus.Entry, virtualStorages []config.VirtualStorage) (*NodeMgr, error)

NewNodeManager creates a new NodeMgr based on virtual storage configs

func (*NodeMgr) GetShard added in v1.86.0

func (n *NodeMgr) GetShard(virtualStorageName string) (Shard, error)

GetShard retrieves a shard for a virtual storage name

func (*NodeMgr) Start added in v1.86.0

func (n *NodeMgr) Start(bootstrapInterval, monitorInterval time.Duration)

Start will bootstrap the node manager by calling healthcheck on the nodes as well as kicking off the monitoring process. Start must be called before NodeMgr can be used.

type ReplMgr added in v1.34.0

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

ReplMgr is a replication manager for handling replication jobs

func NewReplMgr added in v1.34.0

func NewReplMgr(targetNode string, log *logrus.Entry, datastore datastore.Datastore, c *conn.ClientConnections, opts ...ReplMgrOpt) ReplMgr

NewReplMgr initializes a replication manager with the provided dependencies and options

func (ReplMgr) ProcessBacklog added in v1.34.0

func (r ReplMgr) ProcessBacklog(ctx context.Context) error

ProcessBacklog will process queued jobs. It will block while processing jobs.

type ReplMgrOpt added in v1.34.0

type ReplMgrOpt func(*ReplMgr)

ReplMgrOpt allows a replicator to be configured with additional options

func WithReplicator added in v1.34.0

func WithReplicator(r Replicator) ReplMgrOpt

WithReplicator overrides the default replicator

func WithWhitelist added in v1.34.0

func WithWhitelist(whitelistedRepos []string) ReplMgrOpt

WithWhitelist will configure a whitelist for repos to allow replication

type Replicator added in v1.34.0

type Replicator interface {
	// Replicate propagates changes from the source to the target
	Replicate(ctx context.Context, job datastore.ReplJob, source, target *grpc.ClientConn) error
	// Destroy will remove the target repo on the specified target connection
	Destroy(ctx context.Context, job datastore.ReplJob, target *grpc.ClientConn) error
}

Replicator performs the actual replication logic between two nodes

type Server

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

Server is a praefect server

func NewServer

func NewServer(c *Coordinator, repl ReplMgr, grpcOpts []grpc.ServerOption, l *logrus.Entry, clientConnections *conn.ClientConnections, conf config.Config) *Server

NewServer returns an initialized praefect gPRC proxy server configured with the provided gRPC server options

func (*Server) GracefulStop added in v1.75.0

func (srv *Server) GracefulStop()

GracefulStop stops the praefect server gracefully

func (*Server) RegisterServices added in v1.75.0

func (srv *Server) RegisterServices()

RegisterServices will register any services praefect needs to handle rpcs on its own

func (*Server) Serve added in v1.75.0

func (srv *Server) Serve(l net.Listener, secure bool) error

Serve starts serving requests from the listener

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

Shutdown will attempt a graceful shutdown of the grpc server. If unable to gracefully shutdown within the context deadline, it will then forcefully shutdown the server and return a context cancellation error.

func (*Server) Stop added in v1.75.0

func (srv *Server) Stop()

Stop stops the praefect server

type Shard added in v1.86.0

type Shard interface {
	GetPrimary() (Node, error)
	GetSecondaries() ([]Node, error)
}

Shard is a primary with a set of secondaries

Directories

Path Synopsis
Package datastore provides data models and datastore persistence abstractions for tracking the state of repository replicas.
Package datastore provides data models and datastore persistence abstractions for tracking the state of repository replicas.
grpc-proxy
proxy
Package proxy provides a reverse proxy handler for gRPC.
Package proxy provides a reverse proxy handler for gRPC.
service

Jump to

Keyboard shortcuts

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