Skip to content

Commit 43d1787

Browse files
authored
Update ServerInHandle comments (grpc#1437)
* Update ServerInHandle comments * Include code string not code number for RST_STREAM
1 parent 7657092 commit 43d1787

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

tap/tap.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,20 @@ type Info struct {
3232
// TODO: More to be added.
3333
}
3434

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.
3951
type ServerInHandle func(ctx context.Context, info *Info) (context.Context, error)

transport/http2_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) {
955955
warningf("transport: http2Client.handleRSTStream found no mapped gRPC status for the received http2 error %v", f.ErrCode)
956956
statusCode = codes.Unknown
957957
}
958-
s.finish(status.Newf(statusCode, "stream terminated by RST_STREAM with error code: %d", f.ErrCode))
958+
s.finish(status.Newf(statusCode, "stream terminated by RST_STREAM with error code: %v", f.ErrCode))
959959
s.mu.Unlock()
960960
s.write(recvMsg{err: io.EOF})
961961
}

0 commit comments

Comments
 (0)