channels

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowList

func AllowList(allowFrom, userID string) bool

AllowList checks whether a user ID is permitted based on a comma-separated allow_from string. Returns true if allowFrom is empty or "*" (allow all), or if the userID is in the list. Comparison is case-insensitive.

func NewChannel

func NewChannel(name string, opts map[string]any) (channel.Channel, error)

NewChannel creates a new channel instance by name with the given options.

func NewMsgDedup

func NewMsgDedup() *msgDedup

NewMsgDedup creates an in-memory dedup tracker.

func RegisterChannel

func RegisterChannel(name string, factory Factory)

RegisterChannel registers a channel factory under the given name. Each channel package should call this in its init() function.

func StopAll

func StopAll()

StopAll stops all tracked channels.

func TrackChannel

func TrackChannel(key string, p channel.Channel)

TrackChannel adds a started channel to the registry with a unique key.

Types

type Dedup

type Dedup struct {
	// contains filtered or unexported fields
}

Dedup provides message deduplication using Redis.

func NewDedup

func NewDedup(rdb redis.UniversalClient) *Dedup

NewDedup creates a new Dedup instance with the given Redis client.

func (*Dedup) IsDuplicate

func (d *Dedup) IsDuplicate(ctx context.Context, ch string, msgID string) (bool, error)

IsDuplicate checks if the message ID has been seen within the TTL window. Returns true if this is a duplicate, false if it's a new message. Marks the message as seen if it's new.

type Factory

type Factory func(opts map[string]any) (channel.Channel, error)

Factory creates a channel instance from configuration options.

type HTTPRouter

type HTTPRouter interface {
	RegisterHTTPRoutes(r chi.Router, callbackPath string, handler channel.MessageHandler)
}

HTTPRouter is an optional interface for channels that support HTTP webhook callbacks. Implementations should register their GET (verification) and POST (message) handlers on the router.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages channel adapters.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL