72 Commits

Author SHA1 Message Date
ad51f572fd protoc-gen-go-grpc: add requirement of embedding UnimplementedServer in services (#3657) 2020-06-04 10:56:13 -07:00
f818fd2a02 all: regenerate .pb.go files using cmd/protoc-gen-go-grpc (#3646)
Change regenerate.sh to use cmd/protoc-gen-go-grpc and rerun it.
This splits the gRPC service definitions into separate files, but
otherwise has no changes.
2020-05-28 13:52:49 -07:00
15653fec60 all: refactor .pb.go generation (#3451)
Replace various //go:generate lines and regenerate.sh scripts with a
single, top-level regenerate.sh that regenerates all .pb.go files.

Placing generation in a single script ensures that all files are
generated with similar parameters. The new regenerate.sh uses the
protoc-gen-go version defined in test/tools/go.mod and automatically
handles new .proto files as they are added.

Do some minor refactoring on .proto files: Every file now has a
go_package option (which will be required by a future version of the
code generator), and file imports are all relative to the repository
root.
2020-04-24 08:54:03 -07:00
b3dcc68129 stats: set response compression codec on stats.InHeader and stats.OutHeader (#3390) 2020-03-20 10:12:38 -07:00
5c17da6907 stats: add comments about why out headers and out trailers have no wire length (#3408) 2020-03-10 09:15:28 -07:00
132187f04c Modified tests to use tlogger. (#3343)
* Modified tests to use tlogger.

* Fail on errors, with error expectations.

* Added expects and MixedCapsed grpclb_config tests

* Moved tlogger to grpctest, moved leakcheck tester to grpctest.go

* Added ExpectErrorN()

* Removed redundant leak checks

* Fixed new test

* Made tlogger globals into tlogger methods

* ErrorsLeft -> EndTest

* Removed some redundant lines

* Fixed error in test and empty map in EndTest
2020-02-06 13:03:20 -08:00
7621679bee stats: add client side user agent to outgoing header (#3331) 2020-01-31 10:34:44 -08:00
b88d2d7465 protobuf: update protoc-gen-go version and generated code (#3345) 2020-01-30 10:23:21 -08:00
347a6b4db3 stats: attach metadata to In/Out Headers/Trailers (#3169) 2019-11-14 15:22:36 -08:00
a7c1650ef7 fix typos (#3111) 2019-10-22 10:46:34 -07:00
df162eae76 test: embed Unimplemented___Server in every service (#3076) 2019-10-04 13:22:31 -07:00
e2cfd1c28f internal: update proto library version (#3025)
Also, two fixes:

- Fix long-standing `.travis.yml` bug where `VET_SKIP_PROTO` was not `export`ed (so not seen by `vet.sh`).
- Update `vet.sh` to work with new `goimports -l` that does not print a `:` after filenames.
2019-09-17 13:49:26 -07:00
b5748caae7 server: populate WireLength on stats.InPayload for unary RPCs (#2932)
Fixes #2692 which was incompletely fixed by #2711.

Also adds updates stats/stat_test.go to sanity check WireLength.
2019-07-24 16:24:45 -07:00
9c3a959569 stats: add Trailer to client-side stats.End (#2639)
Currently, it is not possible to access trailers from within a
stats.Handler. The reason is that both stats.Handler and
ClientStream.Trailer require a lock on the ClientStream.

A workaround would be to start a separate goroutine that will call
ClientStream.Trailer asynchronously, but that requires careful
coordination and we can quite easily make the trailer metadata available
to the stats.Handler directly.

Use case: an interceptor that processes trailer metadata for each
streaming RPC after the stream has finished. Note that a
StreamClientInterceptor returns immediately, before the stream has
finished and before the trailer metadata is available.
2019-03-13 10:10:52 -07:00
29a7ac4deb client: deprecates FailFast & replaces its use by WaitForReady. 2018-12-13 15:15:11 -08:00
04ea82009c cleanup: replace "x/net/context" import with "context" (#2439) 2018-11-12 13:30:41 -08:00
59a2cfbdf9 Remove support for Go1.6-1.8 (#2428) 2018-11-01 15:43:42 -07:00
5fe10fccaf Remove unused symbols (#2287) 2018-09-05 12:29:02 -07:00
39a411827d internal: Update proto generated code (#2133) 2018-06-08 17:54:26 -07:00
f669235193 internal: update proto generated code (#2093) 2018-05-21 09:59:26 -07:00
a36eb4675a regenerate *.pb.go files due to proto-gen-go update (#2070) 2018-05-11 18:57:54 -07:00
e538e04cad proto: update generated code (#2039) 2018-05-01 12:53:20 -07:00
2c2d834e8e stats: add BeginTime to stats.End (#1907) 2018-03-12 09:16:36 -07:00
365770fcbd streams: Stop cleaning up after orphaned streams (#1854)
This change introduces some behavior changes that should not impact users that
are following the proper stream protocol. Specifically, one of the following
conditions must be satisfied:

1. The user calls Close on the ClientConn.
2. The user cancels the context provided to NewClientStream, or its deadline
    expires. (Note that it if the context is no longer needed before the deadline
    expires, it is still recommended to call cancel to prevent bloat.) It is always
    recommended to cancel contexts when they are no longer needed, and to
    never use the background context directly, so all users should always be
    doing this.
3. The user calls RecvMsg (or Recv in generated code) until a non-nil error is
    returned.
4. The user receives any error from Header or SendMsg (or Send in generated
    code) besides io.EOF.  If none of the above happen, this will leak a goroutine
    and a context, and grpc will not call the optionally-configured stats handler
    with a stats.End message.

Before this change, if a user created a stream and the server ended the stream,
the stats handler would be invoked with a stats.End containing the final status
of the stream. Subsequent calls to RecvMsg would then trigger the stats handler
with InPayloads, which may be unexpected by stats handlers.
2018-02-08 10:51:16 -08:00
f4b523765c status: add Code convenience function (#1754) 2017-12-18 15:00:50 -08:00
4e393e0b21 grpc: fix deprecation comments to conform to standard (#1691) 2017-12-18 09:23:42 -08:00
6ef45d3689 fix stats flaky test (#1740)
1. Call transport Close if newHTTP2Server returns non-nil error.
Handle ConnBegin was called before this error, and handle ConnEnd is not called (because Close() is not called), which caused ConnStats check to fail.

2. Skip stats test in go1.6.
go1.6 doesn't have DialContext (we use Dialer(Cancel: ctx.Done()) instead). When the give context is canceled, this function sometimes returns canceled error, while the server side still gets the conn. This caused the server blocking on reading the preface (which will eventually timeout, but the tests are too short for that), and there will be a missing ConnEnd.
2017-12-15 14:37:20 -08:00
865013bc17 *: replace deprecated grpc.Errorf calls with status.Errorf (#1651) 2017-11-06 10:24:20 -08:00
cf79c84979 fix stats test race (#1560)
* fix stats test race
* and try fix TestMapAddressEnv race
2017-10-04 14:30:12 -07:00
3bf110cd0c fix TestServerCredsDispatch and stats test race (#1554) 2017-10-03 17:07:39 -07:00
6014154b60 Use the same hpack encoder on a transport and share it between RPCs. (#1536) 2017-09-28 13:37:13 -07:00
59cb69e66d Fix misspells (#1531) 2017-09-20 14:55:57 -07:00
69abda08b5 stats: add methods to allow setting grpc-trace-bin and grpc-tags-bin headers (#1404)
This is in preparation for preventing any user-supplied metadata starting with "grpc-", which is reserved.

* stats: add methods to allow setting grpc-trace-bin and grpc-tags-bin headers

Pick these up in grpc's transport when sending and fill them when receiving.

* Add tags/trace to metadata and tests for that behavior

This is temporary to maintain compatibility and provide a migration strategy.
2017-08-24 10:00:40 -07:00
25b4a426b4 go-generate pb.go files and check in Travis to make sure they don't change (#1426) 2017-08-17 16:00:51 -07:00
596a6acc87 metadata: Remove NewContext and FromContext for gRFC L7 (#1392) 2017-08-17 13:10:28 -07:00
bba722ab6d Change comment on stats.End.Error (#1418) 2017-08-03 13:47:29 -07:00
3c33c26290 add license for some proto files (#1322) 2017-06-27 09:54:34 -07:00
834dbd54e0 replace 127.0.0.1 with localhost for ipv6 only environment (#1306) 2017-06-14 15:03:04 -07:00
ddbf6c46a6 autofix license notice 2017-06-08 14:42:19 +02:00
a0c3e72252 Add stats test for client streaming and server streaming RPCs (#1140) 2017-05-11 11:58:13 -07:00
17760cfd5b Calling handleRPC with context derived from the original (#1227)
* Calling handleRPC with different context derived from the original context
* change comment for tagRPC and stats fields
2017-05-10 17:54:49 -07:00
7ddf89f9b7 Fix doc 2017-05-04 10:30:28 -07:00
cd8432ec07 Move handling stats.End to clientStream.finish() (#1182)
* move handling stats.End to clientStream.finish()
* add stats test for streaming RPC not calling last recv()
2017-04-12 11:55:54 -07:00
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
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
cb653e4b61 Change stats APIs (#1030)
Change stats API from one static handler to one handler per server or client.
2017-01-09 17:11:32 -08:00
7484960149 remove stats.Stop() and fix flaky stats test (#1016) 2016-12-07 17:33:01 -08:00
deb01f422a add stats tagger APIs and connection stats. (#992)
* add stats.tagger APIs and connection stats.

* fix comments

use ac.ctx in http2client
change name and comments
small fixes stats_tests

* add a TODO to ConnTagInfo

* rename handle to handleRPC

* modify stats comments
2016-11-30 16:25:46 -08:00
524f421370 fix flaky stats test and reuse functions in stats test 2016-11-10 17:42:52 -08:00
88bdb9565f fixes in test 2016-11-09 14:04:51 -08:00