update so builds in travis ci
This commit is contained in:
		
							
								
								
									
										37
									
								
								examples/mercury/micro/client/client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								examples/mercury/micro/client/client.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/micro/go-micro/client" | ||||
| 	mcodec "github.com/micro/go-plugins/codec/mercury" | ||||
| 	"github.com/micro/go-plugins/selector/mercury" | ||||
| 	"github.com/micro/go-plugins/transport/rabbitmq" | ||||
| 	hello "github.com/micro/micro/examples/greeter/server/proto/hello" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| 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) | ||||
| } | ||||
							
								
								
									
										38
									
								
								examples/mercury/micro/server/server.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								examples/mercury/micro/server/server.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"flag" | ||||
| 	"github.com/micro/go-micro/server" | ||||
| 	mcodec "github.com/micro/go-plugins/codec/mercury" | ||||
| 	"github.com/micro/go-plugins/transport/rabbitmq" | ||||
| 	hello "github.com/micro/micro/examples/greeter/server/proto/hello" | ||||
|  | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| type Say struct{} | ||||
|  | ||||
| func (s *Say) Hello(ctx context.Context, req *hello.Request, rsp *hello.Response) error { | ||||
| 	rsp.Msg = "Hey " + req.Name | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| 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 {} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user