gateway

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package gateway turns permitted Discord messages into events on the bus.

It is the whole of what spec 0019 D2 asks the gateway to be: read, filter, publish, and do no work that can block. The filtering is the pump's; this is the publish.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	PublishValue(
		ctx context.Context, subject, eventType string, v any, opts ...messaging.PublishOption,
	) error
}

Bus is the narrow slice of the message bus this package needs.

An interface rather than *messaging.Bus so the publish can be tested without standing one up, and so this package declares its dependency rather than inheriting the whole surface.

type Option

type Option func(*Publisher)

Option configures a Publisher.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets the logger.

type Publisher

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

Publisher is an ingest.Handler that publishes what the pump admits.

func New

func New(bus Bus, opts ...Option) *Publisher

New builds a Publisher over the bus.

func (*Publisher) Failed

func (p *Publisher) Failed() int64

Failed counts messages and votes that did not, which the bus never sees and so never counts.

func (*Publisher) Handle

func (p *Publisher) Handle(ctx context.Context, space comms.ID, msg comms.Message)

Handle publishes one message. It satisfies ingest.Handler.

That signature returns nothing, so a failed publish cannot propagate: it is a drop before the bus, where none of the bus's own accounting applies, and it is counted here or it is counted nowhere (0019 D2).

func (*Publisher) HandleReaction added in v0.9.0

func (p *Publisher) HandleReaction(ctx context.Context, space comms.ID, r comms.Reaction)

HandleReaction publishes a feedback vote, and drops anything else before the bus (spec 0027 D1). A failure is counted, as Handle's is.

func (*Publisher) Published

func (p *Publisher) Published() int64

Published counts messages and votes that reached the bus.

Jump to

Keyboard shortcuts

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