Created
March 11, 2020 15:46
-
-
Save asim/ebde6b50bc707a1d347b625f2392483f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/micro/clients/go/client" | |
) | |
type Request struct { | |
Count string `json:"count"` | |
} | |
type Response struct { | |
Count string `json:"count"` | |
} | |
func main() { | |
c := client.NewClient(nil) | |
stream, err := c.Stream("go.micro.srv.asim", "Asim.Stream", Request{Count: "10"}) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
for { | |
var rsp Response | |
if err := stream.Recv(&rsp); err != nil { | |
fmt.Println(err) | |
return | |
} | |
fmt.Println("got", rsp.Count) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment