client

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package client contains the Go client used to publish to and subscribe from a local DevLogBus broker.

Index

Constants

View Source
const (
	// NetworkUnix publishes over a Unix domain socket.
	NetworkUnix = "unix"
	// NetworkTCP publishes over a TCP socket.
	NetworkTCP = "tcp"
	// DefaultSocketName is the filename used for the default Unix socket.
	DefaultSocketName = "devlogbus.sock"
	// DefaultSocketDir is the stable local directory used for the default Unix socket.
	DefaultSocketDir = "/tmp/devlogbus"
	// DefaultTCPAddress is the default loopback TCP endpoint used on Windows.
	DefaultTCPAddress = "127.0.0.1:7422"
)
View Source
const RedactedValue = "[REDACTED]"

RedactedValue is the default replacement used by redaction helpers.

Variables

This section is empty.

Functions

func DefaultEndpoint

func DefaultEndpoint() string

DefaultEndpoint returns the default local broker endpoint for this platform.

func DefaultSocketPath

func DefaultSocketPath() string

DefaultSocketPath returns the default local broker socket path.

Types

type Client

type Client struct {
	Endpoint   string
	Network    string
	Address    string
	SocketPath string
	Filter     RecordFilter
	Redactor   RecordRedactor
}

Client publishes records to and subscribes records from a DevLogBus broker.

func New

func New(endpoint string) *Client

New returns a client that uses endpoint, or the platform default endpoint when endpoint is empty. Endpoint may be a Unix socket path or host:port TCP address.

func NewWithOptions

func NewWithOptions(options Options) *Client

NewWithOptions returns a client configured for Unix or TCP transport.

func (*Client) Dial

func (c *Client) Dial(ctx context.Context) (net.Conn, error)

Dial opens a raw connection to the configured broker endpoint.

func (*Client) Expunge

func (c *Client) Expunge(ctx context.Context, source string) (int, error)

Expunge removes replay-buffer records from the broker. When source is empty, every replay-buffer record is removed.

func (*Client) OpenPublisher

func (c *Client) OpenPublisher(ctx context.Context) (*Publisher, error)

OpenPublisher opens a persistent publisher connection.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, record protocol.Record) error

Publish sends one structured record to the broker.

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, sub protocol.Subscribe) (*Subscription, error)

Subscribe opens a live subscription to broker records.

type Options

type Options struct {
	Endpoint   string
	Network    string
	Address    string
	SocketPath string
	Filter     RecordFilter
	Redactor   RecordRedactor
}

Options configures a broker client.

type Publisher

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

Publisher is a persistent broker publisher.

func (*Publisher) Close

func (p *Publisher) Close() error

Close closes the persistent publisher connection.

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, record protocol.Record) error

Publish sends one structured record over the persistent publisher connection.

type RecordFilter added in v1.3.0

type RecordFilter func(protocol.Record) bool

RecordFilter reports whether a record should be published.

func DropSources added in v1.3.0

func DropSources(sources ...string) RecordFilter

DropSources returns a filter that drops records from the listed sources.

type RecordRedactor added in v1.3.0

type RecordRedactor func(protocol.Record) protocol.Record

RecordRedactor returns the record shape that should be published.

func RedactAttrs added in v1.3.0

func RedactAttrs(keys ...string) RecordRedactor

RedactAttrs returns a redactor that replaces matching attrs with RedactedValue.

func RedactAttrsWith added in v1.3.0

func RedactAttrsWith(replacement any, keys ...string) RecordRedactor

RedactAttrsWith returns a redactor that replaces matching attrs.

type ResolvedEndpoint

type ResolvedEndpoint struct {
	Network    string
	Address    string
	SocketPath string
}

ResolvedEndpoint is a concrete broker transport endpoint.

func ParseEndpoint

func ParseEndpoint(raw string) (ResolvedEndpoint, error)

ParseEndpoint resolves a user-facing endpoint string into a transport.

func (ResolvedEndpoint) String

func (e ResolvedEndpoint) String() string

String returns the user-facing endpoint value for the resolved endpoint.

type Subscription

type Subscription struct {
	Records    <-chan protocol.Record
	Errors     <-chan error
	ReplayDone <-chan struct{}
	// contains filtered or unexported fields
}

Subscription is an active broker subscription.

func (*Subscription) Close

func (s *Subscription) Close() error

Close closes the underlying broker connection.

Jump to

Keyboard shortcuts

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