Skip to content

Commit

Permalink
Add Enabled Flag For GRPC Archive
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
  • Loading branch information
mahadzaryab1 committed Jan 24, 2025
1 parent 89ba32d commit ba068b1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions plugin/storage/grpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Config struct {
Tenancy tenancy.Options `mapstructure:"multi_tenancy"`
configgrpc.ClientConfig `mapstructure:",squash"`
exporterhelper.TimeoutConfig `mapstructure:",squash"`
enabled bool
}

func DefaultConfig() Config {
Expand Down
11 changes: 8 additions & 3 deletions plugin/storage/grpc/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ import (
)

var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
_ storage.Factory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
_ plugin.ArchiveCapable = (*Factory)(nil)
)

// Factory implements storage.Factory and creates storage components backed by a storage plugin.
Expand Down Expand Up @@ -210,3 +211,7 @@ func getTelset(logger *zap.Logger, tracerProvider trace.TracerProvider, meterPro
MeterProvider: meterProvider,
}
}

func (f *Factory) IsArchiveCapable() bool {
return f.options.namespace == archiveRemotePrefix && f.options.enabled

Check warning on line 216 in plugin/storage/grpc/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/grpc/factory.go#L215-L216

Added lines #L215 - L216 were not covered by tests
}
10 changes: 10 additions & 0 deletions plugin/storage/grpc/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
archiveRemotePrefix = "grpc-storage-archive"
remoteServer = ".server"
remoteConnectionTimeout = ".connection-timeout"
enabled = ".enabled"
defaultConnectionTimeout = time.Duration(5 * time.Second)
)

Expand Down Expand Up @@ -47,6 +48,12 @@ func (opts *options) addFlags(flagSet *flag.FlagSet) {

flagSet.String(opts.namespace+remoteServer, "", "The remote storage gRPC server address as host:port")
flagSet.Duration(opts.namespace+remoteConnectionTimeout, defaultConnectionTimeout, "The remote storage gRPC server connection timeout")
if opts.namespace == archiveRemotePrefix {
flagSet.Bool(
opts.namespace+enabled,
false,
"Enable extra storage")
}
}

func (opts *options) initFromViper(cfg *Config, v *viper.Viper) error {
Expand All @@ -58,5 +65,8 @@ func (opts *options) initFromViper(cfg *Config, v *viper.Viper) error {
cfg.ClientConfig.TLSSetting = remoteTLSCfg
cfg.TimeoutConfig.Timeout = v.GetDuration(opts.namespace + remoteConnectionTimeout)
cfg.Tenancy = tenancy.InitFromViper(v)
if opts.namespace == archiveRemotePrefix {
cfg.enabled = v.GetBool(opts.namespace + enabled)
}
return nil
}
1 change: 1 addition & 0 deletions plugin/storage/integration/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestGRPCRemoteStorage(t *testing.T) {
"--grpc-storage.tls.enabled=false",
},
archiveFlags: []string{
"--grpc-storage-archive.enabled=true",
"--grpc-storage-archive.server=localhost:17272",
"--grpc-storage-archive.tls.enabled=false",
},
Expand Down

0 comments on commit ba068b1

Please sign in to comment.