mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
Working bidirectional streaming example
This commit is contained in:
@ -42,3 +42,17 @@ func (e *Example) Stream(ctx context.Context, stream server.Streamer) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Example) PingPong(ctx context.Context, stream server.Streamer) error {
|
||||
for {
|
||||
req := &example.Ping{}
|
||||
if err := stream.Recv(req); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Got ping %v", req.Stroke)
|
||||
if err := stream.Send(&example.Pong{Stroke: req.Stroke}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user