Closed Codebreaker101 closed 3 years ago
Yep, the context should be the same one which Serve
accept, it's a bug. Thanks for suggestion!
It has been fixed in v0.8.0, they will be the same context and the Acceptor
method now support context.
Please upgrade to v0.8.0, feel free if you have any question. Thanks!
Currently there is not way of accesing context that was used to run rsocket server.
Motivation
Example 1 - I could inititate logger with some options that I attach to the context that is used to run rsocket server. Then I would acces the same context in my
AbstractSocket
function so I could use the same logger.Example 2 - If my abstract socket has a long running task, having cancelable context available means that I could gracefully stop the execution if the server was requested to shutdown.
Desired solution
First thing that comes to mind is to change the signature of the
OptAbstractSocket
tofunc(context.Context, *socket.AbstractRSocket)
thus having context available on every request.Considered alternatives
Use the main context when creating
AbstractSocket
.Example code