Documentation ¶
Index ¶
- Variables
- type Callback
- type DefaultSubscription
- type Event
- type EventQueue
- type GoPolling
- func (g *GoPolling) Notify(channel string, data interface{}, selector S) error
- func (g *GoPolling) SubscribeListener(roomID string, lf ListenerFunc)
- func (g *GoPolling) WaitForNotice(ctx context.Context, channel string, data interface{}) (interface{}, error)
- func (g *GoPolling) WaitForSelectedNotice(ctx context.Context, channel string, data interface{}, selector S) (interface{}, error)
- type GoroutineBus
- func (g *GoroutineBus) Dequeue(channel string) <-chan Event
- func (g *GoroutineBus) Enqueue(channel string, t Event)
- func (g *GoroutineBus) Publish(channel string, msg Message) error
- func (g *GoroutineBus) SetLog(l Log)
- func (g *GoroutineBus) Subscribe(channel string) (Subscription, error)
- func (g *GoroutineBus) Unsubscribe(sub Subscription) error
- type ListenerFunc
- type ListenerManager
- type Log
- type Loggable
- type Message
- type MessageBuffer
- type MessageBus
- type NoOpLog
- type Option
- type PollingManager
- type PubSub
- type S
- type Subscription
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTimeout = errors.New("request timeout") ErrCancelled = errors.New("request cancelled") )
View Source
var DefaultOption = Option{ Retention: 600, Timeout: 120 * time.Second, Bus: newGoroutineBus(), Buffer: newMemoryBuffer(), PubSubPrefix: pubsubPrefix, QueuePrefix: queuePrefix, Logger: &NoOpLog{}, }
View Source
var (
ErrNotSubscriber = errors.New("no subscriber")
)
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct {
// contains filtered or unexported fields
}
func NewCallback ¶
func NewCallback() Callback
type DefaultSubscription ¶
type DefaultSubscription struct { Channel string ID string // contains filtered or unexported fields }
func NewDefaultSubscription ¶
func NewDefaultSubscription(channel, id string, ch chan Message) *DefaultSubscription
func (*DefaultSubscription) Receive ¶
func (g *DefaultSubscription) Receive() <-chan Message
type EventQueue ¶
type GoPolling ¶
type GoPolling struct {
// contains filtered or unexported fields
}
func (*GoPolling) SubscribeListener ¶
func (g *GoPolling) SubscribeListener(roomID string, lf ListenerFunc)
func (*GoPolling) WaitForNotice ¶
type GoroutineBus ¶
type GoroutineBus struct {
// contains filtered or unexported fields
}
func (*GoroutineBus) Dequeue ¶
func (g *GoroutineBus) Dequeue(channel string) <-chan Event
func (*GoroutineBus) Enqueue ¶
func (g *GoroutineBus) Enqueue(channel string, t Event)
func (*GoroutineBus) SetLog ¶
func (g *GoroutineBus) SetLog(l Log)
func (*GoroutineBus) Subscribe ¶
func (g *GoroutineBus) Subscribe(channel string) (Subscription, error)
func (*GoroutineBus) Unsubscribe ¶
func (g *GoroutineBus) Unsubscribe(sub Subscription) error
type ListenerFunc ¶
type ListenerManager ¶
type ListenerManager struct {
// contains filtered or unexported fields
}
func NewListenerManager ¶
func NewListenerManager(adapter MessageBus, queuePrefix, pubsubPrefix string) ListenerManager
func (*ListenerManager) Subscribe ¶
func (m *ListenerManager) Subscribe(channel string, lf ListenerFunc)
type Log ¶
type Log interface {
Errorf(string, ...interface{})
}
Logger interface support error logging
type Message ¶
Message struct defines the payload which being sent through message bus from notifier to the waiting client
type MessageBuffer ¶
MessageBuffer define the interface use to save and fetch message
type MessageBus ¶
type MessageBus interface { PubSub EventQueue Loggable }
type Option ¶
type Option struct { // Retention period indicate the TTL time in second for the message, default 60s Retention int // Long polling client retention (default 120s) Timeout time.Duration // Message Bus Bus MessageBus // Message Buffer Buffer MessageBuffer // Logging implementation Logger Log PubSubPrefix string QueuePrefix string }
type PollingManager ¶
type PollingManager struct {
// contains filtered or unexported fields
}
func NewPollingManager ¶
func NewPollingManager(adapter MessageBus, t time.Duration, queuePrefix, pubsubPrefix string) PollingManager
func (*PollingManager) WaitForNotice ¶
type PubSub ¶
type PubSub interface { Publish(string, Message) error Subscribe(string) (Subscription, error) Unsubscribe(Subscription) error }
type Subscription ¶
type Subscription interface {
Receive() <-chan Message
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.