This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Replies: 2 comments 2 replies
-
|
@farzbood thanks for you feedback. Unfortunately, there is interface to make it yet. from fastapi import FastAPI
from propan.fastapi import RedisRouter
from redis.asyncio import from_url
router = RedisRouter()
router.broker._connection = from_url("redis://localhost:6379")
@router.event("test")
async def handle(msg):
print(msg)
@router.after_startup
async def test(app):
await router.broker.publish("test", "test")
app = FastAPI(lifespan=router.lifespan_context)
app.include_router(router) |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
By the way, using RedisRouter, you can patch inner broker by TestRedisBroker to test your application locally router = RedisRouter()
router.broker = TestRedisBroker(router.broker) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
How can we pass an existing Redis Connection to the RedisRouter() when using FastAPI plug-in ?
Currently it just gets a fresh url and/or host, port, db, ... to establish it's own connection.
This is needed specifically when we want to use a mock redis-server for development stage, test purposes rather than an actual instance.
In our case, such a fake-server provided by https://github.com/cunla/fakeredis-py
Keep up with outstanding work!
PEACE V
Beta Was this translation helpful? Give feedback.
All reactions