always pass in a client

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2021-02-18 10:58:56 +00:00
parent 11ed5e49d8
commit d9f4a4c524
6 changed files with 13 additions and 21 deletions
+8 -18
View File
@@ -4,29 +4,16 @@ import (
"strings"
"time"
grpcc "github.com/asim/go-micro/plugins/client/grpc/v3"
"github.com/asim/go-micro/v3"
"github.com/asim/go-micro/v3/client"
"github.com/asim/go-micro/plugins/server/grpc/v3"
mgrpcc "github.com/asim/go-micro/plugins/client/grpc/v3"
mgrpcs "github.com/asim/go-micro/plugins/server/grpc/v3"
"github.com/asim/go-micro/plugins/wrapper/monitoring/prometheus/v3"
"github.com/asim/go-micro/plugins/wrapper/trace/opencensus/v3"
"github.com/asim/go-micro/v3"
"github.com/owncloud/ocis/ocis-pkg/registry"
)
// DefaultClient is a custom ocis grpc configured client.
var DefaultClient = newGrpcClient()
func newGrpcClient() client.Client {
//r := *registry.GetRegistry()
c := grpcc.NewClient(
//grpcc.RequestTimeout(10*time.Second),
//grpcc.Registry(r),
)
return c
}
var DefaultClient = mgrpcc.NewClient()
// Service simply wraps the go-micro grpc service.
type Service struct {
@@ -43,7 +30,10 @@ func NewService(opts ...Option) Service {
Msg("starting server")
mopts := []micro.Option{
micro.Server(grpc.NewServer()),
// first add a server because it will reset any options
micro.Server(mgrpcs.NewServer()),
// also add a client that can be used after initializing the service
micro.Client(mgrpcc.NewClient()),
micro.Address(sopts.Address),
micro.Name(strings.Join([]string{sopts.Namespace, sopts.Name}, ".")),
micro.Version(sopts.Version),
+2 -2
View File
@@ -7,7 +7,7 @@ import (
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/asim/go-micro/plugins/server/http/v3"
mhttps "github.com/asim/go-micro/plugins/server/http/v3"
"github.com/asim/go-micro/v3"
"github.com/asim/go-micro/v3/server"
)
@@ -26,7 +26,7 @@ func NewService(opts ...Option) Service {
Msg("starting server")
wopts := []micro.Option{
micro.Server(http.NewServer(server.TLSConfig(sopts.TLSConfig))),
micro.Server(mhttps.NewServer(server.TLSConfig(sopts.TLSConfig))),
micro.Address(sopts.Address),
micro.Name(strings.Join([]string{sopts.Namespace, sopts.Name}, ".")),
micro.Version(sopts.Version),