Skip to content

Commit

Permalink
🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
cl0ete committed Nov 5, 2024
1 parent dfdb689 commit 12ad350
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions shared/services/nats_jetstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ async def init_nats_client() -> AsyncGenerator[JetStreamContext, Any]:

connect_kwargs = {
"servers": [NATS_SERVER],
"reconnect_time_wait": 0.5, # Shorter wait time for faster reconnection
"max_reconnect_attempts": -1, # Infinite reconnection attempts
"reconnect_time_wait": 0.5, # Shorter wait time for faster reconnection
"max_reconnect_attempts": -1, # Infinite reconnection attempts
"error_cb": error_callback,
"disconnected_cb": disconnected_callback,
"reconnected_cb": reconnected_callback,
Expand Down Expand Up @@ -58,14 +58,18 @@ async def init_nats_client() -> AsyncGenerator[JetStreamContext, Any]:
await nats_client.close()
logger.debug("NATS connection closed")


async def error_callback(e):
logger.error("NATS error: {}", str(e))


async def disconnected_callback():
logger.warning("Disconnected from NATS server")


async def reconnected_callback():
logger.info("Reconnected to NATS server")


async def closed_callback():
logger.warning("NATS connection closed")

0 comments on commit 12ad350

Please sign in to comment.