Documentation
¶
Index ¶
- Constants
- type Manager
- func (sm *Manager) HasRedis() bool
- func (sm *Manager) Publish(userID string, notification Notification) error
- func (sm *Manager) Subscribe(userID string, ch chan Notification)
- func (sm *Manager) Unsubscribe(userID string, ch chan Notification)
- func (sm *Manager) WithRedis(client *redis.Client) *Manager
- type Notification
- type RawNotification
Constants ¶
const NotificationChannelBufferSize = 10
NotificationChannelBufferSize is the buffer size for task subscription channels
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages all active subscriptions for real-time updates
func GetGlobalManager ¶ added in v0.51.0
func GetGlobalManager() *Manager
GetGlobalManager returns the global subscription manager instance
func (*Manager) HasRedis ¶ added in v1.27.4
HasRedis reports whether this manager is configured to distribute notifications across processes via redis
func (*Manager) Publish ¶
func (sm *Manager) Publish(userID string, notification Notification) error
Publish sends a notification to all subscribers for that user in this process, and, when Redis is configured, to subscribers of other processes as well
func (*Manager) Subscribe ¶
func (sm *Manager) Subscribe(userID string, ch chan Notification)
Subscribe adds a new subscriber for a user's notification creations
func (*Manager) Unsubscribe ¶
func (sm *Manager) Unsubscribe(userID string, ch chan Notification)
Unsubscribe removes a subscriber
type Notification ¶ added in v0.51.0
type Notification interface{}
Notification is an interface that represents a notification that can be published This avoids import cycles with ent/generated The ent/generated.Notification type has ID and UserID fields that satisfy this interface
type RawNotification ¶ added in v1.27.4
type RawNotification struct {
Payload []byte
}
RawNotification wraps a notification received over Redis that hasn't been unmarshaled into its concrete type yet