Documentation
¶
Index ¶
- Constants
- type Broker
- type Client
- func (c *Client) Channel() chan *Message
- func (c *Client) Close() (err error)
- func (c *Client) Patterns() []string
- func (c *Client) Publish(msg ...*Message) error
- func (c *Client) Subscribe(topics ...string) error
- func (c *Client) SubscribePattern(pattern string) error
- func (c *Client) Topics() []string
- func (c *Client) Unsubscribe(topics ...string) error
- func (c *Client) UnsubscribePattern(pattern string) error
- type Config
- type Memory
- func (m *Memory) Publish(messages ...*Message) error
- func (m *Memory) Serve() error
- func (m *Memory) Stop()
- func (m *Memory) Subscribe(upstream chan *Message, topics ...string) error
- func (m *Memory) SubscribePattern(upstream chan *Message, pattern string) error
- func (m *Memory) Unsubscribe(upstream chan *Message, topics ...string) error
- func (m *Memory) UnsubscribePattern(upstream chan *Message, pattern string) error
- type Message
- type Redis
- func (r *Redis) Publish(messages ...*Message) error
- func (r *Redis) Serve() error
- func (r *Redis) Stop()
- func (r *Redis) Subscribe(upstream chan *Message, topics ...string) error
- func (r *Redis) SubscribePattern(upstream chan *Message, pattern string) error
- func (r *Redis) Unsubscribe(upstream chan *Message, topics ...string) error
- func (r *Redis) UnsubscribePattern(upstream chan *Message, pattern string) error
- type RedisConfig
- type Router
- func (r *Router) Dispatch(msg *Message)
- func (r *Router) Subscribe(upstream chan *Message, topics ...string) (newTopics []string)
- func (r *Router) SubscribePattern(upstream chan *Message, pattern string) (newPatterns []string, err error)
- func (r *Router) Unsubscribe(upstream chan *Message, topics ...string) (dropTopics []string)
- func (r *Router) UnsubscribePattern(upstream chan *Message, pattern string) (dropPatterns []string)
- type Service
Constants ¶
const ID = "broadcast"
ID defines public service name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker interface { // Serve serves broker. Serve() error // Stop closes the consumption and disconnects broker. Stop() // Subscribe broker to one or multiple topics. Subscribe(upstream chan *Message, topics ...string) error // SubscribePattern broker to pattern. SubscribePattern(upstream chan *Message, pattern string) error // Unsubscribe broker from one or multiple topics. Unsubscribe(upstream chan *Message, topics ...string) error // UnsubscribePattern broker from pattern. UnsubscribePattern(upstream chan *Message, pattern string) error // Publish one or multiple Channel. Publish(messages ...*Message) error }
Broker defines the ability to operate as message passing broker.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client subscribes to a given topic and consumes or publish messages to it.
func (*Client) SubscribePattern ¶
SubscribePattern subscribe client to the specific topic pattern.
func (*Client) Unsubscribe ¶
Unsubscribe client from specific topics
func (*Client) UnsubscribePattern ¶
UnsubscribePattern client from topic pattern.
type Config ¶
type Config struct { // RedisConfig configures redis broker. Redis *RedisConfig }
Config configures the broadcast extension.
func (*Config) InitDefaults ¶
InitDefaults enables in memory broadcast configuration.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory manages broadcasting in memory.
func (*Memory) SubscribePattern ¶
SubscribePattern broker to pattern.
func (*Memory) Unsubscribe ¶
Unsubscribe broker from one or multiple channels.
type Message ¶
type Message struct { // Topic message been pushed into. Topic string `json:"topic"` // Payload to be broadcasted. Must be valid json when transferred over RPC. Payload json.RawMessage `json:"payload"` }
Message represent single message.
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis based broadcast Router.
func (*Redis) SubscribePattern ¶
SubscribePattern broker to pattern.
func (*Redis) Unsubscribe ¶
Unsubscribe broker from one or multiple channels.
type RedisConfig ¶
type RedisConfig struct { // Addr of the redis server. Addr string // Password to redis server. Password string // DB index. DB int }
RedisConfig configures redis broker.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router performs internal message routing to multiple subscribers.
func (*Router) SubscribePattern ¶
func (r *Router) SubscribePattern(upstream chan *Message, pattern string) (newPatterns []string, err error)
SubscribePattern subscribes to glob parent and return true and return array of newly added patterns. Error in case if blob is invalid.
func (*Router) Unsubscribe ¶
Unsubscribe from given list of topics and return list of topics which are no longer claimed.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages even broadcasting and websocket interface.
func (*Service) NewClient ¶
NewClient returns single connected client with ability to consume or produce into associated topic(svc).