Commit Graph

30 Commits

Author SHA1 Message Date
Jan Tattermusch ddbf6c46a6 autofix license notice 2017-06-08 14:42:19 +02:00
Menghan Li 2739967807 re-enable handler_server in end2end test, and fix some failed tests (#1259) 2017-05-26 08:26:41 -07:00
MakMukhi 72395c537b Initialize stream properly in handler_server. (#1260) 2017-05-24 11:58:17 -07:00
MakMukhi 6dff7c5f33 Expand stream's flow control in case of an active read. (#1248)
* First commit

* Imported tests from the original PR by @apolcyn.

* Formatting fixes.

* More formating fixes

* more golint

* Make logs more informative.

* post-review update

* Added test to check flow control accounts after sending large messages.

* post-review update

* Empty commit to kickstart travis.

* Post-review update.
2017-05-23 11:39:15 -07:00
Eric Drechsel 135247d85c fix server panic trying to send on stream as client disconnects #1111 (#1115) 2017-05-15 12:41:55 -07:00
dfawley b610ffd3f8 Never encode binary metadata within the metadata map (#1188)
This change ensures consistency for the user when accessing metadata values:
they are never encoded except when sent on the wire.  Previously, they would
appear encoded to client code, but not to server code.  As such, this
represents a behavior change, but one unlikely to affect user code, as it's
unusual to inspect the metadata after setting it.
2017-04-28 10:56:58 -07:00
dfawley 0c1d39df28 Separate incoming and outgoing metadata in context
This will prevent the incoming RPCs' metadata from appearing in outgoing RPCs
unless it is explicitly copied, e.g.:

incomingMD, ok := metadata.FromContext(ctx)
if ok {
  ctx = metadata.NewContext(ctx, incomingMD)
}

Fixes #1148
2017-04-07 11:54:56 -07:00
dfawley 1d27587e10 Change status package to deal with concrete types instead of interfaces (#1171) 2017-04-06 11:41:07 -07:00
dfawley b507112439 Add status package for reporting gRPC status and errors (#1156)
When an error implemented by the status package is returned from a service
handler, the server will transmit a rich status message in the
"grpc-status-details-bin" trailing metadata field if any detailed data is
attached to the error.  Client-side, we will decode them if present in the
server's response and return them to the user code performing the RPC.

This is backward compatible with the existing errors supported by the grpc
package.  However, the grpc.Errorf, grpc.Code and grpc.ErrorDesc functions for
managing errors are now deprecated; status.Errorf and status.Status type
asserions should be used instead.
2017-04-05 10:35:40 -07:00
Menghan Li 6445dedfbc fix wrong context when handling stats 2016-11-08 18:17:14 -08:00
Menghan Li 086edd7dfd Unexport transport.StreamErrorf and transport.ConnectionErrorf 2016-09-02 14:15:27 -07:00
Menghan Li f958389aff Use ConnectionErrorf instread of ConnectionError{} 2016-08-26 14:55:42 -07:00
Menghan Li 22c41c77e6 Change function names 2016-07-27 15:46:40 -07:00
Menghan Li 06d68ef151 Merge pull request #774 from iamqizhao/master
Support server graceful shutdown
2016-07-26 13:54:34 -07:00
iamqizhao f1e4d3b180 allow multiple GoAways and retrying on illegal streams 2016-07-25 16:35:32 -07:00
iamqizhao 046e606dc5 clean up 2016-07-21 18:12:01 -07:00
Menghan Li 2350c4144c Merge pull request #610 from peter-edge/percent_encoding
Do percent encoding matching grpc-java for the statusDesc
2016-07-21 11:36:23 -07:00
iamqizhao 873cc272c2 support goaway 2016-07-20 18:48:49 -07:00
Menghan Li a6bacfe42c Fix go vet 2016-06-29 13:36:10 -07:00
Menghan Li 5d7ad14de4 Rename isGrpcContentType to validContentType 2016-06-07 17:46:06 -07:00
Menghan Li 7ef3c44f78 Move isGrpcContentType to http_util.go and fix processHeaderField 2016-06-07 14:29:37 -07:00
Menghan Li 9391d1a36d Ignore plus and semicolon and anything following in Content-Type 2016-06-07 14:19:29 -07:00
Michal Witkowski eec6ad361b authority: address comments from PR 2016-05-25 11:38:25 +01:00
Michal Witkowski 1ef2c5293f fix `TestCompressOK` and client reserved HTTP header handling 2016-05-17 14:35:18 +01:00
Tamir Duberstein 9e8752e7a2 transport: allocate bigger slabs and reuse
This provides a substantial speed improvement with large payloads.

Benchmarked using https://github.com/cockroachdb/rpc-bench:

```
name                 old time/op    new time/op    delta
GRPCServeHTTP_1K-4      178µs ± 2%     177µs ± 1%     ~     (p=1.000 n=5+5)
GRPCServeHTTP_64K-4    1.30ms ± 3%    1.09ms ± 4%  -16.82%  (p=0.008 n=5+5)

name                 old speed      new speed      delta
GRPCServeHTTP_1K-4   11.5MB/s ± 2%  11.6MB/s ± 1%     ~     (p=1.000 n=5+5)
GRPCServeHTTP_64K-4   100MB/s ± 2%   121MB/s ± 4%  +20.26%  (p=0.008 n=5+5)

name                 old alloc/op   new alloc/op   delta
GRPCServeHTTP_1K-4     88.5kB ± 0%    93.9kB ± 0%   +6.16%  (p=0.008 n=5+5)
GRPCServeHTTP_64K-4     801kB ± 0%     791kB ± 0%   -1.16%  (p=0.008 n=5+5)

name                 old allocs/op  new allocs/op  delta
GRPCServeHTTP_1K-4        162 ± 0%       156 ± 0%   -3.70%  (p=0.008 n=5+5)
GRPCServeHTTP_64K-4       645 ± 0%       284 ± 0%  -55.96%  (p=0.016 n=5+4)
```
2016-03-29 05:29:55 -04:00
Peter Edge 2c4841f18d Do percent encoding matching grpc-java for the statusDesc.
Signed-off-by: Peter Edge <peter.edge@gmail.com>
2016-03-28 23:54:47 +02:00
Victor Vieux 047af78181 fix a few typos 2016-03-16 16:40:16 -07:00
Brad Fitzpatrick 110fd99e30 Fix crashes where transports returned errors unhandled by the message parser.
The http.Handler-based transport body reader was returning error types
not understood by the recvMsg parser. See #557 for some background and
examples.

Fix the http.Handler transport and add tests. I copied in a subset of
the http2 package's serverTest type, adapted slightly to work with
grpc. In the process of adding tests, I discovered that
ErrUnexpectedEOF was also not handled by the regular server
transport. Document the rules and fix that crash as well.

Unrelated stuff in this CL:

* make tests listen on localhost:0 instead of :0, to avoid Mac firewall
  pop-up dialogs.

* rename parser.s field to parser.r, to be more idiomatic that it's an
  io.Reader and not anything fancier. (it's not acting like type
  stream, even if that's the typical concrete type)

* move 5 byte temp buffer into parser, rather than allocating it for
  each new message. (drop in the bucket improvement in garbage; more
  to do later)

* rename http2RSTErrConvTab to http2ErrConvTab, per Qi's earlier
  CL. Also add the HTTP/1.1-required error mapping for completeness,
  not that it should ever arise with gRPC, also per Qi's earlier CL
  referenced in #557.
2016-02-24 15:09:17 -08:00
Brad Fitzpatrick d2d9c0a73a Fix flakiness of TestCancelNoIO with http.Handler-based server transport.
It wasn't closing the recvBuffer body in all cases during shutdown.

This change also:

* adds a new test with concurrent streams doing their own serial sends.
  This test was part of earlier debugging, but exists now to add more
  test coverage around concurrency.

* starts a cleanup of the end2end testing code, to be continued later.
  but the cleanup was necessary when writing the new test to be clean
  and not add more positional parameters.

* documents the concurrency expectations of the ServerTransport
  interface, cleaning up some other nearby documentation in the
  process.

* speeds up TestCancelNoIO to cancel some contexts once no longer
  needed, adding some comments about what the test is doing, adds some
  TODOs, and reduces some overly-long sleeps.
2016-02-12 23:24:53 +00:00
Brad Fitzpatrick 7346c871b0 Add a ServeHTTP method to *grpc.Server
This adds new http.Handler-based ServerTransport in the process,
reusing the HTTP/2 server code in x/net/http2 or Go 1.6+.

All end2end tests pass with this new ServerTransport.

Fixes grpc/grpc-go#75

Also:
Updates grpc/grpc-go#495 (lets user fix it with middleware in front)
Updates grpc/grpc-go#468 (x/net/http2 validates)
Updates grpc/grpc-go#147 (possible with x/net/http2)
Updates grpc/grpc-go#104 (x/net/http2 does this)
2016-02-12 00:16:28 +00:00