Skip to content

Commit

Permalink
update srv template
Browse files Browse the repository at this point in the history
  • Loading branch information
Asim Aslam committed Apr 17, 2018
1 parent 334d62b commit 38ceb7d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion template/srv/handler/example.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package handler

import (
"context"

"github.com/micro/go-log"

"context"
example "github.com/micro/examples/template/srv/proto/example"
)

Expand Down
12 changes: 4 additions & 8 deletions template/srv/main.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
package main

import (
"github.com/micro/examples/template/srv/handler"
"github.com/micro/examples/template/srv/subscriber"
"github.com/micro/go-log"
"github.com/micro/go-micro"
"github.com/micro/go-plugins/registry/etcdv3"
"github.com/micro/examples/template/srv/handler"
"github.com/micro/examples/template/srv/subscriber"

example "github.com/micro/examples/template/srv/proto/example"
)

func main() {
r := etcdv3.NewRegistry()

// New Service
service := micro.NewService(
micro.Name("go.micro.srv.template"),
micro.Version("latest"),
micro.Registry(r),
)

// Register Handler
example.RegisterExampleHandler(service.Server(), new(handler.Example))

// Register Struct as Subscriber
micro.RegisterSubscriber("topic.go.micro.srv.template", service.Server(), new(subscriber.Example))
micro.RegisterSubscriber("go.micro.srv.template", service.Server(), new(subscriber.Example))

// Register Function as Subscriber
micro.RegisterSubscriber("topic.go.micro.srv.template", service.Server(), subscriber.Handler)
micro.RegisterSubscriber("go.micro.srv.template", service.Server(), subscriber.Handler)

// Initialise service
service.Init()
Expand Down
2 changes: 1 addition & 1 deletion template/srv/proto/example/example.micro.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion template/srv/subscriber/example.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package subscriber

import (
"context"
"github.com/micro/go-log"

"context"
example "github.com/micro/examples/template/srv/proto/example"
)

Expand Down

0 comments on commit 38ceb7d

Please sign in to comment.