From da729b6319f873d63e63cebf3be2848d4d6c46f1 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 18 Dec 2019 12:50:00 +0100 Subject: [PATCH 1/4] added http-namespace flag --- pkg/config/config.go | 3 ++- pkg/flagset/flagset.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 6725438616..0f330f7eec 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -37,7 +37,8 @@ type Asset struct { // Phoenix defines the available phoenic configuration. type Phoenix struct { - Path string + Path string + Namespace string } // Config combines all available configuration parts. diff --git a/pkg/flagset/flagset.go b/pkg/flagset/flagset.go index 48a68a9979..9c1567dc68 100644 --- a/pkg/flagset/flagset.go +++ b/pkg/flagset/flagset.go @@ -141,5 +141,12 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVar: "PHOENIX_WEB_CONFIG", Destination: &cfg.Phoenix.Path, }, + &cli.StringFlag{ + Name: "http-namespace", + Value: "com.owncloud", + Usage: "Set the base namespace for the http namespace", + EnvVar: "PHOENIX_NAMESPACE", + Destination: &cfg.Phoenix.Namespace, + }, } } From d6a80470f27b6acf6273410cea88b32555fa4973 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 18 Dec 2019 12:51:09 +0100 Subject: [PATCH 2/4] added namespace option --- pkg/server/http/option.go | 18 +++++++++++++----- pkg/server/http/server.go | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/server/http/option.go b/pkg/server/http/option.go index 185f1b598d..67c4057637 100644 --- a/pkg/server/http/option.go +++ b/pkg/server/http/option.go @@ -14,11 +14,12 @@ type Option func(o *Options) // Options defines the available options for this package. type Options struct { - Logger log.Logger - Context context.Context - Config *config.Config - Metrics *metrics.Metrics - Flags []cli.Flag + Logger log.Logger + Context context.Context + Config *config.Config + Metrics *metrics.Metrics + Flags []cli.Flag + Namespace string } // newOptions initializes the available default options. @@ -66,3 +67,10 @@ func Flags(val []cli.Flag) Option { o.Flags = append(o.Flags, val...) } } + +// Namespace provides a function to set the Namespace option. +func Namespace(val string) Option { + return func(o *Options) { + o.Namespace = val + } +} diff --git a/pkg/server/http/server.go b/pkg/server/http/server.go index 8305fc431e..c8f89645aa 100644 --- a/pkg/server/http/server.go +++ b/pkg/server/http/server.go @@ -13,7 +13,7 @@ func Server(opts ...Option) (http.Service, error) { service := http.NewService( http.Logger(options.Logger), - http.Namespace("go.micro.web"), + http.Namespace(options.Namespace), http.Name("phoenix"), http.Version(version.String), http.Address(options.Config.HTTP.Addr), From 276aa69451b4bbaec7346dcc92012f21e81a2ef9 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 18 Dec 2019 12:51:28 +0100 Subject: [PATCH 3/4] hardcode web --- pkg/server/http/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/http/server.go b/pkg/server/http/server.go index c8f89645aa..65e50f7c7d 100644 --- a/pkg/server/http/server.go +++ b/pkg/server/http/server.go @@ -14,7 +14,7 @@ func Server(opts ...Option) (http.Service, error) { service := http.NewService( http.Logger(options.Logger), http.Namespace(options.Namespace), - http.Name("phoenix"), + http.Name("web.phoenix"), http.Version(version.String), http.Address(options.Config.HTTP.Addr), http.Context(options.Context), From b922327074fe4ea310ebde7a19a3245964f55e81 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 18 Dec 2019 12:58:02 +0100 Subject: [PATCH 4/4] use http namespace --- pkg/command/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/command/server.go b/pkg/command/server.go index be5b7f0201..8b47339a6f 100644 --- a/pkg/command/server.go +++ b/pkg/command/server.go @@ -38,6 +38,7 @@ func Server(cfg *config.Config) cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) + httpNamespace := c.String("http-namespace") if cfg.Tracing.Enabled { switch t := cfg.Tracing.Type; t { @@ -135,6 +136,7 @@ func Server(cfg *config.Config) cli.Command { server, err := http.Server( http.Logger(logger), http.Context(ctx), + http.Namespace(httpNamespace), http.Config(cfg), http.Metrics(metrics), http.Flags(flagset.RootWithConfig(cfg)),