File: async.go

package info (click to toggle)
golang-github-sourcegraph-jsonrpc2 0.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 200 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 378 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)
}