diff --git a/_examples/golang-sse/proto/chat.gen.go b/_examples/golang-sse/proto/chat.gen.go index b34074a7..8756b5a9 100644 --- a/_examples/golang-sse/proto/chat.gen.go +++ b/_examples/golang-sse/proto/chat.gen.go @@ -71,6 +71,16 @@ type subscribeMessagesStreamWriter struct { streamWriter } +func (w *subscribeMessagesStreamWriter) Write(message *Message) error { + out := struct { + Ret0 *Message `json:"message"` + }{ + Ret0: message, + } + + return w.streamWriter.write(out) +} + type streamWriter struct { mu sync.Mutex // Guards concurrent writes to w. w http.ResponseWriter @@ -115,14 +125,6 @@ func (w *streamWriter) write(respPayload interface{}) error { return w.e.Encode(respPayload) } -func (w *streamWriter) Write(message *Message) error { - respPayload := struct { - Arg0 *Message `json:"message"` - }{message} - - return w.write(respPayload) -} - // // Client types // @@ -136,6 +138,7 @@ type SubscribeMessagesStreamReader interface { Read() (message *Message, err error) } + // // Server // @@ -353,7 +356,7 @@ func (c *chatClient) SendMessage(ctx context.Context, username string, text stri Arg0 string `json:"username"` Arg1 string `json:"text"` }{username, text} - + resp, err := doHTTPRequest(ctx, c.client, c.urls[0], in, nil) defer func() { if resp != nil { @@ -363,7 +366,7 @@ func (c *chatClient) SendMessage(ctx context.Context, username string, text stri } } }() - + return err } @@ -389,18 +392,18 @@ type subscribeMessagesStreamReader struct { } func (r *subscribeMessagesStreamReader) Read() (*Message, error) { - var out struct{ + out := struct { Ret0 *Message `json:"message"` WebRPCError *WebRPCError `json:"webrpcError"` - } + }{} err := r.streamReader.read(&out) if err != nil { - return nil, err + return out.Ret0, err } if out.WebRPCError != nil { - return nil, out.WebRPCError + return out.Ret0, out.WebRPCError } return out.Ret0, nil @@ -665,9 +668,9 @@ var ( ErrWebrpcBadResponse = WebRPCError{Code: -5, Name: "WebrpcBadResponse", Message: "bad response", HTTPStatus: 500} ErrWebrpcServerPanic = WebRPCError{Code: -6, Name: "WebrpcServerPanic", Message: "server panic", HTTPStatus: 500} ErrWebrpcInternalError = WebRPCError{Code: -7, Name: "WebrpcInternalError", Message: "internal error", HTTPStatus: 500} - ErrWebrpcClientDisconnected = WebRPCError{Code: -8, Name: "WebrpcClientDisconnected", Message: "client disconnected", HTTPStatus: 400, cause: http.ErrAbortHandler} + ErrWebrpcClientDisconnected = WebRPCError{Code: -8, Name: "WebrpcClientDisconnected", Message: "client disconnected", HTTPStatus: 400} ErrWebrpcStreamLost = WebRPCError{Code: -9, Name: "WebrpcStreamLost", Message: "stream lost", HTTPStatus: 400} - ErrWebrpcStreamFinished = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200, cause: io.EOF} + ErrWebrpcStreamFinished = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200} ) // Schema errors diff --git a/_examples/golang-sse/proto/chat.ridl b/_examples/golang-sse/proto/chat.ridl index 77948fc2..c72864c1 100644 --- a/_examples/golang-sse/proto/chat.ridl +++ b/_examples/golang-sse/proto/chat.ridl @@ -13,4 +13,4 @@ service Chat - SendMessage(username: string, text: string) - SubscribeMessages(username: string) => stream (messages: Message) -error 100 ErrEmptyUsername "Username can't be empty." HTTP 400 \ No newline at end of file +error 100 EmptyUsername "Username can't be empty." HTTP 400 \ No newline at end of file