local

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 8 Imported by: 0 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

Index

Constants

View Source
const PlatformID = "local"

PlatformID is the platform identifier for the local chat platform.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalPlatform

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

LocalPlatform bundles LocalReceiver and LocalSender and implements platform.Platform.

func NewPlatform

func NewPlatform(receiver *LocalReceiver, sender *LocalSender) *LocalPlatform

NewPlatform constructs a LocalPlatform from pre-built receiver and sender.

func (*LocalPlatform) ID

func (p *LocalPlatform) ID() string

func (*LocalPlatform) Receiver

func (*LocalPlatform) Sender

type LocalReceiver

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

LocalReceiver implements platform.PlatformReceiverAdapter. Messages are injected via Enqueue and dispatched to the registered handler in Start.

func NewLocalReceiver

func NewLocalReceiver(bufSize int) *LocalReceiver

NewLocalReceiver constructs a LocalReceiver with the given channel buffer size.

func (*LocalReceiver) Enqueue

func (r *LocalReceiver) Enqueue(msg platform.InboundMessage)

Enqueue adds a message to the dispatch queue. If the channel is full the message is dropped and a warning is logged.

func (*LocalReceiver) Start

func (r *LocalReceiver) Start(ctx context.Context, dispatch func(platform.InboundMessage)) error

Start blocks, dispatching each enqueued message, until ctx is cancelled. Implements platform.PlatformReceiverAdapter.

type LocalSender

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

LocalSender implements platform.PlatformSenderAdapter. It broadcasts replies to connected SSE clients via SSEHub.

func NewLocalSender

func NewLocalSender(hub *SSEHub) *LocalSender

NewLocalSender constructs a LocalSender.

func (*LocalSender) Send

Send broadcasts the reply to any connected SSE clients for the session. The session key is read from msg.ReplyTo.SessionKey.

type SSEHub

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

SSEHub manages Server-Sent Events subscriptions keyed by session key.

func NewSSEHub

func NewSSEHub() *SSEHub

NewSSEHub constructs an SSEHub.

func (*SSEHub) Broadcast

func (h *SSEHub) Broadcast(sessionKey, data string)

Broadcast sends data to all subscribers of the given session key. If a subscriber's channel is full, it is dropped with a warning.

func (*SSEHub) Subscribe

func (h *SSEHub) Subscribe(sessionKey string) (<-chan string, func())

Subscribe registers a new SSE client for the given session key. Returns the receive channel and an unsubscribe function the caller must invoke on disconnect.

Jump to

Keyboard shortcuts

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