watermill
watermill copied to clipboard
add memory clean up on gochannel subscribe topics when they no longer have any more subscribers
This allows publishing and subscribing to narrowly focused topics that include random data like UUIDs in topic name. Without this change, memory usage will grow indefinitely in a long-running service as the map grows larger and larger with keys pointing to empty slices.
The change is small, but it allows using Watermill Gochannel like NATS - having a topic per HTTP request, for example.