refactored/renamed: ScriptRunner => Corredor
This commit is contained in:
@@ -37,7 +37,7 @@ func Configure() *cli.Config {
|
||||
|
||||
cli.HandleError(service.Init(ctx, c.Log, service.Config{
|
||||
Storage: *c.StorageOpt,
|
||||
ScriptRunner: *c.ScriptRunner,
|
||||
Corredor: *c.ScriptRunner,
|
||||
GRPCClientSystem: *c.GRPCServerSystem,
|
||||
}))
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ type (
|
||||
|
||||
Config struct {
|
||||
Storage options.StorageOpt
|
||||
ScriptRunner options.ScriptRunnerOpt
|
||||
Corredor options.CorredorOpt
|
||||
GRPCClientSystem options.GRPCServerOpt
|
||||
}
|
||||
)
|
||||
@@ -106,10 +106,10 @@ func Init(ctx context.Context, log *zap.Logger, c Config) (err error) {
|
||||
{
|
||||
var scriptRunnerClient proto.ScriptRunnerClient
|
||||
|
||||
if c.ScriptRunner.Enabled {
|
||||
corredor, err := automation.Corredor(ctx, c.ScriptRunner, DefaultLogger)
|
||||
if c.Corredor.Enabled {
|
||||
corredor, err := automation.Corredor(ctx, c.Corredor, DefaultLogger)
|
||||
|
||||
log.Info("initializing corredor connection", zap.String("addr", c.ScriptRunner.Addr), zap.Error(err))
|
||||
log.Info("initializing corredor connection", zap.String("addr", c.Corredor.Addr), zap.Error(err))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Corredor standard connector to Corredor service via gRPC
|
||||
func Corredor(ctx context.Context, opt options.ScriptRunnerOpt, logger *zap.Logger) (c *grpc.ClientConn, err error) {
|
||||
func Corredor(ctx context.Context, opt options.CorredorOpt, logger *zap.Logger) (c *grpc.ClientConn, err error) {
|
||||
if !opt.Enabled {
|
||||
// Do not connect when script runner is not enabled
|
||||
return
|
||||
|
||||
33
pkg/cli/options/corredor.go
Normal file
33
pkg/cli/options/corredor.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
CorredorOpt struct {
|
||||
Enabled bool `env:"CORREDOR_ENABLED"`
|
||||
|
||||
// Also used by corredor service to configure gRPC server
|
||||
Addr string `env:"CORREDOR_ADDR"`
|
||||
|
||||
// Also used by corredor service to enable logging
|
||||
Log bool `env:"CORREDOR_LOG_ENABLED"`
|
||||
|
||||
MaxBackoffDelay time.Duration `env:"CORREDOR_MAX_BACKOFF_DELAY"`
|
||||
Log bool `env:"CORREDOR_LOG_ENABLED"`
|
||||
}
|
||||
)
|
||||
|
||||
func Corredor(pfix string) (o *CorredorOpt) {
|
||||
o = &CorredorOpt{
|
||||
Enabled: false,
|
||||
Addr: "corredor:80",
|
||||
MaxBackoffDelay: time.Minute,
|
||||
Log: false,
|
||||
}
|
||||
|
||||
fill(o, pfix)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
ScriptRunnerOpt struct {
|
||||
Enabled bool `env:"SCRIPT_RUNNER_ENABLED"`
|
||||
Addr string `env:"SCRIPT_RUNNER_ADDR"`
|
||||
MaxBackoffDelay time.Duration `env:"SCRIPT_RUNNER_MAX_BACKOFF_DELAY"`
|
||||
Log bool `env:"SCRIPT_RUNNER_LOG"`
|
||||
}
|
||||
)
|
||||
|
||||
func ScriptRunner(pfix string) (o *ScriptRunnerOpt) {
|
||||
o = &ScriptRunnerOpt{
|
||||
Enabled: false,
|
||||
Addr: "corredor:80",
|
||||
MaxBackoffDelay: time.Minute,
|
||||
Log: false,
|
||||
}
|
||||
|
||||
fill(o, pfix)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -50,7 +50,7 @@ type (
|
||||
ProvisionOpt *options.ProvisionOpt
|
||||
SentryOpt *options.SentryOpt
|
||||
StorageOpt *options.StorageOpt
|
||||
ScriptRunner *options.ScriptRunnerOpt
|
||||
ScriptRunner *options.CorredorOpt
|
||||
|
||||
// Services will be calling each other so we need
|
||||
// to keep the config opts spearated
|
||||
@@ -195,7 +195,7 @@ func (c *Config) Init() {
|
||||
c.ProvisionOpt = options.Provision(c.ServiceName)
|
||||
c.SentryOpt = options.Sentry(c.EnvPrefix)
|
||||
c.StorageOpt = options.Storage(c.EnvPrefix)
|
||||
c.ScriptRunner = options.ScriptRunner(c.EnvPrefix)
|
||||
c.ScriptRunner = options.Corredor(c.EnvPrefix)
|
||||
c.GRPCServerSystem = options.GRPCServer("system")
|
||||
// c.GRPCServerCompose = options.GRPCServer("compose")
|
||||
// c.GRPCServerMessagign = options.GRPCServer("messaging")
|
||||
|
||||
Reference in New Issue
Block a user