Skip to content

[Q] Implementation choices #5

Description

@lonix1
  1. Why use a custom JSON parser here? The modern System.Text.Json classes are highly performant.

  2. Why instantiate an HttpClient directly? The recommended approach ([1], [2]) is to delegate that to the container, and typically resolve IHttpClientFactory. That avoids all sorts of problems like network issues and IIRC a socket exhaustion problem that was prevalent a few versions back. Amongst various benefits, it allows the consumer to

    1. create a custom client and couple that with Polly for resilience
    2. create a named/typed client so logs are more descriptive and can be filtered (else all are logged as System.Net.Http.HttpClient.Default.LogicalHandler and System.Net.Http.HttpClient.Default.ClientHandler which cannot be differentiated from other HttpClient logs)
  3. I assume one should register the service thusly: services.AddSingleton<TurnstileService>()?

BTW: these are not criticisms, just curious and/or looking for advice... Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Fields

    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