Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Find file Copy path
@asim asim fix race ea014d7 Feb 13, 2019
1 contributor

Users who have contributed to this file

59 lines (48 sloc) 1.29 KB
package grpc
import (
"time"
"github.com/micro/go-grpc/broker"
"github.com/micro/go-grpc/client"
"github.com/micro/go-grpc/server"
"github.com/micro/go-micro"
)
// NewService returns a grpc service compatible with go-micro.Service
func NewService(opts ...micro.Option) micro.Service {
// our grpc client
c := client.NewClient()
// our grpc server
s := server.NewServer()
// our grpc broker
b := broker.NewBroker()
// create options with priority for our opts
options := []micro.Option{
micro.Client(c),
micro.Server(s),
micro.Broker(b),
}
// append passed in opts
options = append(options, opts...)
// generate and return a service
return micro.NewService(options...)
}
// NewFunction returns a grpc service compatible with go-micro.Function
func NewFunction(opts ...micro.Option) micro.Function {
// our grpc client
c := client.NewClient()
// our grpc server
s := server.NewServer()
// our grpc broker
b := broker.NewBroker()
// create options with priority for our opts
options := []micro.Option{
micro.Client(c),
micro.Server(s),
micro.Broker(b),
micro.RegisterTTL(time.Minute),
micro.RegisterInterval(time.Second * 30),
}
// append passed in opts
options = append(options, opts...)
// generate and return a function
return micro.NewFunction(options...)
}
You can’t perform that action at this time.