gRPC API¶
FutureQ speaks gRPC. The server registers futureq.FutureQTopic, futureq.FutureQProducer, futureq.FutureQConsumer, and futureq.FutureQCluster. Protobuf definitions
Services overview¶
| RPC | Service | Type | Description |
|---|---|---|---|
CreateTopic |
Topic | unary | Declare a topic with optional initial subscriptions |
GetTopic |
Topic | unary | Look up a declared topic by name |
ListTopics |
Topic | unary | List declared topics in name order |
PublishStream |
Producer | bidi streaming | Publish batches of delayed messages; receive per-batch acks |
CreateSubscription |
Consumer | unary | Create durable interest, independently of worker connections |
Unsubscribe |
Consumer | unary | Remove interest and discard its pending deliveries |
Subscribe |
Consumer | bidi streaming | Receive messages for a topic/consumer group; ack over the same stream |
GetClusterInfo |
Cluster | unary | Cluster topology, leader and member metadata |
JoinCluster |
Cluster | unary | Add a node to the event shard and metadata group |
LeaveCluster |
Cluster | unary | Gracefully remove a node from the cluster |
JoinMetadata |
Cluster | unary | Add a non-voting observer to the metadata group (SDKs/brokers) |
LeaveMetadata |
Cluster | unary | Remove a metadata observer |
Topic provisioning¶
Call CreateTopic before publishing or creating subscriptions. A topic name
must be valid UTF-8, 1–255 bytes long, and free of control characters.
You can declare a topic and up to 256 initial subscriptions in one atomic RPC.
Every initial subscription sets exactly one of group_id and subscriber_id.
Repeating the request adds any missing subscriptions and keeps the generations
of active subscriptions. This example provisions an email topic with a group
that can queue jobs before its workers start.
{
"name": "email.send",
"initial_subscriptions": [
{ "group_id": "mailers" }
]
}
GetTopic returns NotFound for an undeclared name. ListTopics includes
topics without subscriptions. Use the returned next_page_token as the next
request's page_token until it is empty. The default page size is 100 and the
maximum is 256.
PublishStream¶
/futureq.FutureQProducer/PublishStream — bidi stream of PublishBatch → PublishBatchAck.
- Each
PublishBatchcarriesmessages(topic, payload, delay_ms, ttl_ms, optional indexes) and anack_level. - Each accepted batch receives one
PublishBatchAck. A rejected batch writes no messages and closes the stream with a gRPC error. - An empty batch returns a default (unsuccessful) ack and performs no write.
- Client half-close (EOF) ends the stream cleanly.
- Ack levels:
QUORUM(default; returns after quorum commit and successful admission during apply),LEADER(returns after the leader durably persists the entry with frozen destinations — see ack levels),NO_ACK(submission only, with preselected destinations). The broker'spublish.minAckLevelfloors what clients may request. - In Raft mode only the event-shard leader accepts writes; standalone always writes directly to storage with fsync.
- Destinations are frozen at publication and persisted atomically with each payload. Every active durable group or universal subscription is included, even with zero connected workers. Later subscriptions receive only future publications.
- If any topic in a batch is undeclared, the whole batch fails with
NotFound. A declared topic with no durable destinations fails withFailedPrecondition. - Quorum admission uses subscription state at the publish entry in Raft order; it needs no separate admission read. Leader and no-ACK modes select destinations before proposal using a fresh registry read. An unroutable batch writes no messages. Standalone publishes persist payload and destinations together in one synchronous batch.
CreateSubscription and Unsubscribe¶
Both RPCs take SubscriptionRequest{topic, group_id, subscriber_id}. Set exactly
one of group_id and subscriber_id; invalid identities return InvalidArgument.
CreateSubscription requires a declared topic and returns NotFound if the
topic is missing. It is idempotent while that identity exists and returns a
SubscriptionResponse including its generation and creates durable interest
without a worker connection. group_id identifies competing workers;
subscriber_id identifies an independent universal subscriber across reconnects.
Unsubscribe is idempotent and deactivates interest. The topic stays registered
when its last subscription is removed or expires. Bounded background cleanup
discards only its pending deliveries. Other subscriptions remain unaffected;
worker sends can overlap until removal is observed. Recreating the name creates
a fresh generation with no old backlog. Neither consumer disconnects nor stream
retries implicitly unsubscribe or recreate interest.
delivery.subscriptions.disconnectTimeout controls automatic unsubscribe after
all workers disconnect. Default 0s means forever. A never-connected interest
starts its timeout at creation. Connected but idle workers do not expire;
crashed connections are detected by their 15-second session leases before the
configured timeout starts. Message TTL still applies.
Subscribe¶
/futureq.FutureQConsumer/Subscribe — bidi stream of ConsumerFrame → QueueMessage.
Handshake¶
- The first frame must be
ConsumerFrame{init: SubscribeInit{topic, group_id, subscriber_id}}. - Create the durable subscription first. Missing subscriptions return
NotFound; invalid or ambiguous identities returnInvalidArgument. - The server confirms a bound generation in initial metadata (
subscription-generation). Clients must inspect terminal status if no binding header is received. - Consumers may connect to any event replica. Cluster-wide assignments and expiring ownership permits fence delivery during rebalances and partitions.
Set SubscribeInit.auto_ack = true to complete this worker's deliveries after
each successful gRPC send. The default is false (manual ACK/NACK). Auto-ack is
per connection and must be requested again on reconnect; durable subscription
creation and generation are unchanged. The server rejects auto-ack streams with
PermissionDenied unless delivery.subscriptions.allowAutoAck: true is set.
An accepting server includes subscription-auto-ack: true in initial metadata;
clients must require that confirmation before suppressing ACK/NACK frames.
On auto-ack streams both manual ACK and NACK requests are ignored. Handler errors cannot request redelivery, and successful send does not confirm application processing. Failed sends are not acknowledged. Completion uses the same batched recipient ledger and persistence retries as manual ACKs; other recipients keep their obligations. A crash before completion is committed can cause duplicates.
After registration¶
- The broker assigns a UUID and registers the consumer with the hub (buffered channel, capacity 1024).
group_idselects competing workers. Otherwisesubscriber_idselects a durable universal interest; different IDs receive independent copies, and multiple workers using one ID share its backlog.- Server → client frames are
QueueMessagewithdelivery_tag— an opaque tag the client must echo back. - Client → server frames are
AckRequest{success, delivery_tag}:success = true(ACK): the message is queued for batched deletion and becomes non-re-dispatchable.success = false(NACK): nothing is deleted; the message becomes re-dispatchable immediately.
- Any ack frame also removes the in-flight entry for that consumer. Non-ack frames after handshake are logged and skipped.
- Client EOF ends the stream cleanly; the consumer is unregistered and its in-flight keys dropped.
- Disconnect removes only the worker session. Both group and universal subscriptions retain pending deliveries; reconnect with the same topic and identity to resume.
Cluster RPCs¶
GetClusterInfo¶
- Returns
leader_node_id,leader_address, and the member list (node_id,address,is_leader). - Any node answers. On a standalone node →
NotFound; before topology is available →Unavailable. - Node addresses prefer the registered gRPC address, falling back to the Raft address.
JoinCluster¶
- Request:
node_id,raft_address,grpc_address. - Must be sent to the leader (not forwarded). Runs add-non-voting → catch-up wait (30s) → promote-to-voter on both the event shard and the metadata group.
- Failures are reported in
JoinResponse{success, error_message}without failing the RPC status.
LeaveCluster¶
Removes the node from the event shard and then the metadata group (leader, same response conventions). Afterwards the node's local Raft data can be deleted.
JoinMetadata / LeaveMetadata¶
Add/remove a non-voting observer on the metadata group only — for client SDKs or new brokers that want live topology without participating in consensus.
Security¶
Danger
The gRPC server is plaintext — no TLS and no authentication. All RPCs, including cluster membership mutations, are open on the configured listen address. Run it on a trusted network or in front of a TLS-terminating proxy.
Server tuning from config: maxConcurrentStreams (default 10), max message sizes (100KiB), keepalive (min 5s, permit-without-stream, idle 30s, max connection age 2m + 10s grace, ping 10s, timeout from api.grpc.keepaliveTimeout).