I'm using the gochan protocol for some internal processing of events. I've built a series of cloudevents.Client like so:
- Client
#1 listens on HTTP for events
- For each event received on
#1 we send to client #2 using a gochan.Protocol sender.
- Client
#3 is receiving from the same gochan.Protocol used in #2
- For each event received on
#3 we send to another client #4 which uses HTTP to an external target.
There's currently no way to wait until all events have finished with the current implementation of gochan.Protocol since it doesn't implement protocol.SendCloser.
You can cancel the ctx passed to client.StartReceiver(), but if you have any outstanding messages not yet received the receiver returns io.EOF as expected.
Closing the underlying channel allows StartReceiver() to continue processing all messages until eventually it returns io.EOF due to the channel being closed, and not because ctx was cancelled.
All this involves is changing gochan.Protocol to have an additional method:
func (sr *SendReceiver) Close(ctx context.Context) error {
return sr.sender.Close(ctx)
}
Is this sensible, or am I missing something?
I'm using the
gochanprotocol for some internal processing of events. I've built a series ofcloudevents.Clientlike so:#1listens on HTTP for events#1we send to client#2using agochan.Protocolsender.#3is receiving from the samegochan.Protocolused in#2#3we send to another client#4which uses HTTP to an external target.There's currently no way to wait until all events have finished with the current implementation of
gochan.Protocolsince it doesn't implementprotocol.SendCloser.You can cancel the
ctxpassed toclient.StartReceiver(), but if you have any outstanding messages not yet received the receiver returnsio.EOFas expected.Closing the underlying channel allows
StartReceiver()to continue processing all messages until eventually it returnsio.EOFdue to the channel being closed, and not becausectxwas cancelled.All this involves is changing
gochan.Protocolto have an additional method:Is this sensible, or am I missing something?