rounds

package
v4.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: BSD-2-Clause, BSD-2-Clause Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteRound

func DeleteRound(kv *versioned.KV, key string) error

func StoreRound

func StoreRound(kv *versioned.KV, round Round, key string) error

StoreRound stores the round using the key.

Types

type Comms

type Comms interface {
	GetHost(hostId *id.ID) (*connect.Host, bool)
	RequestHistoricalRounds(host *connect.Host, message *pb.HistoricalRounds) (
		*pb.HistoricalRoundsResponse, error)
}

Comms interface to increase east of testing of historical rounds.

type Params

type Params struct {
	// MaxHistoricalRounds is the number of historical rounds required to
	// automatically send a historical rounds query.
	MaxHistoricalRounds uint

	// HistoricalRoundsPeriod is the maximum period of time a pending historical
	// round query will wait before it is transmitted.
	HistoricalRoundsPeriod time.Duration

	// HistoricalRoundsBufferLen is the length of historical rounds channel
	// buffer.
	HistoricalRoundsBufferLen uint

	// MaxHistoricalRoundsRetries is the maximum number of times a historical
	// round lookup will be attempted.
	MaxHistoricalRoundsRetries uint
}

Params contains the parameters for the rounds package.

func GetDefaultParams

func GetDefaultParams() Params

GetDefaultParams returns a default set of Params.

func GetParameters

func GetParameters(params string) (Params, error)

GetParameters returns the default Params, or override with given parameters, if set.

func (Params) MarshalJSON

func (r Params) MarshalJSON() ([]byte, error)

MarshalJSON adheres to the json.Marshaler interface.

func (*Params) UnmarshalJSON

func (r *Params) UnmarshalJSON(data []byte) error

UnmarshalJSON adheres to the json.Unmarshaler interface.

type Retriever

type Retriever interface {
	StartProcesses() *stoppable.Single
	LookupHistoricalRound(rid id.Round, callback RoundResultCallback) error
}

func NewRetriever

func NewRetriever(param Params, comms Comms, sender gateway.Sender,
	events event.Reporter) Retriever

type Round

type Round struct {
	// ID of the round. IDs are sequential and monotonic.
	ID id.Round

	// State is the last known state of the round. Possible states are:
	//   PENDING - not started yet
	//   PRECOMPUTING - In the process of preparing to process messages
	//   STANDBY - Completed precomputing but not yet scheduled to run
	//	 QUEUED - Scheduled to run at a set time
	//	 REALTIME - Running, actively handing messages
	//	 COMPLETED - Successfully deleted messages
	//	 FAILED - Failed to deliver messages
	State states.Round

	// Topology contains the list of nodes in the round.
	Topology *connect.Circuit

	// Timestamps of all events that have occurred in the round (see the above
	// states).
	// The QUEUED state's timestamp is different; it denotes when Realtime
	// was/is scheduled to start, not whe the QUEUED state is entered.
	Timestamps map[states.Round]time.Time

	// Errors that occurred in the round. Will only be present in the failed
	// state.
	Errors []RoundError

	// BatchSize is the max number of messages the round can process.
	BatchSize uint32

	// AddressSpaceSize is the ephemeral address space size used in the round.
	AddressSpaceSize uint8

	// UpdateID is a monotonic counter between all round updates denoting when
	// this updated occurred in the queue.
	UpdateID uint64

	// Raw is raw round data, including signatures.
	Raw *pb.RoundInfo
}

func LoadRound

func LoadRound(kv *versioned.KV, key string) (Round, error)

LoadRound stores the round using the key.

func MakeRound

func MakeRound(ri *pb.RoundInfo) Round

MakeRound builds an accessible round object from a RoundInfo protobuf.

func (Round) GetEndTimestamp

func (r Round) GetEndTimestamp() time.Time

GetEndTimestamp returns the timestamp of the last known event, which is generally the state unless in queued, which stores the next event.

type RoundError

type RoundError struct {
	NodeID *id.ID
	Error  string
}

func (*RoundError) String

func (re *RoundError) String() string

String prints a formatted version of the client error string

type RoundResultCallback

type RoundResultCallback func(round Round, success bool)

RoundResultCallback is the used callback when a round is found.

Jump to

Keyboard shortcuts

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