mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
Checkpoint the world
This commit is contained in:
@ -18,16 +18,24 @@ func (e *Example) Call(ctx context.Context, req *example.Request, rsp *example.R
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Example) Stream(ctx context.Context, req *example.StreamingRequest, response func(interface{}) error) error {
|
||||
func (e *Example) Stream(ctx context.Context, stream server.Streamer) error {
|
||||
log.Info("Executing streaming handler")
|
||||
req := &example.StreamingRequest{}
|
||||
|
||||
// We just want to receive 1 request and then process here
|
||||
if err := stream.Recv(req); err != nil {
|
||||
log.Errorf("Error receiving streaming request: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Infof("Received Example.Stream request with count: %d", req.Count)
|
||||
|
||||
for i := 0; i < int(req.Count); i++ {
|
||||
log.Infof("Responding: %d", i)
|
||||
|
||||
r := &example.StreamingResponse{
|
||||
if err := stream.Send(&example.StreamingResponse{
|
||||
Count: int64(i),
|
||||
}
|
||||
|
||||
if err := response(r); err != nil {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user