Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“Fan out” services? #745

Open
mollerhoj opened this issue Aug 18, 2023 · 3 comments
Open

“Fan out” services? #745

mollerhoj opened this issue Aug 18, 2023 · 3 comments

Comments

@mollerhoj
Copy link

Hi guys, great library. I’m still a young rustacean, but I recognise this pattern from other ecosystems. (It’s excellent for ETL work btw).

I thought I’d share a few ideas for services that I’ve found to be useful in the real world. I’d be grateful if you’d tell me if some has already implemented them, or if you’d consider them to be included in the main library.

One thing I’ve found particularly useful is the ability to write the equivalent of a Service thats “fans out” a request into multiple requests.

A few examples from the real world (a scary place btw).

  • Upon receiving a “token expired” from an api, send another request (to get a new temporary token) then retry.

  • Upon receiving a “request requires too much for our servers” error response:

  • a) mutate the current request (ask for less data) or

  • b) split request into multiple other requests, each asking for less data, and fire them in parallel or sequentially.

  • even before sending a request, split it up into multiple requests, and fire in parallel or sequentially.

I know this business logic could be built outside of tower services, but it’s really nice to have it as composable services + I reach for these solutions again and again.

I imagine the business logic could be give to the services as clojures, to have them remain generic.

I know this issue is more of the “open discussion” kind, but I couldn’t see any other forum, so I hope you’ll bear with me.

@GlenDC
Copy link

GlenDC commented Dec 5, 2023

I believe this is better discussed interactively over a Discord or so.

Specific to your suggestion I believe it would help others to engage if you can give a full example using the current tower libraries as-is. And thus implement one such prime example outside of tower. This would give an idea and a starting point to talk beyond this abstract proposal.

I'm saying because as it is written down it can still go many directions and it is very easily to start talking next to one another. An example (or examples) as a starting point with real working code would help a lot to move this forward, if it to ever move forward at all.

@seanmonstar
Copy link
Collaborator

(FWIW, I prefer discussion on issues since it's easier to find again, and chat tends to encourage faster less thought out replies.)

@GlenDC
Copy link

GlenDC commented Dec 5, 2023

I like a combination, where you can have quick thoughts exchanges over chat, and then write summaries and more thought out replies in issue based on those new insights.

But I'm fine with any style that you as a maintainer prefer. So ok, cool, let's do it like that! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants