Exemplo n.º 1
0
func main() {
	flag.Parse()
	rabbitmq.DefaultExchange = "b2a"
	rabbitmq.DefaultRabbitURL = "amqp://localhost:5672"

	s := server.NewServer(
		server.Name("foo"),
		server.Id("foo"),
		server.Address("foo"),
		server.Transport(rabbitmq.NewTransport([]string{})),
		server.Codec("application/x-protobuf", mcodec.NewCodec),
	)
	s.Handle(
		s.NewHandler(&Say{}),
	)

	s.Start()
	select {}
}
Exemplo n.º 2
0
func main() {
	rabbitmq.DefaultExchange = "b2a"
	rabbitmq.DefaultRabbitURL = "amqp://localhost:5672"

	c := client.NewClient(
		client.Selector(mercury.NewSelector()),
		client.Transport(rabbitmq.NewTransport([]string{})),
		client.Codec("application/x-protobuf", mcodec.NewCodec),
		client.ContentType("application/x-protobuf"),
	)

	req := c.NewRequest("foo", "Say.Hello", &hello.Request{
		Name: "John",
	})

	rsp := &hello.Response{}

	if err := c.Call(context.Background(), req, rsp); err != nil {
		fmt.Println(err)
	}

	fmt.Println(rsp)
}