CorrelationId Module
Opaque per-RPC correlation identifier (feature 042 FR-009 / FR-009a). Flows across `await` boundaries via `AsyncLocal<_>`; read by `HubLog.emit` on every log entry; set by the gRPC server interceptor on every unary and streaming RPC entering `FSBar.Hub.ScriptingHub.ScriptingService`. Hub-assigned form: `Guid.NewGuid().ToString("N")`. Client-supplied form: any non-empty UTF-8 string ≤ 64 bytes, carried on the request metadata header `x-fsbar-correlation-id`. The effective ID is echoed back on the response trailer `x-fsbar-correlation-id` so clients can assert on it without a schema change to every existing response message (R3).
Types
| Type | Description |
|
Opaque value type. Carried by `HubLog.LogEntry.CorrelationId` and echoed on every unary RPC response trailer. |
|
|
Server-side gRPC interceptor. Registered globally in
`FSBar.Hub.App/Program.fs` via
`services.AddGrpc(fun o -> o.Interceptors.Add |
Functions and values
| Function or value |
Description
|
Full Usage:
HeaderName
Returns: string
|
Standard request/response metadata header. Constant: value is `"x-fsbar-correlation-id"`. Lower-case per gRPC convention.
|
Full Usage:
MaxClientSuppliedBytes
Returns: int
|
Maximum accepted client-supplied length in UTF-8 bytes. Requests exceeding this reject with gRPC `InvalidArgument`.
|
|
Current correlation ID for the logical call-flow, read from `AsyncLocal<_>`. Returns `None` outside any RPC handler or explicit `withScope`. `HubLog.emit` calls this on the post-gate path.
|
|
Generate a fresh Hub-assigned correlation ID (`Guid.NewGuid().ToString("N")`).
|
Full Usage:
tryParseClientHeader raw
Parameters:
string
Returns: Result<CorrelationId, string>
|
Try to parse a client-supplied header value. Returns `Error reason` when empty or longer than `MaxClientSuppliedBytes`.
|
|
Open an explicit correlation scope covering a block of code —
used when an RPC handler hands off background work via
`Task.Run` / `Async.StartAsTask` and wants its log entries to
retain the RPC's ID.
```fsharp
let cid = CorrelationId.current ()
Task.Run(fun () ->
use _ = CorrelationId.withScope cid
// HubLog.emit calls inside this scope carry `cid`
doWorkInBackground ()
)
```
|
FSBarV1_Archived