async

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: AGPL-3.0 Imports: 3 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 async provides a channel-based async event delivery interface with implementations for WebSocket, SSE, Pusher, and Ably.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncNotifier

type AsyncNotifier interface {
	// Publish sends an event to all subscribers of the given channel.
	Publish(ctx context.Context, channel string, event *Event) error
	// Close releases resources held by the notifier.
	Close() error
}

AsyncNotifier publishes events to named channels. Implementations may deliver via WebSocket, SSE, Pusher, Ably, or other backends.

type ConnectionAcceptor

type ConnectionAcceptor interface {
	// AcceptConnection upgrades an HTTP request to a persistent connection
	// and registers it under the given channel and memberID.
	// The connection is managed internally; events published to the channel
	// will be delivered to this connection.
	AcceptConnection(w http.ResponseWriter, r *http.Request, channel, memberID string) error
}

ConnectionAcceptor is an optional interface implemented by backends that require server-side HTTP connection management (WebSocket, SSE). Callers may type-assert an AsyncNotifier to ConnectionAcceptor when they need to accept inbound client connections.

type Event

type Event struct {
	Type string          `json:"type"`
	Data json.RawMessage `json:"data,omitempty"`
}

Event represents an async notification event to be published to a channel.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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