add missing commands and unify service / namespace options
This commit is contained in:
@@ -30,7 +30,7 @@ func Execute(cfg *config.Config) error {
|
||||
},
|
||||
|
||||
Before: func(c *cli.Context) error {
|
||||
cfg.Server.Version = version.String
|
||||
cfg.Service.Version = version.String
|
||||
return nil
|
||||
},
|
||||
|
||||
|
||||
@@ -43,15 +43,15 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
defer cancel()
|
||||
|
||||
metrics.BuildInfo.WithLabelValues(cfg.Server.Version).Set(1)
|
||||
metrics.BuildInfo.WithLabelValues(cfg.Service.Version).Set(1)
|
||||
|
||||
service := grpc.NewService(
|
||||
grpc.Logger(logger),
|
||||
grpc.Context(ctx),
|
||||
grpc.Config(cfg),
|
||||
grpc.Name(cfg.Server.Name),
|
||||
grpc.Namespace(cfg.Server.Namespace),
|
||||
grpc.Address(cfg.Server.Address),
|
||||
grpc.Name(cfg.Service.Name),
|
||||
grpc.Namespace(cfg.GRPC.Namespace),
|
||||
grpc.Address(cfg.GRPC.Addr),
|
||||
grpc.Metrics(metrics),
|
||||
)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ func PrintVersion(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
reg := registry.GetRegistry()
|
||||
services, err := reg.GetService(cfg.Server.Namespace + "." + cfg.Server.Name)
|
||||
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("could not get thumbnails services from the registry: %v", err))
|
||||
return err
|
||||
|
||||
@@ -16,12 +16,16 @@ type Debug struct {
|
||||
Zpages bool `ocisConfig:"zpages"`
|
||||
}
|
||||
|
||||
// Server defines the available server configuration.
|
||||
type Server struct {
|
||||
Name string `ocisConfig:"name"`
|
||||
// GRPC defines the available grpc configuration.
|
||||
type GRPC struct {
|
||||
Addr string `ocisConfig:"addr"`
|
||||
Namespace string `ocisConfig:"namespace"`
|
||||
Address string `ocisConfig:"address"`
|
||||
Version string `ocisConfig:"version"`
|
||||
}
|
||||
|
||||
// Service provides configuration options for the service
|
||||
type Service struct {
|
||||
Name string `ocisConfig:"name"`
|
||||
Version string `ocisConfig:"version"`
|
||||
}
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
@@ -40,7 +44,8 @@ type Config struct {
|
||||
File string `ocisConfig:"file"`
|
||||
Log *shared.Log `ocisConfig:"log"`
|
||||
Debug Debug `ocisConfig:"debug"`
|
||||
Server Server `ocisConfig:"server"`
|
||||
GRPC GRPC `ocisConfig:"grpc"`
|
||||
Service Service `ocisConfig:"service"`
|
||||
Tracing Tracing `ocisConfig:"tracing"`
|
||||
Thumbnail Thumbnail `ocisConfig:"thumbnail"`
|
||||
|
||||
@@ -82,10 +87,12 @@ func DefaultConfig() *Config {
|
||||
Pprof: false,
|
||||
Zpages: false,
|
||||
},
|
||||
Server: Server{
|
||||
Name: "thumbnails",
|
||||
GRPC: GRPC{
|
||||
Addr: "127.0.0.1:9185",
|
||||
Namespace: "com.owncloud.api",
|
||||
Address: "127.0.0.1:9185",
|
||||
},
|
||||
Service: Service{
|
||||
Name: "thumbnails",
|
||||
},
|
||||
Tracing: Tracing{
|
||||
Enabled: false,
|
||||
|
||||
@@ -80,16 +80,16 @@ func structMappings(cfg *Config) []shared.EnvBinding {
|
||||
Destination: &cfg.Debug.Zpages,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"THUMBNAILS_GRPC_NAME"},
|
||||
Destination: &cfg.Server.Name,
|
||||
EnvVars: []string{"THUMBNAILS_SERVICE_NAME"},
|
||||
Destination: &cfg.Service.Name,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"THUMBNAILS_GRPC_ADDR"},
|
||||
Destination: &cfg.Server.Address,
|
||||
Destination: &cfg.GRPC.Addr,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"THUMBNAILS_GRPC_NAMESPACE"},
|
||||
Destination: &cfg.Server.Namespace,
|
||||
Destination: &cfg.GRPC.Namespace,
|
||||
},
|
||||
{
|
||||
EnvVars: []string{"THUMBNAILS_TXT_FONTMAP_FILE"},
|
||||
|
||||
@@ -14,8 +14,8 @@ func Server(opts ...Option) (*http.Server, error) {
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Server.Name),
|
||||
debug.Version(options.Config.Server.Version),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(options.Config.Service.Version),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
|
||||
@@ -22,7 +22,7 @@ func NewService(opts ...Option) grpc.Service {
|
||||
grpc.Address(options.Address),
|
||||
grpc.Context(options.Context),
|
||||
grpc.Flags(options.Flags...),
|
||||
grpc.Version(options.Config.Server.Version),
|
||||
grpc.Version(options.Config.Service.Version),
|
||||
)
|
||||
tconf := options.Config.Thumbnail
|
||||
gc, err := pool.GetGatewayServiceClient(tconf.RevaGateway)
|
||||
|
||||
@@ -30,7 +30,7 @@ func NewService(opts ...Option) v0proto.ThumbnailServiceHandler {
|
||||
logger.Fatal().Err(err).Msg("resolutions not configured correctly")
|
||||
}
|
||||
svc := Thumbnail{
|
||||
serviceID: options.Config.Server.Namespace + "." + options.Config.Server.Name,
|
||||
serviceID: options.Config.GRPC.Namespace + "." + options.Config.Service.Name,
|
||||
webdavNamespace: options.Config.Thumbnail.WebdavNamespace,
|
||||
manager: thumbnail.NewSimpleManager(
|
||||
resolutions,
|
||||
|
||||
Reference in New Issue
Block a user