52 lines
860 B
Go
Raw Normal View History

2015-01-13 23:31:27 +00:00
package main
import (
2016-03-14 11:01:10 +00:00
"log"
2015-11-20 16:17:33 +00: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-13 23:31:27 +00:00
)
func main() {
// 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
server.Handle(
server.NewHandler(
2015-01-13 23:31:27 +00:00
new(handler.Example),
),
)
// Register Subscribers
if err := server.Subscribe(
server.NewSubscriber(
"topic.go.micro.srv.example",
new(subscriber.Example),
),
); err != nil {
log.Fatal(err)
}
if err := server.Subscribe(
server.NewSubscriber(
"topic.go.micro.srv.example",
subscriber.Handler,
),
); err != nil {
log.Fatal(err)
}
2015-01-13 23:31:27 +00:00
// Run server
if err := server.Run(); err != nil {
log.Fatal(err)
}
}