Skip to content

Commit

Permalink
Factory changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoBraveCoding committed Nov 14, 2023
1 parent d8dbf6e commit d5c5760
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/storage/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/grafana/dskit/flagext"

"github.com/grafana/loki/pkg/storage/bucket"
"github.com/grafana/loki/pkg/storage/chunk/cache"
"github.com/grafana/loki/pkg/storage/chunk/client"
"github.com/grafana/loki/pkg/storage/chunk/client/alibaba"
Expand All @@ -40,6 +41,7 @@ import (
"github.com/grafana/loki/pkg/storage/stores/shipper/indexshipper/indexgateway"
"github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/constants"
utilLog "github.com/grafana/loki/pkg/util/log"
)

var (
Expand Down Expand Up @@ -333,6 +335,9 @@ type Config struct {
DisableBroadIndexQueries bool `yaml:"disable_broad_index_queries"`
MaxParallelGetChunk int `yaml:"max_parallel_get_chunk"`

ThanosObjStore bool `yaml:"thanos_objstore"`
ObjStoreConf bucket.Config `yaml:"objstore_config"`

MaxChunkBatchSize int `yaml:"max_chunk_batch_size"`
BoltDBShipperConfig boltdb.IndexCfg `yaml:"boltdb_shipper" doc:"description=Configures storing index in an Object Store (GCS/S3/Azure/Swift/COS/Filesystem) in the form of boltdb files. Required fields only required when boltdb-shipper is defined in config."`
TSDBShipperConfig indexshipper.Config `yaml:"tsdb_shipper" doc:"description=Configures storing index in an Object Store (GCS/S3/Azure/Swift/COS/Filesystem) in a prometheus TSDB-like format. Required fields only required when TSDB is defined in config."`
Expand Down Expand Up @@ -360,6 +365,8 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
cfg.Hedging.RegisterFlagsWithPrefix("store.", f)
cfg.CongestionControl.RegisterFlagsWithPrefix("store.", f)

cfg.ObjStoreConf.RegisterFlags(f)

cfg.IndexQueriesCacheConfig.RegisterFlagsWithPrefix("store.index-cache-read.", "", f)
f.DurationVar(&cfg.IndexCacheValidity, "store.index-cache-validity", 5*time.Minute, "Cache validity for active index entries. Should be no higher than -ingester.max-chunk-idle.")
f.StringVar(&cfg.ObjectPrefix, "store.object-prefix", "", "The prefix to all keys inserted in object storage. Example: loki-instances/west/")
Expand Down Expand Up @@ -398,6 +405,10 @@ func (cfg *Config) Validate() error {
return errors.Wrap(err, "invalid bloom shipper config")
}

if err := cfg.ObjStoreConf.Validate(); err != nil {
return err
}

return cfg.NamedStores.Validate()
}

Expand Down Expand Up @@ -676,6 +687,12 @@ func internalNewObjectClient(name string, cfg Config, clientMetrics ClientMetric
}
s3Cfg = awsCfg.S3Config
}
if cfg.ThanosObjStore {
// Passing "gcs" as the component name as currently it's not
// possible to get the component called this method
// TODO(JoaoBraveCoding) update compoent when bigger refactor happens
return aws.NewS3ThanosObjectClient(context.Background(), cfg.ObjStoreConf, "gcs", utilLog.Logger, cfg.Hedging)
}
return aws.NewS3ObjectClient(s3Cfg, cfg.Hedging)

case config.StorageTypeAlibabaCloud:
Expand Down

0 comments on commit d5c5760

Please sign in to comment.