cluster

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Overview

Package cluster exports an asynchronously updated model of the swarm.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosing = errors.New("closing")

Functions

This section is empty.

Types

type Clock

type Clock interface {
	// Context returns a context that SHALL expire before a call
	// to Stop() returns.
	Context() context.Context

	// Tick returns a channel that receives the current time
	// at regular intervals.  Implementations SHOULD select a
	// tick interval that is smaller than the minimum expected
	// TTL for the cluster. Implementations MUST NOT close the
	// channel returned by Tick until c.Context() has expired.
	// Closing the channel returned by Tick() is OPTIONAL.
	Tick() <-chan time.Time

	// Stop closes the context returned by Context() and frees
	// all resources.  Relay is guaranteed not to call Start()
	// after Stop() returns.  Relay MAY however call Context()
	// after Stop() has returned.
	Stop()
}

Clock tracks the passage of time, allowing Router to update its internal state and free resources when the clock has stopped. Clock's methods MUST be safe for concurrent access.

func NewClock

func NewClock(tick time.Duration) Clock

NewClock with the specified tick interval.

type Router

type Router struct {
	Topic Topic

	Log          log.Logger
	TTL          time.Duration
	Meta         pulse.Preparer
	Clock        Clock
	RoutingTable RoutingTable
	// contains filtered or unexported fields
}

Router is a peer participating in the cluster membership protocol. It maintains a global view of the cluster with PA/EL guarantees, and periodically announces its presence to others.

func (*Router) Bootstrap

func (r *Router) Bootstrap(ctx context.Context, opt ...pubsub.PubOpt) (err error)

func (*Router) ID

func (r *Router) ID() (id routing.ID)

func (*Router) Stop

func (r *Router) Stop()

func (*Router) String

func (r *Router) String() string

func (*Router) View

func (r *Router) View() view.View

type RoutingTable

type RoutingTable interface {
	Advance(time.Time)
	Upsert(routing.Record) (created bool)
	Snapshot() routing.Snapshot
}

RoutingTable tracks the liveness of cluster peers and provides a simple API for querying routing information.

type Topic

type Topic interface {
	String() string
	Publish(context.Context, []byte, ...pubsub.PubOpt) error
	Relay() (pubsub.RelayCancelFunc, error)
}

Directories

Path Synopsis
Package pulse provides ev cluster-management service based on pubsub.
Package pulse provides ev cluster-management service based on pubsub.
test
Package test_pulse is a generated GoMock package.
Package test_pulse is a generated GoMock package.
test
Package test_routing is a generated GoMock package.
Package test_routing is a generated GoMock package.
Package test_cluster is a generated GoMock package.
Package test_cluster is a generated GoMock package.

Jump to

Keyboard shortcuts

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