2015-12-20 23:50:16 +00:00
|
|
|
/*
|
|
|
|
Go micro provides a pluggable library to build microservices.
|
|
|
|
|
|
|
|
import (
|
|
|
|
micro "github.com/micro/go-micro"
|
|
|
|
)
|
|
|
|
|
2015-12-20 23:52:58 +00:00
|
|
|
service := micro.NewService()
|
2015-12-20 23:50:16 +00:00
|
|
|
h := service.Server().NewHandler(&Greeter{})
|
|
|
|
service.Server().Handle(h)
|
|
|
|
service.Run()
|
|
|
|
|
|
|
|
|
2015-12-20 23:52:58 +00:00
|
|
|
req := service.Client().NewRequest(service, method, request)
|
2015-12-20 23:50:16 +00:00
|
|
|
rsp := response{}
|
2015-12-20 23:52:58 +00:00
|
|
|
err := service.Client().Call(req, rsp)
|
2015-12-20 23:50:16 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-01-02 19:14:56 +00:00
|
|
|
package micro
|
2015-12-20 23:50:16 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/micro/go-micro/client"
|
|
|
|
"github.com/micro/go-micro/server"
|
|
|
|
)
|
|
|
|
|
2015-12-23 00:02:42 +00:00
|
|
|
// Service is an interface that wraps the lower level libraries
|
|
|
|
// within go-micro. Its a convenience method for building
|
|
|
|
// and initialising services.
|
2015-12-20 23:50:16 +00:00
|
|
|
type Service interface {
|
2016-01-01 01:16:21 +00:00
|
|
|
Init(...Option)
|
2016-01-02 19:12:17 +00:00
|
|
|
Options() Options
|
2015-12-20 23:50:16 +00:00
|
|
|
Client() client.Client
|
|
|
|
Server() server.Server
|
|
|
|
Run() error
|
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Option func(*Options)
|
|
|
|
|
|
|
|
var (
|
2015-12-21 01:12:29 +00:00
|
|
|
HeaderPrefix = "X-Micro-"
|
2015-12-20 23:50:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewService(opts ...Option) Service {
|
|
|
|
return newService(opts...)
|
|
|
|
}
|