Documentation
¶
Overview ¶
Package client contains the Go client used to publish to and subscribe from a local DevLogBus broker.
Index ¶
- Constants
- func DefaultEndpoint() string
- func DefaultSocketPath() string
- type Client
- func (c *Client) Dial(ctx context.Context) (net.Conn, error)
- func (c *Client) Expunge(ctx context.Context, source string) (int, error)
- func (c *Client) OpenPublisher(ctx context.Context) (*Publisher, error)
- func (c *Client) Publish(ctx context.Context, record protocol.Record) error
- func (c *Client) Subscribe(ctx context.Context, sub protocol.Subscribe) (*Subscription, error)
- type Options
- type Publisher
- type RecordFilter
- type RecordRedactor
- type ResolvedEndpoint
- type Subscription
Constants ¶
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" )
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 ¶
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 ¶
NewWithOptions returns a client configured for Unix or TCP transport.
func (*Client) Expunge ¶
Expunge removes replay-buffer records from the broker. When source is empty, every replay-buffer record is removed.
func (*Client) OpenPublisher ¶
OpenPublisher opens a persistent publisher connection.
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.
type RecordFilter ¶ added in v1.3.0
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
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 ¶
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.