InternalsPackages

daemon-ably-client

daemon-ably-client

Go client library for the daemon-managed Ably transport (daemon-ably). It speaks NDJSON over a Unix domain socket and provides publish + subscribe primitives with reconnect handling.

Core Purpose

  • Keep Falco and Nagato free of direct Ably SDK usage
  • Centralize IPC framing and ACK handling for daemon-ably
  • Restore subscriptions after reconnects

Supported Operations

OperationDirectionDescription
publish.v1client → daemon-ablyPublish payloads (Falco path)
publish.ack.v1client → daemon-ablyPublish ACKs (Nagato path)
subscribe.v1client → daemon-ablySubscribe to a channel/event
message.v1daemon-ably → clientPush inbound messages

API Overview

client, err := client.New("/Users/me/.unbound/ably.sock")
if err != nil { /* ... */ }

defer client.Close()
ctx := context.Background()

if err := client.Connect(ctx); err != nil { /* ... */ }
if err := client.Publish(ctx, "session:1:conversation", "conversation.message.v1", payload, 5*time.Second); err != nil { /* ... */ }

if err := client.Subscribe(ctx, client.Subscription{
  SubscriptionID: "nagato-primary",
  Channel: "remote:device-id:commands",
  Event: "remote.command.v1",
}); err != nil { /* ... */ }

for msg := range client.Messages() {
  // msg.Payload is raw bytes
}

Reconnect Semantics

  • Client auto-reconnects with exponential backoff (max 3s).
  • Active subscriptions are replayed after reconnect.
  • In-flight requests are failed fast on disconnect.

Configuration

VariableDefaultDescription
DAEMON_ABLY_MAX_FRAME_BYTES2097152Maximum NDJSON frame size accepted from daemon-ably

Package Layout

packages/daemon-ably-client/
├── client/
│   ├── client.go        # NDJSON client + reconnect
│   └── client_test.go   # ack + reconnect tests
├── go.mod
└── README.md

Development

cd packages/daemon-ably-client
go test ./...