You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The context.Context passed to Handler.Handle or Preempter.Preempt is not canceled when the connection is closed. Each async (long-running) handler has to monitor the end of the connection by itself to stop running when this happens.
The goal of this proposal is to mimic net/http.Server.ConnContext and so to allow the user to provide its own context.Context derived from the "server" one.
To be backward compatible, a new ConnContext field can be added to ConnectionOptions as:
// ConnectionOptions holds the options for new connections.typeConnectionOptionsstruct {
…
// ConnContext optionally specifies a function that modifies// the context used for a new connection conn.ConnContextfunc(ctx context.Context, conn*Connection) context.Context
}
This function will then be called in newConnection just after Binder.Bind is called as:
options, err := binder.Bind(ctx, c)
if err != nil {
return nil, err
}
+ if options.ConnContext != nil {+ ctx = options.ConnContext(ctx, c)+ if ctx == nil {+ panic("ConnContext returned nil")+ }+ }
if options.Framer == nil {
The text was updated successfully, but these errors were encountered:
The
context.Context
passed toHandler.Handle
orPreempter.Preempt
is not canceled when the connection is closed. Each async (long-running) handler has to monitor the end of the connection by itself to stop running when this happens.The goal of this proposal is to mimic
net/http.Server.ConnContext
and so to allow the user to provide its owncontext.Context
derived from the "server" one.To be backward compatible, a new
ConnContext
field can be added toConnectionOptions
as:This function will then be called in
newConnection
just afterBinder.Bind
is called as:The text was updated successfully, but these errors were encountered: