Documentation ¶
Overview ¶
Package topic implements a carrier topic tree with functionality to unicast, broadcast and load balance between nodes of the tree.
Index ¶
- Variables
- type Topic
- func (t *Topic) Balance(ex *big.Int) (*big.Int, error)
- func (t *Topic) Broadcast(ex *big.Int) []*big.Int
- func (t *Topic) Cycle()
- func (t *Topic) Empty() bool
- func (t *Topic) GenerateReports() ([]*big.Int, []int)
- func (t *Topic) Neighbor(id *big.Int) bool
- func (t *Topic) Parent() *big.Int
- func (t *Topic) ProcessReport(id *big.Int, cap int) error
- func (t *Topic) Reown(parent *big.Int)
- func (t *Topic) Self() *big.Int
- func (t *Topic) Subscribe(id *big.Int) error
- func (t *Topic) Unsubscribe(id *big.Int) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotSubscribed = errors.New("not subscribed")
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 (*Topic) Balance ¶
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 ¶
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) GenerateReports ¶
Returns the list of nodes to report to, and the report for each.
func (*Topic) ProcessReport ¶
Sets the load capacity for a source node in the balancer.