Refactoring SDK with Effect: Seeking Best Practices for Modularity and Caching
Hey! I'm building an sdk and want to use effect internally but expose an async/await layer. The idea is to have an ORM-style syntax aka.
client.service.get()
client.service.get()
as an example. Currently the structure I have is this:
Client: Is just an object with keys for each service Service: Is a
Data.TaggedClass
Data.TaggedClass
that exposes the functions a user will call Transporter/http layer: this is only a function at the moment that fetches the data from the relevant api endpoint based on which service function was called.
I want to try and refactor this into using the best practices for Effect, such as layers etc. to learn a bit more about Effect at the same time. Does anyone have any tips on what I should use for each step? I want it to be modular and easy to add a new service without having to go through multiple files just to import and set everything up correctly. I was also thinking of adding a cache to each of the services in order to cache requests to limit the usage of the api if they call the same function in quick succession.