1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-17 17:44:30 +02:00
2020-12-26 15:17:20 +00:00

52 lines
829 B
Go

package main
import (
"log"
"github.com/micro/examples/server/handler"
"github.com/micro/examples/server/subscriber"
"github.com/micro/go-micro/v2/config/cmd"
"github.com/micro/go-micro/v2/server"
)
func main() {
// optionally setup command line usage
cmd.Init()
// Initialise Server
server.Init(
server.Name("go.micro.srv.example"),
)
// Register Handlers
server.Handle(
server.NewHandler(
new(handler.Example),
),
)
// Register Subscribers
if err := server.Subscribe(
server.NewSubscriber(
"topic.example",
new(subscriber.Example),
),
); err != nil {
log.Fatal(err)
}
if err := server.Subscribe(
server.NewSubscriber(
"topic.example",
subscriber.Handler,
),
); err != nil {
log.Fatal(err)
}
// Run server
if err := server.Run(); err != nil {
log.Fatal(err)
}
}