Documentation ¶
Index ¶
- type BaseMessage
- type IMessage
- type IMessageBus
- type InMemoryMessageBus
- func (m *InMemoryMessageBus) Ping(retries uint, intervalInSeconds uint) error
- func (m *InMemoryMessageBus) Pop(mf MessageFactory, timeout time.Duration, queue ...string) (IMessage, error)
- func (m *InMemoryMessageBus) Publish(messages ...IMessage) error
- func (m *InMemoryMessageBus) Push(messages ...IMessage) error
- func (m *InMemoryMessageBus) Subscribe(callback SubscriptionCallback, mf MessageFactory, topics ...string) (subscriptionId string)
- func (m *InMemoryMessageBus) Unsubscribe(subscriptionId string) (success bool)
- type MessageFactory
- type SubscriptionCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseMessage ¶
type BaseMessage struct { MsgTopic string `json:"topic"` // Message topic (channel) MsgOpCode int `json:"opCode"` // Message op code MsgAddressee string `json:"addressee"` // Message final addressee MsgSessionId string `json:"sessionId"` // Session id shared across all messages related to the same session MsgPayload any `json:"payload"` // Message payload }
BaseMessage basie implementation of IMessage interface
func (*BaseMessage) Addressee ¶
func (m *BaseMessage) Addressee() string
func (*BaseMessage) OpCode ¶
func (m *BaseMessage) OpCode() int
func (*BaseMessage) Payload ¶
func (m *BaseMessage) Payload() any
func (*BaseMessage) SessionId ¶
func (m *BaseMessage) SessionId() string
func (*BaseMessage) Topic ¶
func (m *BaseMessage) Topic() string
type IMessage ¶
type IMessage interface { // Topic name (also known as channel or queue) Topic() string // OpCode message operational code OpCode() int // Addressee message final addressee (recipient) - optional field Addressee() string // SessionId identifies a message exchange session which is shared across all messages related to the same session SessionId() string // Payload is the message body Payload() any }
IMessage General message interface
type IMessageBus ¶
type IMessageBus interface { // Ping Test connectivity for retries number of time with time interval (in seconds) between retries Ping(retries uint, intervalInSeconds uint) error // Publish messages to a channel (topic) Publish(messages ...IMessage) error // Subscribe on topics Subscribe(callback SubscriptionCallback, mf MessageFactory, topics ...string) (subscriptionId string) // Unsubscribe with the given subscriber id Unsubscribe(subscriptionId string) (success bool) // Push Append one or multiple messages to a queue Push(messages ...IMessage) error // Pop Remove and get the last message in a queue or block until timeout expires Pop(mf MessageFactory, timeout time.Duration, queue ...string) (IMessage, error) }
IMessageBus Message bus interface
func NewInMemoryMessageBus ¶
func NewInMemoryMessageBus() (mq IMessageBus, err error)
NewInMemoryMessageBus Factory method
type InMemoryMessageBus ¶
type InMemoryMessageBus struct {
// contains filtered or unexported fields
}
InMemoryMessageBus represents in memory implementation of IMessageBus interface topics is a map ot topic -> array of channels (channel per subscriber)
func (*InMemoryMessageBus) Ping ¶
func (m *InMemoryMessageBus) Ping(retries uint, intervalInSeconds uint) error
Ping Test connectivity for retries number of time with time interval (in seconds) between retries
func (*InMemoryMessageBus) Pop ¶
func (m *InMemoryMessageBus) Pop(mf MessageFactory, timeout time.Duration, queue ...string) (IMessage, error)
Pop Remove and get the last message in a queue or block until timeout expires
func (*InMemoryMessageBus) Publish ¶
func (m *InMemoryMessageBus) Publish(messages ...IMessage) error
Publish messages to a channel (topic)
func (*InMemoryMessageBus) Push ¶
func (m *InMemoryMessageBus) Push(messages ...IMessage) error
Push Append one or multiple messages to a queue
func (*InMemoryMessageBus) Subscribe ¶
func (m *InMemoryMessageBus) Subscribe(callback SubscriptionCallback, mf MessageFactory, topics ...string) (subscriptionId string)
Subscribe on topics
func (*InMemoryMessageBus) Unsubscribe ¶
func (m *InMemoryMessageBus) Unsubscribe(subscriptionId string) (success bool)
Unsubscribe with the given subscriber id
type MessageFactory ¶
type MessageFactory func() IMessage
MessageFactory is a factory method of any message
type SubscriptionCallback ¶
type SubscriptionCallback func(msg IMessage)
SubscriptionCallback Message subscription callback function