1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

Update services/ (#2392)

This commit is contained in:
Asim Aslam
2021-12-21 13:18:29 +00:00
committed by GitHub
parent 8e52761edb
commit 7af0eb4b7a
67 changed files with 3457 additions and 271 deletions

View File

@ -18,14 +18,34 @@ type HelloworldService struct {
// Call returns a personalised "Hello $name" response
func (t *HelloworldService) Call(request *CallRequest) (*CallResponse, error) {
rsp := &CallResponse{}
return rsp, t.client.Call("helloworld", "Call", request, rsp)
}
// Stream returns a stream of "Hello $name" responses
func (t *HelloworldService) Stream(request *StreamRequest) (*StreamResponse, error) {
rsp := &StreamResponse{}
return rsp, t.client.Call("helloworld", "Stream", request, rsp)
func (t *HelloworldService) Stream(request *StreamRequest) (*StreamResponseStream, error) {
stream, err := t.client.Stream("helloworld", "Stream", request)
if err != nil {
return nil, err
}
return &StreamResponseStream{
stream: stream,
}, nil
}
type StreamResponseStream struct {
stream *client.Stream
}
func (t *StreamResponseStream) Recv() (*StreamResponse, error) {
var rsp StreamResponse
if err := t.stream.Recv(&rsp); err != nil {
return nil, err
}
return &rsp, nil
}
type CallRequest struct {