Reputation: 421
If we use microservice architecture, ideally a single function definition should be at a single place.
So if I have a microservice containing the subscriber function.
And I want to publish an event to that subscriber from any microservice. How would I pass an instance of that function, when it is not even available in any other microservice.
with Connection(redis.from_url(redis_url)):
q = Queue(queue_name)
task = q.enqueue(func, kwargs=params)
My API server is based of flask and my scripts are a separate microservice container, below is the architecture I'm following.
cron_scripts
category1/
- script_file.py // Enqueue Redis File
category2/
flask_server
- app
- models
- routes
- tests
- utils
- queue // Defines my redis enqueue Wrapper
- tasks
- All Separate Task functions as per worker
- init (Flask Init)
Are there any better design pattern resources, for the same? Please let me know.
Update -
This repo does make sense - https://github1s.com/munisisazade/redis-pub-sub/
Any reviews?
Upvotes: 0
Views: 187