micro/server
Hao Lian d4b149046f server/rpc_codec: if c.codec.Write fails, reset write buffer and encode an error message about the encoding failure
When developing go-micro services, it is frequently possible to set invalid results in the response pointer. When this happens (as I and @trushton personally experienced), `sendResponse()` returns an error correctly explaining what happened (e.g. protobuf refused to encode a bad struct) but the `call()` function one above it in the stack ignores the returned error object.

Thus, invalid structs go un-encoded and the _client side times out_. @trushton and I first caught this in our CI builds when we left a protobuf.Empty field uninitialized (nil) instead of setting it to `&ptypes.Empty{}`. This resulted in an `proto: oneof field has nil value` error, but it was dropped and became a terribly confusing client timeout instead.

This patch is two independent changes:

* In rpc_codec, when a serialization failure occurs serialize an error message, which will correctly become a 500 for HTTP services, about the encoding failure. This means rpc_codec only returns an `error` when a socket failure occurs, which I believe is the behavior that rpc_service is expecting anyway.

* In rpc_service, log any errors returned by sendResponse instead of dropping the error object. This will make debugging client timeouts less of a hassle.
2017-07-17 14:21:43 -04:00
..
debug Add debug stats handler 2016-05-28 22:30:47 +01:00
mock Add mock server 2016-04-16 00:02:55 +01:00
rpc Add packages for the defaults 2016-03-14 10:45:38 +00:00
buffer.go Updated codec interface and code. Painful stuff 2015-11-28 11:22:29 +00:00
context.go be pedantic 2017-05-31 19:33:11 +01:00
debug.go Add debug stats handler 2016-05-28 22:30:47 +01:00
extractor_test.go move addr extractor to misc 2017-01-12 13:20:34 +00:00
extractor.go move addr extractor to misc 2017-01-12 13:20:34 +00:00
handler.go move the option 2016-05-26 20:43:05 +01:00
options.go add wait option 2017-05-31 19:47:50 +01:00
rpc_codec_test.go server/rpc_codec: if c.codec.Write fails, reset write buffer and encode an error message about the encoding failure 2017-07-17 14:21:43 -04:00
rpc_codec.go server/rpc_codec: if c.codec.Write fails, reset write buffer and encode an error message about the encoding failure 2017-07-17 14:21:43 -04:00
rpc_handler.go Support endpoint metadata 2016-05-26 18:01:02 +01:00
rpc_request.go Rename to hdlrWrappers for symmetry sake 2015-12-02 21:12:09 +00:00
rpc_server.go defer wg.Done so it's called even if there's a panic 2017-06-12 14:18:59 +01:00
rpc_service.go server/rpc_codec: if c.codec.Write fails, reset write buffer and encode an error message about the encoding failure 2017-07-17 14:21:43 -04:00
rpc_stream.go superfluous logging 2016-12-15 20:45:27 +00:00
server_wrapper.go Checkpoint the world 2015-12-18 01:01:59 +00:00
server.go make use of micro/go-log 2017-05-11 20:43:42 +01:00
subscriber.go defer wg.Done so it's called even if there's a panic 2017-06-12 14:18:59 +01:00