CovenantSQL: github.com/CovenantSQL/CovenantSQL/chainbus Index | Files

package chainbus

import "github.com/CovenantSQL/CovenantSQL/chainbus"

Index

Package Files

bus.go doc.go

type Bus Uses

type Bus interface {
    BusController
    ChainSuber
    ChainPuber
}

Bus englobes global (subscribe, publish, control) bus behavior.

func New Uses

func New() Bus

New returns new ChainBus with empty handlers.

type BusController Uses

type BusController interface {
    HasCallback(topic string) bool
    WaitAsync()
}

BusController defines bus control behavior (checking handler's presence, synchronization).

type ChainBus Uses

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

ChainBus - box for handlers and callbacks.

func (*ChainBus) HasCallback Uses

func (bus *ChainBus) HasCallback(topic string) bool

HasCallback returns true if exists any callback subscribed to the topic.

func (*ChainBus) Publish Uses

func (bus *ChainBus) Publish(topic string, args ...interface{})

Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.

func (*ChainBus) Subscribe Uses

func (bus *ChainBus) Subscribe(topic string, fn interface{}) error

Subscribe subscribes to a topic. Returns error if `fn` is not a function.

func (*ChainBus) SubscribeAsync Uses

func (bus *ChainBus) SubscribeAsync(topic string, fn interface{}, transactional bool) error

SubscribeAsync subscribes to a topic with an asynchronous callback Async determines whether subsequent Publish should wait for callback return Transactional determines whether subsequent callbacks for a topic are run serially (true) or concurrently (false) Returns error if `fn` is not a function.

func (*ChainBus) SubscribeOnce Uses

func (bus *ChainBus) SubscribeOnce(topic string, fn interface{}) error

SubscribeOnce subscribes to a topic once. Handler will be removed after executing. Returns error if `fn` is not a function.

func (*ChainBus) SubscribeOnceAsync Uses

func (bus *ChainBus) SubscribeOnceAsync(topic string, fn interface{}) error

SubscribeOnceAsync subscribes to a topic once with an asynchronous callback Async determines whether subsequent Publish should wait for callback return Handler will be removed after executing. Returns error if `fn` is not a function.

func (*ChainBus) Unsubscribe Uses

func (bus *ChainBus) Unsubscribe(topic string, handler interface{}) error

Unsubscribe removes callback defined for a topic. Returns error if there are no callbacks subscribed to the topic.

func (*ChainBus) WaitAsync Uses

func (bus *ChainBus) WaitAsync()

WaitAsync waits for all async callbacks to complete.

type ChainPuber Uses

type ChainPuber interface {
    Publish(topic string, args ...interface{})
}

ChainPuber defines publishing-related bus behavior.

type ChainSuber Uses

type ChainSuber interface {
    Subscribe(topic string, handler interface{}) error
    SubscribeAsync(topic string, handler interface{}, transactional bool) error
    SubscribeOnce(topic string, handler interface{}) error
    SubscribeOnceAsync(topic string, handler interface{}) error
    Unsubscribe(topic string, handler interface{}) error
}

ChainSuber defines subscribing-related bus behavior.

Package chainbus imports 3 packages (graph) and is imported by 2 packages. Updated 2019-01-16. Refresh now. Tools for package owners.