Skip to content

docs(dotnet): document PostGuardConfig.HttpClient, Timeout, and IDisposable lifetime #98

@dobby-coder

Description

@dobby-coder

The E4A.PostGuard SDK gained two new PostGuardConfig properties in encryption4all/postguard-dotnet#19 that are not covered in docs/sdk/dotnet-encryption.md:

  • HttpClient (HttpClient?, init-only). Optional caller-supplied client. When supplied, the SDK does NOT dispose it. Useful for DI scenarios.
  • Timeout (TimeSpan?, init-only). Request timeout applied to the SDK-owned client. Ignored when HttpClient is supplied (caller owns the timeout in that case).

Also: PostGuard now implements IDisposable. When the SDK creates its own client (default), pg.Dispose() disposes it; an injected client is left alone.

The internal change is that PostGuard now reuses a single long-lived HttpClient built from a SocketsHttpHandler with PooledConnectionLifetime = 2min, fixing socket exhaustion under sustained load. Callers that previously created a new PostGuard per request should be told to reuse one instance.

What to update

docs/sdk/dotnet-encryption.md:

  1. Add HttpClient and Timeout rows to the PostGuardConfig options table near the top of the file (right after Headers).
  2. Add a short "Lifetime" subsection under "Constructor" explaining that PostGuard is IDisposable, owns its own HttpClient by default (which it disposes), and that callers can inject their own client via HttpClient = ... (the SDK won't dispose injected clients). Recommend reusing a single PostGuard per process for sustained workloads.
  3. Mention that Timeout is ignored when an HttpClient is supplied.

Verify with npm run docs:build. Follow the style rules in postguard-docs/CLAUDE.md (no banned words, no em dashes, no bold inflation).

Source PR: encryption4all/postguard-dotnet#19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions