Last active
April 10, 2017 16:12
-
-
Save shijuvar/7f34b22904476ca9cae856f36e8f24b6 to your computer and use it in GitHub Desktop.
NATS Request-Reply Request
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
| func main() { | |
| // Create NATS server connection | |
| natsConnection, _ := nats.Connect(nats.DefaultURL) | |
| log.Println("Connected to " + nats.DefaultURL) | |
| msg, err := natsConnection.Request("Discovery.OrderService", nil, 1000*time.Millisecond) | |
| if err == nil && msg != nil { | |
| orderServiceDiscovery := pb.ServiceDiscovery{} | |
| err := proto.Unmarshal(msg.Data, &orderServiceDiscovery) | |
| if err != nil { | |
| log.Fatalf("Error on unmarshal: %v", err) | |
| } | |
| address := orderServiceDiscovery.OrderServiceUri | |
| log.Println("OrderService endpoint found at:", address) | |
| //Set up a connection to the gRPC server. | |
| conn, err := grpc.Dial(address, grpc.WithInsecure()) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment