Documentation ¶
Index ¶
Constants ¶
View Source
const ( // UnorderedDelivery means that messages are delivered in random order. It's good to distribute independent events in a distributed system. UnorderedDelivery = int16(1) << iota // OrderedDelivery means that messages are delivered in some order. Not implemented yet. OrderedDelivery )
Variables ¶
View Source
var ( // PublishedTotal is the total number of published messages during the life of this instance. PublishedTotal = stats.NewInt64Counter() // CurrentListeners is the current number of listeners of DTopics. CurrentListeners = stats.NewInt64Gauge() // ListenersTotal is the total number of registered listeners during the life of this instance. ListenersTotal = stats.NewInt64Counter() )
View Source
var ErrServerGone = errors.New("server is gone")
Functions ¶
func NewService ¶
func NewService(e *environment.Environment) (service.Service, error)
Types ¶
type DTopic ¶
type DTopic struct {
// contains filtered or unexported fields
}
DTopic implements a distributed topic to deliver messages between clients and Olric nodes. You should know that:
- Communication between parties is one-to-many (fan-out).
- All data is in-memory, and the published messages are not stored in the cluster.
- Fire&Forget: message delivery is not guaranteed.
func (*DTopic) AddListener ¶
AddListener adds a new listener for the topic. Returns a registration ID or a non-nil error. Registered functions are run by parallel.
func (*DTopic) Destroy ¶
Destroy removes all listeners for this topic on the cluster. If Publish function is called again after Destroy, the topic will be recreated.
func (*DTopic) Publish ¶
Publish publishes the given message to listeners of the topic. Message order and delivery are not guaranteed.
func (*DTopic) RemoveListener ¶
RemoveListener removes a listener with the given listenerID.
type Dispatcher ¶
func NewDispatcher ¶
func NewDispatcher(ctx context.Context) *Dispatcher
type Service ¶
func (*Service) NewDTopic ¶
NewDTopic returns a new distributed topic instance. Parameters:
- name: DTopic name.
- concurrency: Maximum number of concurrently processing DTopic messages.
- flag: Any flag to control DTopic behaviour.
Flags for delivery options:
- UnorderedDelivery: Messages are delivered in random order. It's good to distribute independent events in a distributed system.
- OrderedDelivery: Messages are delivered in order. Not implemented yet.
func (*Service) RegisterOperations ¶
func (s *Service) RegisterOperations(operations map[protocol.OpCode]func(w, r protocol.EncodeDecoder))
Click to show internal directories.
Click to hide internal directories.