Skip to content

Instantly share code, notes, and snippets.

@asim
Created March 11, 2020 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asim/ebde6b50bc707a1d347b625f2392483f to your computer and use it in GitHub Desktop.
Save asim/ebde6b50bc707a1d347b625f2392483f to your computer and use it in GitHub Desktop.
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