add streaming response to helloworld service

This commit is contained in:
Asim Aslam
2021-06-11 12:17:54 +01:00
parent 7033fcfdb7
commit 1ae03a6011
4 changed files with 274 additions and 14 deletions

View File

@@ -15,3 +15,18 @@ func (e *Helloworld) Call(ctx context.Context, req *helloworld.Request, rsp *hel
rsp.Message = "Hello " + req.Name
return nil
}
func (e *Helloworld) Stream(ctx context.Context, req *helloworld.StreamRequest, rsp helloworld.Helloworld_StreamStream) error {
// send one if none
if req.Messages == 0 {
req.Messages = 1
}
for i := 0; i < int(req.Messages); i++ {
rsp.Send(&helloworld.StreamResponse{
Message: "Hello " + req.Name,
})
}
return nil
}