2015-01-14 02:31:27 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-01-31 18:49:21 +03:00
|
|
|
log "github.com/golang/glog"
|
2015-11-20 19:17:33 +03:00
|
|
|
"github.com/micro/go-micro/cmd"
|
|
|
|
"github.com/micro/go-micro/examples/server/handler"
|
|
|
|
"github.com/micro/go-micro/examples/server/subscriber"
|
|
|
|
"github.com/micro/go-micro/server"
|
2015-01-14 02:31:27 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2015-02-15 02:33:21 +03:00
|
|
|
// optionally setup command line usage
|
|
|
|
cmd.Init()
|
|
|
|
|
2015-01-14 02:31:27 +03:00
|
|
|
// Initialise Server
|
2015-05-27 00:39:48 +03:00
|
|
|
server.Init(
|
|
|
|
server.Name("go.micro.srv.example"),
|
|
|
|
)
|
2015-01-14 02:31:27 +03:00
|
|
|
|
|
|
|
// Register Handlers
|
2015-06-03 03:25:37 +03:00
|
|
|
server.Handle(
|
|
|
|
server.NewHandler(
|
2015-01-14 02:31:27 +03:00
|
|
|
new(handler.Example),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2015-06-12 21:52:27 +03: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-14 02:31:27 +03:00
|
|
|
// Run server
|
|
|
|
if err := server.Run(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|