nats-io / nats.ex

Elixir client for NATS, the cloud native messaging system. https://nats.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cleanup Subscriptions on unsub

mmmries opened this issue · comments

When a client calls sub we record a mapping entry to map their sid to the receivers address (ie where we will deliver the messages). When a client calls unsub, we should remove this mapping. Also if a client calls unsub with max_messages: 1, we should automatically cleanup the mapping of sid => pid.

In the request/response flow we generate a new subscription for every request and failure to cleanup these subscriptions will result in a memory leak.