rabbitmq / rabbitmq-stream-go-client

A client library for RabbitMQ streams
MIT License
170 stars 20 forks source link

Close channels inside a `Once` and don't set channels to `nil` #249

Open Zerpet opened 1 year ago

Zerpet commented 1 year ago

https://github.com/rabbitmq/rabbitmq-stream-go-client/blob/80ec3cc3d49b88fb3f11393daa403055cba269c5/pkg/raw/client.go#L684-L697

Setting the channel to nil comes at a risk of blocking infinitely if any receiver attempts to receive.

Receiving from a nil channel blocks forever.

https://go.dev/ref/spec#Receive_operator

It probably does not block inside the smart layer, but this is an unnecesary risk, when there's another option available to achieve idempotent shutdown()