lockproxy

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const RFC3339Milli = "2006-01-02T15:04:05.999Z07:00"

Variables

This section is empty.

Functions

func GetExponentialBackOff added in v0.3.0

func GetExponentialBackOff(initialInterval time.Duration, maxElapsedTime time.Duration) *backoff.ExponentialBackOff

func GrpcDialTransportSecurity

func GrpcDialTransportSecurity(
	certPath string,
	keyPath string,
	caPath string,
) (grpc.DialOption, error)

func NewDebugServer

func NewDebugServer() *http.Server

func NewHealthServer

func NewHealthServer(healthService grpc_health_v1.HealthServer) *grpc.Server

func NewProxyServer

func NewProxyServer(proxyDirector *ProxyDirector) *grpc.Server

Types

type Adapter added in v0.2.0

type Adapter interface {
	Init(ctx context.Context) error
	GetLocker(onLocked func(ctx context.Context) error) (Locker, error)
	GetRemoteAddrStore(addrStore LocalAddrStore) (RemoteAddrStore, error)
	Close() error
}

type Commander

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

Commander starts the command. It handles graceful shutdown with a timeout after which the command is forcefully killed.

func NewCommander

func NewCommander(
	cmd []string,
	cmdShutdownTimeout time.Duration,
	logger *logrus.Entry,
) *Commander

func (*Commander) Start

func (c *Commander) Start(ctx context.Context) error

type HealthService

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

func NewHealthService

func NewHealthService(isLeader func(ctx context.Context) bool) *HealthService

type JSONFormatter

type JSONFormatter struct {
	*logrus.JSONFormatter
}

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(entry *logrus.Entry) ([]byte, error)

type LocalAddrStore added in v0.3.0

type LocalAddrStore interface {
	Addr(ctx context.Context) string
	SetAddr(ctx context.Context, addr string)
}

type LockProxy

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

func NewLockProxy

func NewLockProxy(
	config *config.Config,
	adapter Adapter,
	logger *logrus.Entry,
) *LockProxy

func (*LockProxy) Close

func (p *LockProxy) Close() error

func (*LockProxy) Init

func (p *LockProxy) Init(ctx context.Context) error

func (*LockProxy) Spawn

func (p *LockProxy) Spawn(name string, f func(context.Context) error)

func (*LockProxy) Start

func (p *LockProxy) Start() error

type Locker

type Locker interface {
	Start(ctx context.Context) error
}

type MemoryAddrStore added in v0.3.0

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

MemoryAddrStore stores the current proxy address locally.

func NewMemoryAddrStore added in v0.3.0

func NewMemoryAddrStore(
	logger *logrus.Entry,
) *MemoryAddrStore

func (*MemoryAddrStore) Addr added in v0.3.0

func (s *MemoryAddrStore) Addr(ctx context.Context) string

func (*MemoryAddrStore) SetAddr added in v0.3.0

func (s *MemoryAddrStore) SetAddr(ctx context.Context, addr string)

type Pinger

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

func NewPinger

func NewPinger(
	ping func(ctx context.Context) error,
	retryInitialInterval time.Duration,
	retryMaxElapsedTime time.Duration,
	delay time.Duration,
	initialDelay time.Duration,
	logger *logrus.Entry,
) *Pinger

func (*Pinger) Ping

func (p *Pinger) Ping(ctx context.Context) error

func (*Pinger) Start

func (p *Pinger) Start(ctx context.Context) error

type ProxyDirector

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

ProxyDirector is gRPC connection handler. It is called for every gRPC method call. It gets the current upstream address from upstreamAddrProvider and fails with Unavailable if the address is not set. It accepts a global Context after which all the requests are cancelled.

If enabled and the current method is /grpc.health.v1.Health/* and the server is not leader we proxy the request to the our internal health server.

func NewProxyDirector

func NewProxyDirector(
	ctx context.Context,
	upstreamAddrProvider UpstreamAddrProvider,
	healthAddr string,
	grpcDialTransportSecurity grpc.DialOption,
	grpcMaxCallRecvMsgSize int,
	grpcMaxCallSendMsgSize int,
	abortTimeout time.Duration,
	proxyHealthFollowerInternal bool,
	logger *logrus.Entry,
) *ProxyDirector

func (*ProxyDirector) Director

func (d *ProxyDirector) Director(ctx context.Context, fullMethodName string) (context.Context, *grpc.ClientConn, error)

type RemoteAddrStore added in v0.3.0

type RemoteAddrStore interface {
	Addr(ctx context.Context) string
	Refresh(ctx context.Context) (addr string, err error)
	Start(ctx context.Context, onInit func()) error
	SetAddr(ctx context.Context, addr string) error
}

type UpstreamAddrProvider

type UpstreamAddrProvider func(ctx context.Context) (addr string, isLeader bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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