Skip to content

Commit

Permalink
feat: integrate additional asset types for server
Browse files Browse the repository at this point in the history
  • Loading branch information
irainia committed Aug 21, 2024
1 parent 21b4d1b commit 8dc15a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func runServer(ctx context.Context, cfg *Config) error {
logger := initLogger(cfg.LogLevel)
logger.Info("compass starting", "version", Version)

if err := registerAdditionalAssetTypes(cfg.Service.AdditionalAssetTypes); err != nil {
return fmt.Errorf("error registering additional asset types: %w", err)
}

nrApp, cleanUp, err := telemetry.Init(ctx, cfg.Telemetry, logger)
if err != nil {
return err
Expand Down Expand Up @@ -259,3 +263,12 @@ func migratePostgres(ctx context.Context, logger log.Logger, config *Config) (er

return nil
}

func registerAdditionalAssetTypes(additionalTypes []string) error {
transformedTypes := make([]asset.Type, len(additionalTypes))
for i := range additionalTypes {
transformedTypes[i] = asset.Type(additionalTypes[i])
}

return asset.RegisterSupportedTypes(transformedTypes...)
}
2 changes: 2 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type Config struct {
RequestTimeout time.Duration `mapstructure:"request_timeout" default:"10s"`
// GRPC Config
GRPC GRPCConfig `mapstructure:"grpc"`

AdditionalAssetTypes []string `mapstructure:"additional_asset_types"`
}

func (cfg Config) addr() string { return fmt.Sprintf("%s:%d", cfg.Host, cfg.Port) }
Expand Down

0 comments on commit 8dc15a8

Please sign in to comment.