Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Gateway gRPC

The gateway exposes a single gRPC service for SDK clients that need real-time flag definition streaming: FlagSyncService.

Service

ServiceProto packageGateway port
FlagSyncServiceflags.v150050

This is a passthrough — the gateway forwards the streaming RPC directly to stitchd-flag-service.

RPCs

SyncDefinitions

rpc SyncDefinitions(SyncRequest) returns (stream SyncResponse);

Opens a server-streaming connection. The gateway pushes the full flag/segment definition set on connect, then streams incremental updates as definitions change.

Auth: Pass the SDK key as gRPC metadata:

x-sdk-key: sdk_live_abc123...

SyncRequest fields:

FieldTypeDescription
environment_idstringEnvironment to subscribe to

SyncResponse fields:

FieldTypeDescription
flagsrepeated FlagDefinitionCurrent set of flag definitions
segmentsrepeated SegmentDefinitionCurrent set of segment definitions
sequence_numberint64Monotonically increasing sync counter

Connecting from the Rust SDK

The SDK automatically opens the streaming connection on SdkClient::connect(). You do not need to manage the gRPC channel directly.

#![allow(unused)]
fn main() {
let client = SdkClient::builder()
    .gateway("http://localhost:50050")
    .sdk_key("sdk_live_abc123")
    .build()
    .await?;
}

Connecting from Other Languages

Use any gRPC client with the flags/v1/flag_sync.proto definition. Set the x-sdk-key metadata key on the channel.

import grpc
from flags.v1 import flag_sync_pb2_grpc, flag_sync_pb2

channel = grpc.insecure_channel("localhost:50050")
stub = flag_sync_pb2_grpc.FlagSyncServiceStub(channel)
metadata = [("x-sdk-key", "sdk_live_abc123")]

for response in stub.SyncDefinitions(
    flag_sync_pb2.SyncRequest(environment_id="env-1"),
    metadata=metadata
):
    print(response)

See the gRPC Protobuf Reference for the full proto schema.