From 76c633e650de6f6afa324eb75dcf2ce03d66b195 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 11 Nov 2020 11:50:53 +0100 Subject: [PATCH] wip --- accounts/pkg/service/v0/permissions.go | 5 +++-- accounts/pkg/service/v0/service.go | 6 ++++-- accounts/pkg/service/v0/settings.go | 4 ++-- glauth/pkg/command/server.go | 7 ++++--- ocis-pkg/go.sum | 2 ++ ocis-pkg/service/grpc/service.go | 14 ++++++++++++++ ocis/go.sum | 3 +++ ocs/pkg/service/v0/service.go | 4 ++-- proxy/pkg/command/server.go | 6 +++--- 9 files changed, 37 insertions(+), 14 deletions(-) diff --git a/accounts/pkg/service/v0/permissions.go b/accounts/pkg/service/v0/permissions.go index 62c5668d6..bb45a3be9 100644 --- a/accounts/pkg/service/v0/permissions.go +++ b/accounts/pkg/service/v0/permissions.go @@ -3,7 +3,8 @@ package service import ( "context" - mclient "github.com/micro/go-micro/v2/client" + "github.com/owncloud/ocis/ocis-pkg/service/grpc" + olog "github.com/owncloud/ocis/ocis-pkg/log" settings "github.com/owncloud/ocis/settings/pkg/proto/v0" ssvc "github.com/owncloud/ocis/settings/pkg/service/v0" @@ -28,7 +29,7 @@ const ( func RegisterPermissions(l *olog.Logger) { // TODO this won't work with a registry other than mdns. Look into Micro's client initialization. // https://github.com/owncloud/ocis-proxy/issues/38 - service := settings.NewBundleService("com.owncloud.api.settings", mclient.DefaultClient) + service := settings.NewBundleService("com.owncloud.api.settings", grpc.DefaultClient) permissionRequests := generateAccountManagementPermissionsRequests() for i := range permissionRequests { diff --git a/accounts/pkg/service/v0/service.go b/accounts/pkg/service/v0/service.go index 231568d44..65242cb27 100644 --- a/accounts/pkg/service/v0/service.go +++ b/accounts/pkg/service/v0/service.go @@ -9,12 +9,14 @@ import ( "strings" "time" + "github.com/owncloud/ocis/ocis-pkg/service/grpc" + "github.com/owncloud/ocis/accounts/pkg/storage" "github.com/owncloud/ocis/ocis-pkg/indexer" idxcfg "github.com/owncloud/ocis/ocis-pkg/indexer/config" idxerrs "github.com/owncloud/ocis/ocis-pkg/indexer/errors" - mclient "github.com/micro/go-micro/v2/client" + //mclient "github.com/micro/go-micro/v2/client" "github.com/owncloud/ocis/accounts/pkg/config" "github.com/owncloud/ocis/accounts/pkg/proto/v0" "github.com/owncloud/ocis/ocis-pkg/log" @@ -36,7 +38,7 @@ func New(opts ...Option) (s *Service, err error) { if roleService == nil { // https://github.com/owncloud/ocis-proxy/issues/38 // TODO this won't work with a registry other than mdns. Look into Micro's client initialization. - roleService = settings.NewRoleService("com.owncloud.api.settings", mclient.DefaultClient) + roleService = settings.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient) } roleManager := options.RoleManager if roleManager == nil { diff --git a/accounts/pkg/service/v0/settings.go b/accounts/pkg/service/v0/settings.go index c2c2990c5..3d16d37a7 100644 --- a/accounts/pkg/service/v0/settings.go +++ b/accounts/pkg/service/v0/settings.go @@ -3,8 +3,8 @@ package service import ( "context" - mclient "github.com/micro/go-micro/v2/client" olog "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/ocis-pkg/service/grpc" settings "github.com/owncloud/ocis/settings/pkg/proto/v0" ssvc "github.com/owncloud/ocis/settings/pkg/service/v0" ) @@ -17,7 +17,7 @@ const ( func RegisterSettingsBundles(l *olog.Logger) { // TODO this won't work with a registry other than mdns. Look into Micro's client initialization. // https://github.com/owncloud/ocis-proxy/issues/38 - service := settings.NewBundleService("com.owncloud.api.settings", mclient.DefaultClient) + service := settings.NewBundleService("com.owncloud.api.settings", grpc.DefaultClient) bundleRequests := []settings.SaveBundleRequest{ generateBundleProfileRequest(), diff --git a/glauth/pkg/command/server.go b/glauth/pkg/command/server.go index 674b4c8fd..813dd0a6d 100644 --- a/glauth/pkg/command/server.go +++ b/glauth/pkg/command/server.go @@ -7,6 +7,8 @@ import ( "strings" "time" + "github.com/owncloud/ocis/ocis-pkg/service/grpc" + "github.com/owncloud/ocis/glauth/pkg/metrics" "github.com/owncloud/ocis/glauth/pkg/crypto" @@ -17,7 +19,6 @@ import ( glauthcfg "github.com/glauth/glauth/pkg/config" "github.com/micro/cli/v2" - "github.com/micro/go-micro/v2/client" "github.com/oklog/run" openzipkin "github.com/openzipkin/zipkin-go" zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" @@ -309,6 +310,6 @@ func Server(cfg *config.Config) *cli.Command { // getAccountsServices returns an ocis-accounts service func getAccountsServices() (accounts.AccountsService, accounts.GroupsService) { - return accounts.NewAccountsService("com.owncloud.api.accounts", client.DefaultClient), - accounts.NewGroupsService("com.owncloud.api.accounts", client.DefaultClient) + return accounts.NewAccountsService("com.owncloud.api.accounts", grpc.DefaultClient), + accounts.NewGroupsService("com.owncloud.api.accounts", grpc.DefaultClient) } diff --git a/ocis-pkg/go.sum b/ocis-pkg/go.sum index b4518c975..ae6619d8b 100644 --- a/ocis-pkg/go.sum +++ b/ocis-pkg/go.sum @@ -775,6 +775,8 @@ github.com/micro/cli/v2 v2.1.2 h1:43J1lChg/rZCC1rvdqZNFSQDrGT7qfMrtp6/ztpIkEM= github.com/micro/cli/v2 v2.1.2/go.mod h1:EguNh6DAoWKm9nmk+k/Rg0H3lQnDxqzu5x5srOtGtYg= github.com/micro/go-micro/v2 v2.9.1 h1:+S9koIrNWARjpP6k2TZ7kt0uC9zUJtNXzIdZTZRms7Q= github.com/micro/go-micro/v2 v2.9.1/go.mod h1:x55ZM3Puy0FyvvkR3e0ha0xsE9DFwfPSUMWAIbFY0SY= +github.com/micro/go-plugins v1.5.1 h1:swcFD7ynCTUo98APqIEIbPu2XMd6yVGTnI8PqdnCwOQ= +github.com/micro/go-plugins/v2 v2.0.0 h1:QbzQBaOVNtAIhjTgtLoOHtlhcwNFbcJenEsT66IwpkQ= github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1 h1:IaZUsLp0Omb/ozDnRKEvVY56C0UocBdPxxg2S2Pk2j0= github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1/go.mod h1:26UmOLM/I487NqTg3n6zJiBrYmIb684M2Zp4WH98XzU= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= diff --git a/ocis-pkg/service/grpc/service.go b/ocis-pkg/service/grpc/service.go index c50039fcc..f349b6505 100644 --- a/ocis-pkg/service/grpc/service.go +++ b/ocis-pkg/service/grpc/service.go @@ -1,14 +1,26 @@ package grpc import ( + "fmt" "strings" "time" "github.com/micro/go-micro/v2" + mclient "github.com/micro/go-micro/v2/client" + "github.com/micro/go-micro/v2/client/grpc" "github.com/micro/go-plugins/wrapper/trace/opencensus/v2" "github.com/owncloud/ocis/ocis-pkg/wrapper/prometheus" ) +var DefaultClient = newGrpcClient() + +func newGrpcClient() mclient.Client { + c := grpc.NewClient( + mclient.RequestTimeout(10 * time.Second), + ) + return c +} + // Service simply wraps the go-micro grpc service. type Service struct { micro.Service @@ -17,6 +29,7 @@ type Service struct { // NewService initializes a new grpc service. func NewService(opts ...Option) Service { sopts := newOptions(opts...) + fmt.Printf("\n\n%v\n\n", sopts.Name) sopts.Logger.Info(). Str("transport", "grpc"). @@ -33,6 +46,7 @@ func NewService(opts ...Option) Service { ".", ), ), + micro.Client(DefaultClient), micro.Version(sopts.Version), micro.Address(sopts.Address), micro.WrapHandler(prometheus.NewHandlerWrapper()), diff --git a/ocis/go.sum b/ocis/go.sum index 98dfc5560..994ee8ae4 100644 --- a/ocis/go.sum +++ b/ocis/go.sum @@ -351,6 +351,8 @@ github.com/glauth/glauth v1.1.3-0.20201005201919-4d42af8aacbf h1:3ejnL7OvxCJ6XiE github.com/glauth/glauth v1.1.3-0.20201005201919-4d42af8aacbf/go.mod h1:ygO1z1pcp79iBrjbA6vqrsUxIonStjBncosl2a9/Dx8= github.com/glauth/glauth v1.1.3-0.20201030130813-4f029234b230 h1:2oT6sD4SUhZ94BXf0NmOaKCwbkzsweBTYRPnyTDP7xY= github.com/glauth/glauth v1.1.3-0.20201030130813-4f029234b230/go.mod h1:ygO1z1pcp79iBrjbA6vqrsUxIonStjBncosl2a9/Dx8= +github.com/glauth/glauth v1.1.3-0.20201110124627-fd3ac7e4bbdc h1:xbCdy5zNO0CBDIpXQ9l4dfwgnTmjk9B0YyRjJkRndCc= +github.com/glauth/glauth v1.1.3-0.20201110124627-fd3ac7e4bbdc/go.mod h1:ygO1z1pcp79iBrjbA6vqrsUxIonStjBncosl2a9/Dx8= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4= @@ -921,6 +923,7 @@ github.com/micro/go-micro/v2 v2.0.0/go.mod h1:v7QP5UhKRt37ixjJe8DouWmg0/eE6dltr5 github.com/micro/go-micro/v2 v2.8.0/go.mod h1:hSdOM6jb6aGswjBpCeB9wJ0yVH+CugevRm/CX7NlSrQ= github.com/micro/go-micro/v2 v2.9.1 h1:+S9koIrNWARjpP6k2TZ7kt0uC9zUJtNXzIdZTZRms7Q= github.com/micro/go-micro/v2 v2.9.1/go.mod h1:x55ZM3Puy0FyvvkR3e0ha0xsE9DFwfPSUMWAIbFY0SY= +github.com/micro/go-plugins v1.5.1 h1:swcFD7ynCTUo98APqIEIbPu2XMd6yVGTnI8PqdnCwOQ= github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.0.1/go.mod h1:QrkcwcDtIs2hIJpIEhozekyf6Rfz5C36kFI8+zzCpX0= github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1 h1:IaZUsLp0Omb/ozDnRKEvVY56C0UocBdPxxg2S2Pk2j0= github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1/go.mod h1:26UmOLM/I487NqTg3n6zJiBrYmIb684M2Zp4WH98XzU= diff --git a/ocs/pkg/service/v0/service.go b/ocs/pkg/service/v0/service.go index d1817b41d..c59a64e3a 100644 --- a/ocs/pkg/service/v0/service.go +++ b/ocs/pkg/service/v0/service.go @@ -8,8 +8,8 @@ import ( "github.com/go-chi/chi/middleware" "github.com/go-chi/render" "github.com/micro/go-micro/v2/client/grpc" + ogrpc "github.com/owncloud/ocis/ocis-pkg/service/grpc" - mclient "github.com/micro/go-micro/v2/client" accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0" "github.com/owncloud/ocis/ocis-pkg/account" "github.com/owncloud/ocis/ocis-pkg/log" @@ -41,7 +41,7 @@ func NewService(opts ...Option) Service { if roleService == nil { // https://github.com/owncloud/ocis-proxy/issues/38 // TODO this won't work with a registry other than mdns. Look into Micro's client initialization. - roleService = settings.NewRoleService("com.owncloud.api.settings", mclient.DefaultClient) + roleService = settings.NewRoleService("com.owncloud.api.settings", ogrpc.DefaultClient) } roleManager := options.RoleManager if roleManager == nil { diff --git a/proxy/pkg/command/server.go b/proxy/pkg/command/server.go index 2d3e2c7d6..cfd2d1f4f 100644 --- a/proxy/pkg/command/server.go +++ b/proxy/pkg/command/server.go @@ -15,13 +15,13 @@ import ( "github.com/coreos/go-oidc" "github.com/justinas/alice" "github.com/micro/cli/v2" - mclient "github.com/micro/go-micro/v2/client" "github.com/micro/go-micro/v2/client/grpc" "github.com/oklog/run" openzipkin "github.com/openzipkin/zipkin-go" zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" acc "github.com/owncloud/ocis/accounts/pkg/proto/v0" "github.com/owncloud/ocis/ocis-pkg/log" + ogrpc "github.com/owncloud/ocis/ocis-pkg/service/grpc" "github.com/owncloud/ocis/proxy/pkg/config" "github.com/owncloud/ocis/proxy/pkg/cs3" "github.com/owncloud/ocis/proxy/pkg/flagset" @@ -254,8 +254,8 @@ func loadMiddlewares(ctx context.Context, l log.Logger, cfg *config.Config) alic // TODO this won't work with a registry other than mdns. Look into Micro's client initialization. // https://github.com/owncloud/ocis/proxy/issues/38 - accounts := acc.NewAccountsService("com.owncloud.api.accounts", mclient.DefaultClient) - roles := settings.NewRoleService("com.owncloud.api.settings", mclient.DefaultClient) + accounts := acc.NewAccountsService("com.owncloud.api.accounts", ogrpc.DefaultClient) + roles := settings.NewRoleService("com.owncloud.api.settings", ogrpc.DefaultClient) uuidMW := middleware.AccountUUID( middleware.Logger(l),