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
- Variables
- type Client
- func (c *Client) Addr() string
- func (c *Client) Close() error
- func (c *Client) Messages() <-chan ReceivedMessage
- func (c *Client) PublicKey() *[crypto.PublicKeySize]byte
- func (c *Client) Publish(ctx context.Context, topic, schemaID string, payload []byte, ...) error
- func (c *Client) Subscribe(ctx context.Context, topic, schemaID string) error
- type Config
- type ReceivedMessage
Constants ¶
const (
// DefaultMessageBuffer is the buffer size for the Messages() channel.
DefaultMessageBuffer = 64
)
Variables ¶
var ( SchemaTemperature = proto.SchemaTemperature SchemaHumidity = proto.SchemaHumidity SchemaCommand = proto.SchemaCommand )
Schema constants for convenience (re-export from proto).
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 ¶
New creates a new Qumbed client. Call Subscribe to receive messages; read them from Messages().
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).
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 ¶
ReceivedMessage is a message delivered to the subscriber.