Created
April 10, 2017 16:31
-
-
Save shijuvar/be59bfd9edff256faadb5b2712cb9bf2 to your computer and use it in GitHub Desktop.
NATS Request-Reply Response
This file contains 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
var orderServiceUri string | |
orderServiceUri = viper.GetString("discovery.orderservice") | |
func main() { | |
// Create server connection | |
natsConnection, _ := nats.Connect(nats.DefaultURL) | |
log.Println("Connected to " + nats.DefaultURL) | |
natsConnection.Subscribe("Discovery.OrderService", func(m *nats.Msg) { | |
orderServiceDiscovery := pb.ServiceDiscovery{OrderServiceUri: orderServiceUri} | |
data, err := proto.Marshal(&orderServiceDiscovery) | |
if err == nil { | |
natsConnection.Publish(m.Reply, data) | |
} | |
}) | |
// Keep the connection alive | |
runtime.Goexit() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment