u/Brick-Logic
Greetings people!
As the title says, I got enough of manual integrations and I wanted to use interfaces to connect to the server endpoints. Because the project grew a lot, I'm now looking for feedback in order to validate and improve it for production/industrial usage.
Yes, I tried looking for libraries that combined good developer experience, speed and free of memory leaks, but I couldn't find anything that could suffice. I wanted to call endpoints from interfaces that shared the same firm.
The idea developed a lot, and now it became a declarative framework with optional manual settings:
First, we need a Contract:
[HttpTransport]
public interface IUserContract : IControllerContract
{
[RateLimit(5)]
[HttpGet]
Task<string> TestHubcon(string message);
}
A Controller:
[Authorize(Roles:"Staff")]
[UseJwt]
public class UserController : IUserContract
{
[Authorize(Roles:"Manager")]
public async Task<string> GetUser(string id) => return "Server response";
}
Then calling it from the client using the optional Execute method:
var response = await userContract.Execute(contract => contract.GetUser("some id"));
A HubconResponse<T> example
This is the experience I built with my framework supporting HTTP and WebSockets, and specially non-invasive Native AOT support for clients due to constraints in Uno Platform 6 (Android) and Blazor projects.
The client also uses local rate limiters, uses the same declared transports in the Contract and adapts to HttpGet declared endpoints automatically. If it's in the contract, the client knows what to do.
It also supports:
- ASP.NET-like middlewares with extended context about the operation and circuit-breaker behaviour, including endpoint-scoped, controller-scoped and global middlewares.
- Native IAsyncEnumerable<T> streaming (HTTP and WebSockets)
- Ingest methods (IAsyncEnumerable<T> as parameters)
- Client-side rate limiters (and server, of course), client-side interceptors and hooks
- OpenAPI server support
- External REST integrations using contracts in clients (like OpenAI integrations)
- Integrated telemetry
- Extensible Transport and Auth providers
- Documented and debuggable code
- Painless Native AOT support for clients
- Isolated websocket clients with massive client count support
- And more.
I'm sharing this because I'm looking for feedback about the developer experience, the concept, possible improvements, the potential, possible implementations (like ChannelReader<T> and IObservable<T> support), performance metrics that would be good to see, what features it needs or lacks for a good use for production...
Any constructive feedback is welcome!
This is the repository link: https://github.com/Brick-Logic/Hubcon
It has a quick start, and a wiki with all the technical details, including performance metrics and 3 working examples.
Thank you so much in advance!