2015-01-13 23:31:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-01-31 16:49:21 +01:00
|
|
|
log "github.com/golang/glog"
|
2015-05-05 19:05:06 +01:00
|
|
|
"github.com/myodc/go-micro/cmd"
|
2015-05-25 18:16:42 +01:00
|
|
|
"github.com/myodc/go-micro/examples/server/handler"
|
2015-06-12 19:52:27 +01:00
|
|
|
"github.com/myodc/go-micro/examples/server/subscriber"
|
2015-05-05 19:05:06 +01:00
|
|
|
"github.com/myodc/go-micro/server"
|
2015-01-13 23:31:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2015-02-14 23:33:21 +00:00
|
|
|
// optionally setup command line usage
|
|
|
|
cmd.Init()
|
|
|
|
|
2015-01-13 23:31:27 +00:00
|
|
|
// Initialise Server
|
2015-05-26 22:39:48 +01:00
|
|
|
server.Init(
|
|
|
|
server.Name("go.micro.srv.example"),
|
|
|
|
)
|
2015-01-13 23:31:27 +00:00
|
|
|
|
|
|
|
// Register Handlers
|
2015-06-03 01:25:37 +01:00
|
|
|
server.Handle(
|
|
|
|
server.NewHandler(
|
2015-01-13 23:31:27 +00:00
|
|
|
new(handler.Example),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2015-06-12 19:52:27 +01:00
|
|
|
// Register Subscribers
|
|
|
|
server.Subscribe(
|
|
|
|
server.NewSubscriber(
|
|
|
|
"topic.go.micro.srv.example",
|
|
|
|
new(subscriber.Example),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
server.Subscribe(
|
|
|
|
server.NewSubscriber(
|
|
|
|
"topic.go.micro.srv.example",
|
|
|
|
subscriber.Handler,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2015-01-13 23:31:27 +00:00
|
|
|
// Run server
|
|
|
|
if err := server.Run(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|