nats-io / nats.net

Full Async C# / .NET client for NATS
https://nats-io.github.io/nats.net
Apache License 2.0
233 stars 48 forks source link

Inconsistency in the use of classes and interfaces #539

Open iskandersierra opened 2 months ago

iskandersierra commented 2 months ago

Observed behavior

To use just two instances as examples:

  1. At class NatsJSContext, methods CreateStreamAsync and UpdateStreamAsync return different types:

    public async ValueTask<INatsJSStream> CreateStreamAsync(...)
    {
        // ...
        return new NatsJSStream(...);
    }
    
    public async ValueTask<NatsJSStream> UpdateStreamAsync(...)
    {
        // ...
        return new NatsJSStream(...);
    }
  2. Contructor of class NatsJSContext receives a NatsConnection instead of INatsConnection:

    public partial class NatsJSContext
    {
        public NatsJSContext(NatsConnection connection) ...
        public NatsJSContext(NatsConnection connection, NatsJSOpts opts) ...
    }

Expected behavior

Given that the team decided to use interface + class pairs for most of the concepts, I would expect that there were no parameters and return types declared with the class type, but most importantly, that there were consistency among the declarations.

Server and client version

Client Versions:

<PackageReference Include="NATS.Client.JetStream" Version="2.3.0" />
<PackageReference Include="NATS.Client.Serializers.Json" Version="2.3.0" />
<PackageReference Include="NATS.Net" Version="2.3.0" />

Server Version: irrelevant

Host environment

No response

Steps to reproduce

No response

mtmk commented 2 months ago

thank you @iskandersierra we need to fix these. see also: