interfaces

package
v0.0.0-...-6de2257 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: BSD-3-Clause Imports: 1 Imported by: 7

Documentation

Overview

Package interfaces provides all the interfaces used in Rafty. They have been secluded in this package in order to avoid circular imports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discoverer

type Discoverer interface {
	// NewServers returns a channel that is used to notify Rafty that there is a
	// new list of servers available. Although not required, it is better that
	// notifications are sent only when the list of servers has changed.
	NewServers() chan struct{}

	// GetServers returns the current list of servers.
	GetServers() []raft.Server
}

Discoverer is the mechanism Rafty uses to discover other Rafty processes.

type Distributor

type Distributor[T any, T2 Work[T]] interface {
	Distribute(servers []raft.Server, works []T2) map[raft.ServerID][]T2
}

Distributor is the mechanism that allows to distibute work across the members of the Raft cluster that constitutes Rafty.

type Finalizer

type Finalizer interface {
	Done() chan struct{}
}

Finalizer interface is used to finalize the discovery process. In the event of a Rafty process being stopped, if the Discoverer also implements Finalizer, Rafty will call Done() to allow the Discoverer to perform any cleanup required before the process exits.

type Foreman

type Foreman[T any, T2 Work[T]] interface {
	// Start is called on the process that has been elected as the leader by the
	// Raft Cluster.
	Start()

	// Stop is called in the event we lose leadership.
	Stop()

	// NewWorks returns a channel that is used to notify Rafty that there is new
	// works available.
	NewWorks() chan struct{}

	// GetWorks returns the current list of work.
	GetWorks() []T2
}

Formeman is the mechanism Rafty uses to retrieve work.

type Logger

type Logger interface {
	Tracef(format string, fields ...interface{})
	Debugf(format string, fields ...interface{})
	Infof(format string, fields ...interface{})
	Warnf(format string, fields ...interface{})
	Errorf(format string, fields ...interface{})
}

type Work

type Work[T any] interface {
	ID() string
	Object() T
	Equals(T) bool
}

type Works

type Works[T any, T2 Work[T]] interface {
	GetWorks() []T2
}

Jump to

Keyboard shortcuts

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