fix(pkg/bus):return correct boolean signal when channel is closed

This commit is contained in:
ItsT0ng 2026-02-27 20:52:12 +11:00
parent 438f764c7a
commit f63a609601

View file

@ -32,8 +32,8 @@ func (mb *MessageBus) PublishInbound(msg InboundMessage) {
func (mb *MessageBus) ConsumeInbound(ctx context.Context) (InboundMessage, bool) { func (mb *MessageBus) ConsumeInbound(ctx context.Context) (InboundMessage, bool) {
select { select {
case msg := <-mb.inbound: case msg, ok := <-mb.inbound:
return msg, true return msg, ok
case <-ctx.Done(): case <-ctx.Done():
return InboundMessage{}, false return InboundMessage{}, false
} }
@ -50,8 +50,8 @@ func (mb *MessageBus) PublishOutbound(msg OutboundMessage) {
func (mb *MessageBus) SubscribeOutbound(ctx context.Context) (OutboundMessage, bool) { func (mb *MessageBus) SubscribeOutbound(ctx context.Context) (OutboundMessage, bool) {
select { select {
case msg := <-mb.outbound: case msg, ok := <-mb.outbound:
return msg, true return msg, ok
case <-ctx.Done(): case <-ctx.Done():
return OutboundMessage{}, false return OutboundMessage{}, false
} }