Commit Graph

188 Commits

Author SHA1 Message Date
Phil Estes
5829a06d8c Merge pull request #43 from crosbymichael/metadata
metadata as KeyValue type
2019-06-13 14:29:42 -04:00
Michael Crosby
694de9d955 metadata as KeyValue type
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-13 18:06:27 +00:00
Michael Crosby
3afb82bd27 Fix error handling with server shutdown
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-13 17:19:47 +00:00
Michael Crosby
f3eb35b158 Refactor close handling for ttrpc clients
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-13 16:52:46 +00:00
Michael Crosby
d134fe75a4 Merge pull request #41 from crosbymichael/interceptors
Add client and server unary interceptors
2019-06-12 16:53:32 -04:00
Michael Crosby
de8faac08b Add godocs for interceptors
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-12 20:26:36 +00:00
Michael Crosby
e409d7d775 Add example binary for testing the example service
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-12 19:37:43 +00:00
Michael Crosby
819653f40c Add client and server unary interceptors
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-07 15:49:42 +00:00
Michael Crosby
a5bd8ce9e4 Merge pull request #40 from mxpv/headers
Support headers
2019-05-29 14:57:06 -04:00
Maksym Pavlenko
04523b9d2c Rename headers to metadata
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2019-05-24 17:02:38 -07:00
Maksym Pavlenko
5926a92b70 Support headers
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2019-05-23 13:34:04 -07:00
Brian Goff
f82148331a Merge pull request #38 from masters-of-cats/pr-client-eof-improvement
Improve connection error handling
2019-05-13 07:15:51 -07:00
Georgi Sabev
911c9cda77 Improve connection error handling
Return if client is gone, log all other errors

Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Signed-off-by: Georgi Sabev <georgethebeatle@gmail.com>
2019-05-13 10:36:03 +01:00
Phil Estes
69eadd1c7f Merge pull request #37 from masters-of-cats/pr-handle-client-eof
Handle EOF to prevent file descriptor leak
2019-05-10 16:50:00 +02:00
Georgi Sabev
96dcf73d20 Handle EOF to prevent file descriptor leak
Currently the EOF that the server gets when a client connection is
closed is being ignored, which means that the goroutine that is
processing the client connection will never exit. If it never exits
it will never close the underlying unix socket and this would lead
to a file descriptor leak.

Signed-off-by: Georgi Sabev <georgethebeatle@gmail.com>
2019-05-10 15:35:37 +03:00
Michael Crosby
699c4e40d1 Merge pull request #35 from Random-Liu/make-on-close-an-options
Make onclose an option.
2019-04-11 14:14:08 -04:00
Lantao Liu
ba15956d22 Make onclose an option.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-04-11 10:57:14 -07:00
Phil Estes
6914432707 Merge pull request #33 from JoeWrightss/patch-1
Fix returns error message
2019-02-10 20:22:30 -08:00
zhoulin xie
ce5c1c4546 Fix returns error message
Signed-off-by: zhoulin xie <zhoulin.xie@daocloud.io>
2019-02-08 22:30:00 +08:00
Stephen Day
f02858b145 Merge pull request #31 from cpuguy83/support_context_deadlines
Add support for request timeout propgation.
2019-01-07 13:10:05 -08:00
Brian Goff
a364f44e55 Add support for request timeout propgation.
Adds a new field to the `Request` type which specifies a timeout (in
nanoseconds) for the request. This is propagated on method dispatch as a
context timeout.

There was some discussion here on supporting a broader "metadata" field
(similar to grpc) that can be used for other things, but we ended up
with a dedicated field because it is lighter weight and expect it to be
used pretty heavily as is.... metadata may be added in the future, but
is not necessary for timeouts.

Also discussed using a deadline vs a timeout in the request and decided
to go with a timeout in order to deal with potential clock skew between
the client and server. This also has the side-effect of eliminating the
protocol/wire overhead from the request timeout.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-01-07 12:43:52 -08:00
Michael Crosby
f51df4475b Merge pull request #30 from estesp/add-common-project-content
Add common check scripts and project references
2018-10-01 11:40:09 -04:00
Phil Estes
6c96b39a28 Add common check scripts and project references
Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-10-01 10:33:38 -04:00
Michael Crosby
2a805f7186 Merge pull request #29 from containerd/ctxdone
Add client side context.Done support
2018-09-20 14:52:16 -04:00
Michael Crosby
33564d24b2 Signal server done before closing connections
This fixes the races we are seeing in the tests

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-09-20 14:14:44 -04:00
Michael Crosby
d77f111e2e Add client side context.Done support
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-28 10:54:57 -04:00
Michael Crosby
94dde38880 Merge pull request #27 from containerd/ctx
Add context to Serve
2018-07-02 15:18:17 -04:00
Michael Crosby
01ed7d8777 Add context to Serve
This is to seed a new context on the serve method

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-02 11:36:10 -04:00
Michael Crosby
fa6c681436 Merge pull request #25 from containerd/repochange
Update imports and references for containerd
2018-06-28 09:41:53 -04:00
Michael Crosby
0690b20898 Add apache license to files
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-06-27 17:49:06 -04:00
Michael Crosby
4b957e7112 Update imports and references for containerd
This updates the references and imports for the move into the containerd
org.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-06-27 17:32:37 -04:00
Stephen Day
530a70d668 Merge pull request #24 from elboulangero/master
Log with sirupsen/logrus to avoid a circular dependency to containerd #6
2018-05-07 11:00:46 -07:00
Arnaud Rebillout
87ac4c6f7a Log with sirupse/logrus to avoid a circular dependency to containerd #6
Signed-off-by: Arnaud Rebillout <arnaud.rebillout@collabora.com>
2018-02-22 13:28:57 +07:00
Stephen Day
d452837986 Merge pull request #22 from crosbymichael/onclose
Add onclose func
2018-02-05 14:44:48 -08:00
Michael Crosby
042635eccb Add onclose func
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-02-05 16:51:41 -05:00
Stephen Day
4d1bf6563c Merge pull request #20 from stevvooe/pump-read-block
ttrpc: refactor channel to take a conn
2018-01-16 15:50:42 -08:00
Stephen J Day
c575201d9a ttrpc: refactor channel to take a conn
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-01-16 15:29:07 -08:00
Stephen Day
7276d64f93 Merge pull request #21 from stevvooe/return-correct-error-close
ttrpc: return correct error on (*Client).Close
2018-01-12 16:38:48 -08:00
Stephen J Day
2c96d0a152 ttrpc: return correct error on (*Client).Close
Because `shutdownErr` will likely be `nil` in the close select branch,
returning it to waiters will result in the waiting `(*Client).Call`
returning `(nil, nil)`. This should take whatever is set for the client
as the exit condition, which is likely to be `ErrClosed`.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-01-12 16:21:27 -08:00
Stephen Day
d2710463e4 Merge pull request #19 from stevvooe/shutdown-client-err
ttrpc: return ErrClosed when client is shutdown
2018-01-09 15:00:59 -08:00
Stephen J Day
e963fd5a12 ttrpc: return ErrClosed when client is shutdown
To gracefully handle scenarios where the connection is closed or the
client is closed, we now set the final error to be `ErrClosed`. Callers
can resolve it through using `errors.Cause` to detect this condition.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-01-09 14:46:02 -08:00
Stephen Day
76e68349ad Merge pull request #14 from AkihiroSuda/avoid-os-user
unixcreds: use euid instead of uid
2017-12-01 11:38:49 -08:00
Akihiro Suda
f2351f115b unixcreds: use euid instead of uid
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-12-02 03:58:03 +09:00
Stephen Day
334dad0199 Merge pull request #15 from justincormack/creds_linuxonly
SO_PEERCRED is Linux only
2017-12-01 10:55:09 -08:00
Justin Cormack
511f780fca SO_PEERCRED is Linux only
BSD does have LOCAL_PEERCRED but x/sys.unix does not yet have support for it.
I will add support and do a proper fix later.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-12-01 10:54:41 -08:00
Stephen Day
961d4bc798 Merge pull request #17 from stevvooe/raw-conn
ttrpc: use syscall.RawConn to access fd over File
2017-12-01 10:19:14 -08:00
Stephen J Day
0fc9ed6ba0 ttrpc: use syscall.RawConn to access fd over File
Due to a performance drop when calling `(*net.UnixConn).File`, this
change uses the `syscall.RawConn` directly to call `Control` on the
socket. The result is there is no longer a performance penalty to using
unix socket credentials.

The benchmarks after this change are as follows:

```
goos: linux
goarch: amd64
pkg: github.com/stevvooe/ttrpc
BenchmarkRoundTrip-8                  	   50000	     22474 ns/op	    2593 B/op	      43 allocs/op
BenchmarkRoundTripUnixSocketCreds-8   	  100000	     22120 ns/op	    2593 B/op	      43 allocs/op
PASS
ok  	github.com/stevvooe/ttrpc	4.049s
```

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-12-01 10:00:50 -08:00
Stephen Day
45d16b41b5 Merge pull request #13 from stevvooe/glibc-not-static
ttrpc: use os.Getuid/os.Getgid directly
2017-11-30 20:30:37 -08:00
Stephen J Day
256c17bccd ttrpc: use os.Getuid/os.Getgid directly
Because of issues with glibc, using the `os/user` package can cause when
calling `user.Current()`. Neither the Go maintainers or glibc developers
could be bothered to fix it, so we have to work around it by calling the
uid and gid functions directly. This is probably better because we don't
actually use much of the data provided in the `user.User` struct.

This required some refactoring to have better control over when the uid
and gid are resolved. Rather than checking the current user on every
connection, we now resolve it once at initialization. To test that this
provided an improvement in performance, a benchmark was added.
Unfortunately, this exposed a regression in the performance of unix
sockets in Go when `(*UnixConn).File` is called. The underlying culprit
of this performance regression is still at large.

The following open issues describe the underlying problem in more
detail:

https://github.com/golang/go/issues/13470
https://sourceware.org/bugzilla/show_bug.cgi?id=19341

In better news, I now have an entire herd of shaved yaks.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-30 20:21:50 -08:00
Stephen Day
af6e7491e5 Merge pull request #11 from stevvooe/unix-socket-credentials
ttrpc: implement unix socket credentials
2017-11-30 16:55:30 -08:00