topic

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: GPL-3.0-or-later Imports: 8 Imported by: 4

Documentation

Overview

Package topic implements a carrier topic tree with functionality to unicast, broadcast and load balance between nodes of the tree.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSubscribed = errors.New("not subscribed")
View Source
var ErrSubscribed = errors.New("already subscribed")

Custom topic error messages

Functions

This section is empty.

Types

type Topic

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

The maintenance data related to a single topic.

func New

func New(id, owner *big.Int) *Topic

Creates a new topic with no subscriptions.

func (*Topic) Balance

func (t *Topic) Balance(ex *big.Int) (*big.Int, error)

Returns a node id to which the balancer deemed the next message should be sent. An optional ex node can be specified to prevent balancing there (if others exist).

func (*Topic) Broadcast

func (t *Topic) Broadcast(ex *big.Int) []*big.Int

Returns the list of nodes that a broadcast message should be sent to. An optional ex node can be specified to exclude it from the list.

func (*Topic) Cycle

func (t *Topic) Cycle()

If local subscriptions are alive in the topic, updates the balancer according to the messages processed since the last beat.

func (*Topic) Empty

func (t *Topic) Empty() bool

Returns whether the current topic subtree is empty.

func (*Topic) GenerateReports

func (t *Topic) GenerateReports() ([]*big.Int, []int)

Returns the list of nodes to report to, and the report for each.

func (*Topic) Neighbor

func (t *Topic) Neighbor(id *big.Int) bool

Returns whether a node is a neighbor of the current one in the topic tree.

func (*Topic) Parent

func (t *Topic) Parent() *big.Int

Returns the current topic parent node.

func (*Topic) ProcessReport

func (t *Topic) ProcessReport(id *big.Int, cap int) error

Sets the load capacity for a source node in the balancer.

func (*Topic) Reown

func (t *Topic) Reown(parent *big.Int)

Sets the topic parent to the one specified.

func (*Topic) Self

func (t *Topic) Self() *big.Int

Returns the topic identifier.

func (*Topic) Subscribe

func (t *Topic) Subscribe(id *big.Int) error

Subscribes a node to the topic and inserts it into the load balancer registry.

func (*Topic) Unsubscribe

func (t *Topic) Unsubscribe(id *big.Int) error

Unregisters a node from the topic, removing it from the balancer's registry.

Jump to

Keyboard shortcuts

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