syncserver

package
v0.0.0-...-21cfbab Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0, Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PortRandom = -1
)

Variables

View Source
var (
	ErrReadFailed               = errors.New("Failed to read from client")
	ErrUnexpectedClientMsg      = errors.New("Unexpected message from client")
	ErrUnsupportedClientFeature = errors.New("Unsupported client feature")
)

Functions

This section is empty.

Types

type BreadcrumbProvider interface {
	CurrentBreadcrumb() *snapcache.Breadcrumb
}

type Config

type Config struct {
	Port                           int
	MaxMessageSize                 int
	BinarySnapshotTimeout          time.Duration
	MaxFallBehind                  time.Duration
	NewClientFallBehindGracePeriod time.Duration
	MinBatchingAgeThreshold        time.Duration
	PingInterval                   time.Duration
	PongTimeout                    time.Duration
	WriteTimeout                   time.Duration
	DropInterval                   time.Duration
	ShutdownTimeout                time.Duration
	ShutdownMaxDropInterval        time.Duration
	MaxConns                       int
	HealthAggregator               *health.HealthAggregator
	KeyFile                        string
	CertFile                       string
	CAFile                         string
	ClientCN                       string
	ClientURISAN                   string
	WriteBufferSize                int

	// DebugLogWrites tells the server to wrap each connection with a Writer that
	// logs every write.  Intended only for use in tests!
	DebugLogWrites bool

	// FIPSModeEnabled Enables FIPS 140-2 verified crypto mode.
	FIPSModeEnabled bool
}

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

func (*Config) ListenPort

func (c *Config) ListenPort() int

type Server

type Server struct {
	Finished sync.WaitGroup
	// contains filtered or unexported fields
}

func New

func New(caches map[syncproto.SyncerType]BreadcrumbProvider, config Config) *Server

func (*Server) NumActiveConnections

func (s *Server) NumActiveConnections() int

func (*Server) Port

func (s *Server) Port() int

func (*Server) SetMaxConns

func (s *Server) SetMaxConns(numConns int)

func (*Server) ShutDownGracefully

func (s *Server) ShutDownGracefully()

func (*Server) ShuttingDown

func (s *Server) ShuttingDown() bool

func (*Server) Start

func (s *Server) Start(cxt context.Context)

func (*Server) TerminateRandomConnection

func (s *Server) TerminateRandomConnection(logCtx *log.Entry, reason string) bool

TerminateRandomConnection tries to drop a connection at random. On success, returns true. If there are no connections returns false.

type SnappySnapshotCache

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

func NewSnappySnapCache

func NewSnappySnapCache(
	syncerName string,
	cache BreadcrumbProvider,
	snapValidityTimeout time.Duration,
	writeTimeout time.Duration,
) *SnappySnapshotCache

func (*SnappySnapshotCache) SendSnapshot

SendSnapshot waits for a binary snapshot to be ready and then sends it as a raw snappy-compressed gob stream on the given connection. Since the stream is cached, it starts with fresh snappy/gob headers. Hence, the decoder at the client side must also be reset before sending such a snapshot. The snapshot ends with a MsgDecoderRestart, so the caller should wait for an ACK and then reset their encoder.

type WriteDeadlineSetter

type WriteDeadlineSetter interface {
	SetWriteDeadline(newDeadline time.Time) error
}

Jump to

Keyboard shortcuts

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