66 Commits

Author SHA1 Message Date
794873f0a2 Added calloption to retrieve peer information 2017-02-07 10:41:32 -08:00
6e0ace39fe Change max message size fields from uint64 to uint32. 2017-01-26 14:43:08 -08:00
325a0c2061 Update comment. 2017-01-09 12:59:10 -08:00
09aecb094e Add the initial service config support (#1009)
* Add the initial service config support

* start scWatcher later

* remove timeoutCh

* address the comments

* deal with dial timeout

* defer cancel for the newly created context for correct lifetime management

* fix the defer order

* added other 2 missing cancels
2016-12-19 16:31:00 -08:00
3f9a96ea71 move inPayload.RecvTime to after unmarshal 2016-11-07 16:29:25 -08:00
5938492b60 fix comments 2016-11-07 15:16:52 -08:00
a4edc462a2 renaming 2016-11-07 15:16:52 -08:00
c698588285 Renaming types and variables 2016-11-07 15:16:52 -08:00
1054f1c42b add payload with original type to payload stats 2016-11-07 15:16:52 -08:00
17ee5a3637 Add package stats, and export stats on server side. 2016-11-07 15:16:52 -08:00
727a60e4d1 update server reflection code to comply with the change to the grpc generator 2016-10-21 18:06:55 -07:00
5e734ab23e Avoid creating transport stream error outside of transport 2016-09-02 11:57:42 -07:00
fc500c24f6 fix go vet error 2016-07-29 18:08:00 -07:00
b13920a0cf add the mem alloc guard on server 2016-07-29 16:19:20 -07:00
8c908a8c1d Reject over-sized requests on server 2016-07-26 16:44:49 -07:00
ffdfb592e8 Fix type assertion error after rebase 2016-07-08 10:35:38 -07:00
3802318f46 Make Errorf return pointer to rpcError 2016-07-08 10:28:36 -07:00
be59d023f2 refactor error handling a bit 2016-06-29 15:21:44 -07:00
213a20c4fe bug fix, typo fix and slight error refactoring 2016-06-28 16:08:19 -07:00
01ef81a4d9 minor fix including removal of debugging logs, error code fix, etc. 2016-06-27 15:30:20 -07:00
3e71fb360d Support fail-fast mode and make it the default 2016-06-27 14:36:59 -07:00
cf04b299b7 Change SupportPackageIsVersion variable 2016-06-10 11:48:20 -07:00
487ada6517 Fixed typos in docstrings 2016-06-07 12:01:07 +01:00
e0f9f26e85 remove the checking of empty string for recvCompress 2016-05-11 11:01:26 -07:00
b506f13d5b change the error code when the required decompressor is not installed 2016-05-11 10:46:23 -07:00
113bf2f219 Change some compression related error code 2016-05-10 13:54:10 -07:00
61e92eacc3 Phase 1 to add the server interceptor 2016-04-18 16:18:34 -07:00
d07d0562ff Merge pull request #601 from stevvooe/backoff-strategy
backoff: allow configuration of backoff strategy
2016-04-11 10:32:33 -07:00
47b74a63a8 backoff: allow configuration of backoff strategy
The backoff function and parameters have been pulled up into an
interface `backoffStrategy`. The default parameters are now part of a
package variable `DefaultBackoffConfig`. The strategy is then plumbed
through `dialOptions`. As a result of this PR, the
maximum backoff delay can now be set using the `WithBackoffConfig` dial
option.

While the addition of strategy may seem premature, this allows one to
simply export `BackoffStrategy` and `WithBackoff` to allow arbirarily
configurable backoff strategies.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-04-07 20:17:57 -07:00
71e3dbec56 Use ErrorDetail() to provide better error msg for malformed HTTP2 2016-03-28 11:34:29 -07:00
710dbc764f Prepare for adding a compatibility marker to proto generated code.
This will assert at build time that the generated code is compatible
with the grpc package that it is linked to. A future change in the
grpc plugin for protoc-gen-go will generate a line like
	const _ = grpc.SupportPackageIsVersion1

This constant will be renamed in the future when incompatible changes
are made that require synchronised updates to grpc and protoc-gen-go.
2016-03-07 10:12:28 +11:00
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
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
af8888dc8d remove Compressor/DecompressorGenerator 2016-01-29 14:38:20 -08:00
61d7c39d4c comments and gofmt 2016-01-25 11:18:41 -08:00
da3bb0c9f7 Support compression 2016-01-22 18:21:41 -08:00
ea6e7189de Move callInfo into the right position 2016-01-07 14:44:36 -08:00
da435e3a08 Keep length as uint for overflow check 2015-10-22 12:21:04 +02:00
cbdc43cf9a Fix variable name in comment 2015-10-21 20:47:16 +02:00
20ed1e924e Replace bytes.Buffer with properly sized []byte in encode 2015-10-21 20:47:16 +02:00
984280ba37 change the type of length 2015-10-15 13:22:54 -07:00
61c1259226 some cleanup 2015-10-15 10:59:39 -07:00
d3cb35a50a Fix decoding of message headers for messages with lengths >= 2^24.
recvMsg was interpreting buf[1] as the payload format instead of buf[0];
since compressionNone (the only thing supported) == 0, recvMsg got lucky
for message lengths under 2^24, which has buf[1] == 0.

Fix the error, and ditch the constants in recvMsg. I think they were the
cause of the bug.

Also make encode fail more clearly if someone tries to transmit a
message that exceeds 2^32 bytes.

Fixes #399.
2015-10-15 18:56:48 +11:00
6c8d213d08 Merge pull request #385 from nuss-justin/master
Avoid some allocations in recvMsg
2015-10-06 22:39:18 -07:00
e2cb78fabb Combine const declarations into one block 2015-10-07 06:37:58 +02:00
e63d714a45 fix the wrong reference link 2015-10-06 16:05:45 -07:00
5165699f37 Define constants for header size and format index 2015-10-06 20:53:17 +02:00
95d129f7d8 Remove unnecessary uint8 conversion 2015-10-06 06:32:01 +02:00
c9fdfdd500 Avoid some allocations in recvMsg
Reading the header by hand avoids some allocations and improves the
performance of recvMsg.

benchmark                              old ns/op     new ns/op     delta
BenchmarkClientStreamc1-8              125267        110733        -11.60%
BenchmarkClientStreamc8-8              21561         20971         -2.74%
BenchmarkClientStreamc64-8             13573         12825         -5.51%
BenchmarkClientStreamc512-8            13937         13300         -4.57%
BenchmarkClientUnaryc1-8               223208        257968        +15.57%
BenchmarkClientUnaryc8-8               46168         45618         -1.19%
BenchmarkClientUnaryc64-8              33740         33038         -2.08%
BenchmarkClientUnaryc512-8             33137         32663         -1.43%
BenchmarkClientStreamNoTracec1-8       115559        107506        -6.97%
BenchmarkClientStreamNoTracec8-8       20853         20376         -2.29%
BenchmarkClientStreamNoTracec64-8      12119         11935         -1.52%
BenchmarkClientStreamNoTracec512-8     13087         12479         -4.65%
BenchmarkClientUnaryNoTracec1-8        225577        244701        +8.48%
BenchmarkClientUnaryNoTracec8-8        42211         41884         -0.77%
BenchmarkClientUnaryNoTracec64-8       30313         29655         -2.17%
BenchmarkClientUnaryNoTracec512-8      29914         29637         -0.93%

benchmark                              old allocs     new allocs     delta
BenchmarkClientStreamc1-8              46             40             -13.04%
BenchmarkClientStreamc8-8              47             41             -12.77%
BenchmarkClientStreamc64-8             46             40             -13.04%
BenchmarkClientStreamc512-8            46             40             -13.04%
BenchmarkClientUnaryc1-8               100            91             -9.00%
BenchmarkClientUnaryc8-8               100            91             -9.00%
BenchmarkClientUnaryc64-8              100            91             -9.00%
BenchmarkClientUnaryc512-8             96             88             -8.33%
BenchmarkClientStreamNoTracec1-8       42             36             -14.29%
BenchmarkClientStreamNoTracec8-8       43             37             -13.95%
BenchmarkClientStreamNoTracec64-8      42             36             -14.29%
BenchmarkClientStreamNoTracec512-8     42             36             -14.29%
BenchmarkClientUnaryNoTracec1-8        87             78             -10.34%
BenchmarkClientUnaryNoTracec8-8        87             78             -10.34%
BenchmarkClientUnaryNoTracec64-8       87             78             -10.34%
BenchmarkClientUnaryNoTracec512-8      84             77             -8.33%

benchmark                              old bytes     new bytes     delta
BenchmarkClientStreamc1-8              2015          1919          -4.76%
BenchmarkClientStreamc8-8              2016          1920          -4.76%
BenchmarkClientStreamc64-8             2015          1919          -4.76%
BenchmarkClientStreamc512-8            2007          1901          -5.28%
BenchmarkClientUnaryc1-8               5981          5837          -2.41%
BenchmarkClientUnaryc8-8               5980          5837          -2.39%
BenchmarkClientUnaryc64-8              5956          5813          -2.40%
BenchmarkClientUnaryc512-8             5743          5611          -2.30%
BenchmarkClientStreamNoTracec1-8       1887          1791          -5.09%
BenchmarkClientStreamNoTracec8-8       1888          1792          -5.08%
BenchmarkClientStreamNoTracec64-8      1916          1789          -6.63%
BenchmarkClientStreamNoTracec512-8     1894          1811          -4.38%
BenchmarkClientUnaryNoTracec1-8        4301          4158          -3.32%
BenchmarkClientUnaryNoTracec8-8        4301          4157          -3.35%
BenchmarkClientUnaryNoTracec64-8       4282          4140          -3.32%
BenchmarkClientUnaryNoTracec512-8      4131          4077          -1.31%
2015-10-05 19:52:11 +02:00
1a7cf7f696 fix difference between unitary and stream codec error handling 2015-10-03 18:43:53 +01:00