Commit Graph

275 Commits

Author SHA1 Message Date
Stephen J Day
b1feeec836
ttrpc: implement Close and Shutdown
This apples logic to correctly Close a server, as well as implements
graceful shutdown. This ensures that inflight requests are not
interrupted and works similar to the functionality in `net/http`.

This required a fair bit of refactoring around how the connection is
managed. The connection now has an explicit wrapper object, ensuring
that shutdown happens in a coordinated fashion, whether or not a
forceful close or graceful shutdown is called.

In addition to the above, hardening around the accept loop has been
added. We now correctly exit on non-temporary errors and debounce the
accept call when encountering repeated errors. This should address some
issues where `SIGTERM` was not honored when dropping into the accept
spin.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-29 11:03:51 -08:00
Stephen Day
8d40df6f6d
Merge pull request #5 from stevvooe/travis-build
build: add travis build file
2017-11-29 10:29:12 -08:00
Stephen J Day
d31419dd1d
build: add travis build file
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-29 10:24:42 -08:00
Stephen J Day
5e1096a4c2
ttrpc: better test for concurrency
Improve the test to conduct two concurrent calls. The test server now
just doubles the input and we use a unix socket to better represent what
will be used in production.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-27 21:19:57 -08:00
Stephen J Day
bdb2ab7a81
ttrpc: use odd numbers for client initiated streams
Following the convention of http2, we now use odd stream ids for client
initiated streams. This makes it easier to tell who initiates the
stream. We enforce the convention on the server-side.

This allows us to upgrade the protocol in the future to have server
initiated streams.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-27 18:18:25 -08:00
Stephen J Day
07cd4de2f2
ttrpc: correctly propagate error from response
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-22 12:06:18 -08:00
Stephen J Day
a763db9d1f
ttrpc: add required codec.go
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-21 21:44:39 -08:00
Stephen J Day
7f752bf263
ttrpc: handle concurrent requests and responses
With this changeset, ttrpc can now handle mutliple outstanding requests
and responses on the same connection without blocking. On the
server-side, we dispatch a goroutine per outstanding reequest. On the
client side, a management goroutine dispatches responses to blocked
waiters.

The protocol has been changed to support this behavior by including a
"stream id" that can used to identify which request a response belongs
to on the client-side of the connection. With these changes, we should
also be able to support streams in the future.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-21 21:38:38 -08:00
Stephen J Day
2a81659f49
ttrpc: remove use of typeurl
Rather than employ the typeurl package, we now generate code to
correctly allocate the incoming types from the caller. As a side-effect
of this activity, the services definitions have been split out into a
separate type that handles the full resolution and dispatch of the
method, incuding correctly mapping the RPC status.

This work is a pre-cursor to larger protocol change that will allow us
to handle multiple, concurrent requests.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-21 18:03:52 -08:00
Stephen J Day
2d76dba1df
plugin: move generator to separate package
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-16 19:22:21 -08:00
Stephen J Day
d7306a0f0b
README: clarifications and TODOs
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 18:32:08 -08:00
Stephen J Day
809ed493d8
ttrpc: remove unused imports
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 17:28:18 -08:00
Stephen J Day
bd8c759c72
ttrpc: update examples after name change
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 17:09:36 -08:00
Stephen J Day
f147d6ca77
ttrpc: rename project to ttrpc
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 17:04:16 -08:00
Stephen J Day
1bfe6fb8f6
mgrpc: address error on accept
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 17:02:44 -08:00
Stephen J Day
52978c11e8
mgrpc: decrease size of channel buffers
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 17:01:30 -08:00
Stephen J Day
484a09bfa0
mgrpc: fill out client generation functionality
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 17:00:35 -08:00
Stephen J Day
76ad1535fb
README: explain differences with grpc
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-15 16:58:33 -08:00
Stephen J Day
f32bbe9f11
mgrpc: generate first example service
With this changeset, we have the first end to end generated server and
client. Most of the necessary types are in place and working. There are
a lot of details to work out, but this would be enough for to exercise
the end to end flow.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-14 18:56:09 -08:00
Stephen J Day
71e9170d05
mgrpc: mock out workflow for generated code
The server unit test now manually mocks much of the generated code for a
given service, including back registration of the service. We avoid
having a package-level global descriptor in favor of a closures for the
handler dispatch function.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-14 18:23:40 -08:00
Stephen J Day
538d13ce1b
README: update overview of project and provide usage
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-14 13:12:30 -08:00
Stephen J Day
42ff40f1f1
mgrpc: initial implementation of server
With this change, we define a simple server and client framework to
start generating code against. We define a simple handler system with
back registration into the server definition.

From here, we can start generating code against the handlers.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-14 12:18:06 -08:00
Stephen J Day
789a1bff64
mgrpc: initial implementation of message channel
A varint prefixed framing format is defined for transport messages for
mgrpc. We may make changes to include a more structured frame, but this
initial work can be used to validate the concepts.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-14 12:04:48 -08:00
Stephen J Day
eb6cfbbf53
mgrpc: baseline protobuf example
Set the stage for the example server by including a service definition,
generated code and the protobuild definition file used to generate them.
From here, we can work up to a generated mgrpc server.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-14 12:02:25 -08:00
Stephen Day
96ea8b3be5
Initial commit 2017-11-13 14:12:46 -08:00