LearnGO/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.0.0-20191222043438-96c4efab7ee2/async.go
2024-09-19 21:38:24 -04:00

18 lines
378 B
Go

package jsonrpc2
import "context"
// AsyncHandler wraps a Handler such that each request is handled in its own
// goroutine. It is a convenience wrapper.
func AsyncHandler(h Handler) Handler {
return asyncHandler{h}
}
type asyncHandler struct {
Handler
}
func (h asyncHandler) Handle(ctx context.Context, conn *Conn, req *Request) {
go h.Handler.Handle(ctx, conn, req)
}