client

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package client provides the Qumbed developer SDK: a simple API to publish and subscribe with channel-based message delivery and context.Context for timeouts.

Index

Constants

View Source
const (
	// DefaultMessageBuffer is the buffer size for the Messages() channel.
	DefaultMessageBuffer = 64
)

Variables

View Source
var (
	SchemaTemperature = proto.SchemaTemperature
	SchemaHumidity    = proto.SchemaHumidity
	SchemaCommand     = proto.SchemaCommand
)

Schema constants for convenience (re-export from proto).

View Source
var ErrClosed = errors.New("client closed")

ErrClosed is returned when using a client after Close.

Functions

This section is empty.

Types

type Client

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

Client is the developer-facing Qumbed client. Use Publish/Subscribe and read from Messages().

func New

func New(ctx context.Context, cfg Config) (*Client, error)

New creates a new Qumbed client. Call Subscribe to receive messages; read them from Messages().

func (*Client) Addr

func (c *Client) Addr() string

Addr returns the local QUIC listen address.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the client and closes the Messages() channel.

func (*Client) Messages

func (c *Client) Messages() <-chan ReceivedMessage

Messages returns the channel of received messages. Read until the client is closed.

func (*Client) PublicKey

func (c *Client) PublicKey() *[crypto.PublicKeySize]byte

PublicKey returns this client's public key (hex for sharing with publishers).

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, topic, schemaID string, payload []byte, recipientPub *[crypto.PublicKeySize]byte) error

Publish sends a message to a topic. Payload must match schemaID (e.g. proto.SchemaTemperature). recipientPub is the subscriber's public key for E2EE; use nil to publish to self (demo only).

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, topic, schemaID string) error

Subscribe registers for a topic and starts receiving messages on Messages(). Must be called with a non-empty RelayAddr in Config.

type Config

type Config struct {
	// Addr is the local QUIC listen address (e.g. ":0" for any port).
	Addr string
	// NodeID is a human-readable identifier for this node (e.g. "sensor-1").
	NodeID string
	// RelayAddr is the relay address (e.g. "localhost:6121"). Required for pub/sub via relay.
	RelayAddr string
	// DisableDiscovery disables mDNS (set true in containers or relay-only mode).
	DisableDiscovery bool
	// MessageBuffer sets the capacity of Messages() channel; 0 uses DefaultMessageBuffer.
	MessageBuffer int
}

Config configures the Qumbed client.

type ReceivedMessage

type ReceivedMessage struct {
	Topic   string
	Payload []byte
}

ReceivedMessage is a message delivered to the subscriber.

Jump to

Keyboard shortcuts

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