svarogclient

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosed       = errors.New("Svarog client is closed")
	ErrInvalidEntry = errors.New("invalid log entry")
)

Functions

This section is empty.

Types

type Client

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

func New

func New(options Options) (*Client, error)

New validates local configuration and starts a background publisher. It does not wait for the broker: unavailable connections retry while the queue fills.

func (*Client) Enqueue

func (c *Client) Enqueue(entry Entry) error

Enqueue waits for space in the bounded queue. Success means local acceptance, not broker or database persistence. Shutdown unblocks waiting callers. Rejections are also reported locally because slog discards handler errors.

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) error

Shutdown stops admission and waits for broker acknowledgements for accepted entries. Expiry cancels network operations and joins the publisher before returning an error. It does not wait for PostgreSQL and cannot recover entries left in memory after a timeout or process exit. Concurrent calls are safe; any caller's expired context aborts the shared drain.

type Entry

type Entry struct {
	// Message must not contain NUL. Each invalid UTF-8 byte becomes U+FFFD.
	Message string
	// A zero timestamp is set to time.Now once the entry obtains admission,
	// which can be later than the Enqueue call while producers wait.
	Timestamp time.Time
}

type Options

type Options struct {
	ConnectionString string
	// InstanceID defaults to SVAROG_INSTANCE_ID, then the hostname.
	InstanceID string
	// Diagnostics defaults to stderr. It must not feed back into this client.
	Diagnostics io.Writer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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