cluster

package
v0.0.0-...-055f8da Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0, MIT Imports: 19 Imported by: 3

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 Constraint

type Constraint func(ConstraintStruct) error

type ConstraintStruct

type ConstraintStruct = api.View_Constraint

type FutureRecord

type FutureRecord api.View_MaybeRecord_Future

func (FutureRecord) Await

func (f FutureRecord) Await(ctx context.Context) (routing.Record, error)

func (FutureRecord) Record

func (f FutureRecord) Record() (routing.Record, error)

type Iterator

type Iterator casm.Iterator[routing.Record]

Iterator is a stateful object that enumerates routing records. See casm.Iterator() for important information on lifetime and error handling.

func (Iterator) Err

func (it Iterator) Err() error

Err reports any error encountered during iteration. Next will always return nil when Err() != nil.

func (Iterator) Next

func (it Iterator) Next() routing.Record

Next upates the iterator's internal state and returns the next record in the stream. If a call to Next returns nil, the iterator is exhausted.

Records returned by Next are valid until the next call to Next, or until the iterator is released. See View.Iter().

type Query

type Query func(QueryParams) error

func NewQuery

func NewQuery(s Selector, cs ...Constraint) Query

type QueryParams

type QueryParams interface {
	NewSelector() (api.View_Selector, error)
	NewConstraints(int32) (api.View_Constraint_List, error)
}

type RecordBinder

type RecordBinder interface {
	BindRecord(api.View_Record) error
}

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) Loggable

func (r *Router) Loggable() map[string]any

func (*Router) Stop

func (r *Router) Stop()

func (*Router) String

func (r *Router) String() string

func (*Router) View

func (r *Router) 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 Selector

type Selector func(SelectorStruct) error

func All

func All() Selector

func From

func From(index routing.Index) Selector

func Match

func Match(index routing.Index) Selector

type SelectorStruct

type SelectorStruct = api.View_Selector

type Server

type Server struct {
	RoutingTable interface {
		Snapshot() routing.Snapshot
	}
}

func (Server) Client

func (s Server) Client() capnp.Client

func (Server) Iter

func (s Server) Iter(ctx context.Context, call api.View_iter) error

func (Server) Lookup

func (s Server) Lookup(ctx context.Context, call api.View_lookup) error

func (Server) Reverse

func (s Server) Reverse(ctx context.Context, call api.View_reverse) error

func (Server) View

func (s Server) View() View

type Topic

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

type View

type View api.View

func (View) AddRef

func (v View) AddRef() View

func (View) Iter

func (v View) Iter(ctx context.Context, query Query) (Iterator, capnp.ReleaseFunc)

Iter returns an iterator that ranges over records matching the supplied query. Callers MUST call the ReleaseFunc when finished with the iterator. Callers MUST NOT call methods on the iterator after calling the ReleaseFunc.

func (View) Lookup

func (v View) Lookup(ctx context.Context, query Query) (FutureRecord, capnp.ReleaseFunc)

Lookup returns the first record to match the supplied query. Callers MUST call ReleaseFunc when finished. Note that this will invalidate any record returned by FutureRecord.

func (View) Release

func (v View) Release()

Directories

Path Synopsis
Package pulse provides ev cluster-management service based on pubsub.
Package pulse provides ev cluster-management service based on pubsub.

Jump to

Keyboard shortcuts

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