Documentation
¶
Index ¶
- Constants
- Variables
- func EventKey(event *livekit.WebhookEvent) string
- func IncDispatchDrop(reason string)
- func IncDispatchFailure()
- func IncDispatchSuccess()
- func InitWebhookStats(constLabels prometheus.Labels)
- func Receive(r *http.Request, provider auth.KeyProvider) ([]byte, error)
- func ReceiveWebhookEvent(r *http.Request, provider auth.KeyProvider) (*livekit.WebhookEvent, error)
- func RecordQueueLength(queueLength int)
- type DefaultNotifier
- func (n *DefaultNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
- func (n *DefaultNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
- func (n *DefaultNotifier) SetFilter(params FilterParams)
- func (n *DefaultNotifier) SetKeys(apiKey, apiSecret string)
- func (n *DefaultNotifier) Stop(force bool)
- type FilterParams
- type HTTPClientParams
- type NotifyOption
- type NotifyParams
- type QueuedNotifier
- type ResourceURLNotifier
- func (r *ResourceURLNotifier) IsAllowed(event string) bool
- func (r *ResourceURLNotifier) Process(ctx context.Context, queuedAt time.Time, event *livekit.WebhookEvent, ...)
- func (r *ResourceURLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
- func (r *ResourceURLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
- func (r *ResourceURLNotifier) SetFilter(params FilterParams)
- func (r *ResourceURLNotifier) SetKeys(apiKey, apiSecret string)
- func (r *ResourceURLNotifier) Stop(force bool)
- type ResourceURLNotifierConfig
- type ResourceURLNotifierParams
- type URLNotifier
- func (n *URLNotifier) IsAllowed(event string) bool
- func (n *URLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
- func (n *URLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
- func (n *URLNotifier) SetFilter(params FilterParams)
- func (n *URLNotifier) SetKeys(apiKey, apiSecret string)
- func (n *URLNotifier) Stop(force bool)
- type URLNotifierConfig
- type URLNotifierParams
- type WebHookConfig
Constants ¶
const ( EventRoomStarted = "room_started" EventRoomFinished = "room_finished" EventParticipantJoined = "participant_joined" EventParticipantLeft = "participant_left" EventParticipantConnectionAborted = "participant_connection_aborted" EventTrackPublished = "track_published" EventTrackUnpublished = "track_unpublished" EventTrackMuted = "track_muted" EventTrackUnmuted = "track_unmuted" EventEgressStarted = "egress_started" EventEgressUpdated = "egress_updated" EventEgressEnded = "egress_ended" EventIngressStarted = "ingress_started" EventIngressEnded = "ingress_ended" )
Variables ¶
var ( ErrNoAuthHeader = errors.New("authorization header could not be found") ErrSecretNotFound = errors.New("API secret could not be found") ErrInvalidChecksum = errors.New("could not verify authenticity of message") )
var DefaultResourceURLNotifierConfig = ResourceURLNotifierConfig{ MaxAge: 30 * time.Second, MaxDepth: 200, }
var DefaultURLNotifierConfig = URLNotifierConfig{
NumWorkers: 10,
QueueSize: 100,
}
var DefaultWebHookConfig = WebHookConfig{ URLNotifier: DefaultURLNotifierConfig, ResourceURLNotifier: DefaultResourceURLNotifierConfig, FilterParams: FilterParams{}, }
Functions ¶
func EventKey ¶
func EventKey(event *livekit.WebhookEvent) string
func IncDispatchDrop ¶
func IncDispatchDrop(reason string)
func IncDispatchFailure ¶
func IncDispatchFailure()
func IncDispatchSuccess ¶
func IncDispatchSuccess()
func InitWebhookStats ¶
func InitWebhookStats(constLabels prometheus.Labels)
func Receive ¶
Receive reads and verifies incoming webhook is signed with key/secret pair closes body after reading
func ReceiveWebhookEvent ¶
func ReceiveWebhookEvent(r *http.Request, provider auth.KeyProvider) (*livekit.WebhookEvent, error)
ReceiveWebhookEvent reads and verifies incoming webhook, and returns a parsed WebhookEvent
func RecordQueueLength ¶
func RecordQueueLength(queueLength int)
Types ¶
type DefaultNotifier ¶
type DefaultNotifier struct {
// contains filtered or unexported fields
}
func (*DefaultNotifier) QueueNotify ¶
func (n *DefaultNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
func (*DefaultNotifier) RegisterProcessedHook ¶
func (n *DefaultNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
func (*DefaultNotifier) SetFilter ¶
func (n *DefaultNotifier) SetFilter(params FilterParams)
func (*DefaultNotifier) SetKeys ¶
func (n *DefaultNotifier) SetKeys(apiKey, apiSecret string)
func (*DefaultNotifier) Stop ¶
func (n *DefaultNotifier) Stop(force bool)
type FilterParams ¶
type HTTPClientParams ¶
type NotifyOption ¶
type NotifyOption func(*NotifyParams)
func WithExtraWebhooks ¶
func WithExtraWebhooks(wh []*livekit.WebhookConfig) NotifyOption
func WithSecret ¶
func WithSecret(secret string) NotifyOption
type NotifyParams ¶
type NotifyParams struct {
ExtraWebhooks []*livekit.WebhookConfig
Secret string
}
type QueuedNotifier ¶
type QueuedNotifier interface {
RegisterProcessedHook(f func(ctx context.Context, whi *livekit.WebhookInfo))
SetKeys(apiKey, apiSecret string)
SetFilter(params FilterParams)
QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
Stop(force bool)
}
func NewDefaultNotifier ¶
func NewDefaultNotifier(config WebHookConfig, kp auth.KeyProvider) (QueuedNotifier, error)
type ResourceURLNotifier ¶
type ResourceURLNotifier struct {
// contains filtered or unexported fields
}
ResourceURLNotifier is a QueuedNotifier that sends a POST request to a Webhook URL. It queues up events per resource (could be egress, ingress, room, participant, track, etc.) to avoid blocking events of one resource blocking another resource's event(s). It will retry on failure, and will drop events if notification fall too far behind, either in age or queue depth.
func NewResourceURLNotifier ¶
func NewResourceURLNotifier(params ResourceURLNotifierParams) *ResourceURLNotifier
func (*ResourceURLNotifier) IsAllowed ¶
func (r *ResourceURLNotifier) IsAllowed(event string) bool
func (*ResourceURLNotifier) Process ¶
func (r *ResourceURLNotifier) Process( ctx context.Context, queuedAt time.Time, event *livekit.WebhookEvent, params *ResourceURLNotifierParams, qLen int, )
poster interface
func (*ResourceURLNotifier) QueueNotify ¶
func (r *ResourceURLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
func (*ResourceURLNotifier) RegisterProcessedHook ¶
func (r *ResourceURLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
func (*ResourceURLNotifier) SetFilter ¶
func (r *ResourceURLNotifier) SetFilter(params FilterParams)
func (*ResourceURLNotifier) SetKeys ¶
func (r *ResourceURLNotifier) SetKeys(apiKey, apiSecret string)
func (*ResourceURLNotifier) Stop ¶
func (r *ResourceURLNotifier) Stop(force bool)
type ResourceURLNotifierParams ¶
type ResourceURLNotifierParams struct {
HTTPClientParams
Logger logger.Logger
Timeout time.Duration
Config ResourceURLNotifierConfig
URL string
APIKey string
APISecret string
FieldsHook func(whi *livekit.WebhookInfo)
EventKey func(event *livekit.WebhookEvent) string
FilterParams
}
type URLNotifier ¶
type URLNotifier struct {
// contains filtered or unexported fields
}
URLNotifier is a QueuedNotifier that sends a POST request to a Webhook URL. It will retry on failure, and will drop events if notification fall too far behind
func NewURLNotifier ¶
func NewURLNotifier(params URLNotifierParams) *URLNotifier
func (*URLNotifier) IsAllowed ¶
func (n *URLNotifier) IsAllowed(event string) bool
func (*URLNotifier) QueueNotify ¶
func (n *URLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error
func (*URLNotifier) RegisterProcessedHook ¶
func (n *URLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))
func (*URLNotifier) SetFilter ¶
func (n *URLNotifier) SetFilter(params FilterParams)
func (*URLNotifier) SetKeys ¶
func (n *URLNotifier) SetKeys(apiKey, apiSecret string)
func (*URLNotifier) Stop ¶
func (n *URLNotifier) Stop(force bool)
type URLNotifierConfig ¶
type URLNotifierParams ¶
type URLNotifierParams struct {
HTTPClientParams
Logger logger.Logger
Config URLNotifierConfig
URL string
APIKey string
APISecret string
FieldsHook func(whi *livekit.WebhookInfo)
EventKey func(event *livekit.WebhookEvent) string
FilterParams
}
type WebHookConfig ¶
type WebHookConfig struct {
URLs []string `yaml:"urls,omitempty"`
APIKey string `yaml:"api_key,omitempty"`
URLNotifier URLNotifierConfig `yaml:"url_notifier,omitempty"`
ResourceURLNotifier ResourceURLNotifierConfig `yaml:"resource_url_notifier,omitempty"`
FilterParams FilterParams `yaml:"filter_params,omitempty"`
}