Separate out grpc client to package local for thumbnails service.

This commit is contained in:
Daniel Swärd
2023-07-27 12:22:28 +02:00
parent 94aab8b38d
commit d21b03b14c
4 changed files with 12 additions and 3 deletions
+7 -1
View File
@@ -12,6 +12,7 @@ import (
ociscrypto "github.com/owncloud/ocis/v2/ocis-pkg/crypto"
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
"go-micro.dev/v4"
"go-micro.dev/v4/client"
"go-micro.dev/v4/server"
)
@@ -22,6 +23,11 @@ type Service struct {
// NewService initializes a new grpc service.
func NewService(opts ...Option) (Service, error) {
return NewServiceWithClient(DefaultClient(), opts...)
}
// NewServiceWithClient initializes a new grpc service with explicit client.
func NewServiceWithClient(client client.Client, opts ...Option) (Service, error) {
var mServer server.Server
sopts := newOptions(opts...)
tlsConfig := &tls.Config{}
@@ -52,7 +58,7 @@ func NewService(opts ...Option) (Service, error) {
// first add a server because it will reset any options
micro.Server(mServer),
// also add a client that can be used after initializing the service
micro.Client(DefaultClient()),
micro.Client(client),
micro.Address(sopts.Address),
micro.Name(strings.Join([]string{sopts.Namespace, sopts.Name}, ".")),
micro.Version(sopts.Version),