Created
June 13, 2016 10:50
-
-
Save asim/31584c6da274b6f92960a1eb664d748c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"github.com/micro/go-micro" | |
"github.com/micro/foo/handler" | |
"github.com/micro/foo/subscriber" | |
example "github.com/micro/foo/proto/example" | |
) | |
func main() { | |
// New Service | |
service := micro.NewService( | |
micro.Name("go.micro.srv.foo"), | |
micro.Version("latest"), | |
) | |
// Register Handler | |
example.RegisterExampleHandler(service.Server(), new(handler.Example)) | |
// Register Struct as Subscriber | |
service.Server().Subscribe( | |
service.Server().NewSubscriber("topic.go.micro.srv.foo", new(subscriber.Example)), | |
) | |
// Register Function as Subscriber | |
service.Server().Subscribe( | |
service.Server().NewSubscriber("topic.go.micro.srv.foo", subscriber.Handler), | |
) | |
// Initialise service | |
service.Init() | |
// Run service | |
if err := service.Run(); err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment