Skip to main content

Live updates (WebSockets)

The Go SDK can listen for real-time updates so new definitions are applied quickly.

Enable​

client, err := toggly.NewClient(toggly.Config{
AppKey: "YOUR_APP_KEY",
Environment: "Production",
EnableLiveUpdates: true,
})

How it works​

The SDK connects directly to the definitions worker:

wss://{baseURL}/{appKey}/ws?rev={cachedRevision}

When a cached definitions revision is available, it is sent as the rev query parameter. On connect the worker responds with a sync message. The SDK fetches definitions only when the revision changed or no cached revision exists.

Update messages:

MessageSDK action
sync + unchanged: trueStore revision, no fetch
sync without unchangedFetch if revision differs or no cache
flags-updatedFetch if etag differs (debounced)
signing-key-updatedForce JWKS + definitions refresh

Legacy plain-text update messages are still handled for backward compatibility.

Live updates are an acceleration mechanism; the background refresh loop still provides eventual consistency when WebSocket is disconnected.

See WebSocket sync (client-side) for the full protocol shared across SDKs.