@@ -32,8 +32,20 @@ type Info struct {
32
32
// TODO: More to be added.
33
33
}
34
34
35
- // ServerInHandle defines the function which runs when a new stream is created
36
- // on the server side. Note that it is executed in the per-connection I/O goroutine(s) instead
37
- // of per-RPC goroutine. Therefore, users should NOT have any blocking/time-consuming
38
- // work in this handle. Otherwise all the RPCs would slow down.
35
+ // ServerInHandle defines the function which runs before a new stream is created
36
+ // on the server side. If it returns a non-nil error, the stream will not be
37
+ // created and a RST_STREAM will be sent back to the client with REFUSED_STREAM.
38
+ // The client will receive an RPC error "code = Unavailable, desc = stream
39
+ // terminated by RST_STREAM with error code: REFUSED_STREAM".
40
+ //
41
+ // It's intended to be used in situations where you don't want to waste the
42
+ // resources to accept the new stream (e.g. rate-limiting). And the content of
43
+ // the error will be ignored and won't be sent back to the client. For other
44
+ // general usages, please use interceptors.
45
+ //
46
+ // Note that it is executed in the per-connection I/O goroutine(s) instead of
47
+ // per-RPC goroutine. Therefore, users should NOT have any
48
+ // blocking/time-consuming work in this handle. Otherwise all the RPCs would
49
+ // slow down. Also, for the same reason, this handle won't be called
50
+ // concurrently by gRPC.
39
51
type ServerInHandle func (ctx context.Context , info * Info ) (context.Context , error )
0 commit comments