broadcast

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package broadcast captures events an app sends to a Pusher-compatible server (Laravel Reverb, Pusher, soketi) over the Pusher HTTP API: POST /apps/{app_id}/events and /batch_events. Point the app's REVERB_HOST / PUSHER_HOST at Buggregator; each event becomes a card with its channels and data. With an upstream set, the same request also goes to the real server, so browsers still get the events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Upstream is the real Pusher-compatible server (e.g. http://127.0.0.1:8080
	// for Reverb). Empty: capture only, the app gets {} back.
	Upstream string
	// Secrets maps an app key to its secret, to check request signatures.
	// A key with no secret is not checked.
	Secrets map[string]string
	// Timeout bounds a forward; default 5 s.
	Timeout time.Duration
}

Config is the module's settings.

type Event

type Event struct {
	AppID     string          `json:"app_id"`
	Name      string          `json:"name"`
	Channels  []string        `json:"channels"`
	Kinds     []string        `json:"channel_kinds"` // per channel: public, private, presence, encrypted, user
	Data      string          `json:"data"`          // as sent: a string, JSON in most apps
	DataJSON  json.RawMessage `json:"data_json,omitempty"`
	Encrypted bool            `json:"encrypted,omitempty"` // private-encrypted-*: data is ciphertext
	SocketID  string          `json:"socket_id,omitempty"` // sent to everyone but this socket (toOthers)
	Info      string          `json:"info,omitempty"`
	AuthKey   string          `json:"auth_key,omitempty"`
	Signature string          `json:"signature"` // valid, invalid or not_checked
	Size      int             `json:"size"`      // bytes of data
	Warnings  []string        `json:"warnings"`
	Library   string          `json:"library,omitempty"` // X-Pusher-Library
	BatchID   string          `json:"batch_id,omitempty"`
	BatchSize int             `json:"batch_size,omitempty"`
	Upstream  *Upstream       `json:"upstream,omitempty"`
}

Event is one stored broadcast event.

type EventStorer

type EventStorer interface {
	HandleIncoming(ctx context.Context, inc *event.Incoming) error
}

EventStorer stores one event: a batch request makes several.

type Module

type Module struct {
	module.BaseModule
	// contains filtered or unexported fields
}

Module is the broadcast events catcher.

func New

func New(cfg Config) *Module

New returns the module.

func (*Module) HTTPHandler

func (m *Module) HTTPHandler() module.HTTPIngestionHandler

func (*Module) Name

func (m *Module) Name() string

func (*Module) PreviewMapper

func (m *Module) PreviewMapper() event.PreviewMapper

func (*Module) SetEventService

func (m *Module) SetEventService(es EventStorer)

SetEventService sets where the events go.

func (*Module) Type

func (m *Module) Type() string

type Upstream

type Upstream struct {
	URL    string `json:"url"`
	Status int    `json:"status,omitempty"`
	TimeMs int64  `json:"time_ms"`
	Error  string `json:"error,omitempty"`
}

Upstream is the result of forwarding the request to the real server.

Jump to

Keyboard shortcuts

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