eventstream

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: AGPL-3.0 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

This section is empty.

Variables

This section is empty.

Functions

func WriteEvent

func WriteEvent(w io.Writer, e *Event) error

WriteEvent writes an event to a writer.

Types

type Client

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

Client connects to a remote event stream broker on port 1002.

func Subscribe

func Subscribe(d *driver.Driver, addr protocol.Addr, topic string) (*Client, error)

Subscribe connects to the event stream and subscribes to a topic. Use "*" to subscribe to all events.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection.

func (*Client) Publish

func (c *Client) Publish(topic string, payload []byte) error

Publish sends an event to the broker for distribution.

func (*Client) Recv

func (c *Client) Recv() (*Event, error)

Recv waits for the next event from the broker.

type Event

type Event struct {
	Topic   string
	Payload []byte
}

Event is a typed message published to the event stream. Wire format: [2-byte topic length][topic][4-byte payload length][payload]

func ReadEvent

func ReadEvent(r io.Reader) (*Event, error)

ReadEvent reads an event from a reader.

type Server

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

Server is a pub/sub event broker on port 1002. Clients connect, subscribe to topics, and publish events. The first event from a client is treated as a subscription: - Topic "*" subscribes to all events - Any other topic subscribes to that specific topic Subsequent events are published to all matching subscribers.

func NewServer

func NewServer(d *driver.Driver) *Server

NewServer creates an event stream server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe binds port 1002 and starts the broker.

Jump to

Keyboard shortcuts

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