Documentation
¶
Overview ¶
Package notify provides PostgreSQL LISTEN/NOTIFY functionality for real-time notifications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener manages PostgreSQL LISTEN/NOTIFY connections.
func NewListener ¶
func NewListener(connString string, opts ...ListenerOption) *Listener
NewListener creates a new PostgreSQL notification listener.
func (*Listener) OnNotification ¶
func (l *Listener) OnNotification(channel NotifyChannel, handler NotificationHandler)
OnNotification registers a handler for a notification channel. Multiple handlers can be registered for the same channel.
type ListenerOption ¶
type ListenerOption func(*Listener)
ListenerOption configures a Listener.
func WithReconnectDelay ¶
func WithReconnectDelay(d time.Duration) ListenerOption
WithReconnectDelay sets the delay before reconnecting after a connection failure.
type NotificationHandler ¶
type NotificationHandler func(ctx context.Context, channel NotifyChannel, payload string)
NotificationHandler is a callback function that handles notifications.
type NotifyChannel ¶
type NotifyChannel string
NotifyChannel represents a PostgreSQL notification channel name.
const ( // ChannelWorkflowClosed wakes clients awaiting terminal results. ChannelWorkflowClosed NotifyChannel = "workflow_closed" // ChannelActivityTask wakes workers when activity work becomes available. ChannelActivityTask NotifyChannel = "workflow_activity_task" // ChannelWorkflowResumable is notified when a workflow becomes resumable. ChannelWorkflowResumable NotifyChannel = "workflow_resumable" // ChannelTimerExpired is notified when a timer is registered. ChannelTimerExpired NotifyChannel = "workflow_timer_expired" )
func AllChannels ¶
func AllChannels() []NotifyChannel
AllChannels returns all notification channels.
type TimerNotification ¶
type TimerNotification struct {
InstanceID string `json:"instance_id"`
TimerID string `json:"timer_id"`
ExpiresAt string `json:"expires_at,omitempty"`
}
TimerNotification is the payload for timer expired notifications.
func ParseTimerNotification ¶
func ParseTimerNotification(payload string) (*TimerNotification, error)
ParseTimerNotification parses a timer notification payload.
type WorkflowNotification ¶
type WorkflowNotification struct {
InstanceID string `json:"instance_id"`
WorkflowName string `json:"workflow_name,omitempty"`
}
WorkflowNotification is the payload for workflow resumable notifications.
func ParseWorkflowNotification ¶
func ParseWorkflowNotification(payload string) (*WorkflowNotification, error)
ParseWorkflowNotification parses a workflow notification payload.