Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
squashable: Resolve conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>
  • Loading branch information
Harkishen-Singh committed Dec 15, 2022
1 parent 0cf0e1e commit 25f9997
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
12 changes: 6 additions & 6 deletions pkg/dataset/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ type Config struct {

// Metrics contains dataset configuration options for metrics data.
type Metrics struct {
ChunkInterval day.Duration `mapstructure:"default_chunk_interval" yaml:"default_chunk_interval"`
Compression *bool `mapstructure:"compress_data" yaml:"compress_data"` // Using pointer to check if the the value was set.
HALeaseRefresh day.Duration `mapstructure:"ha_lease_refresh" yaml:"ha_lease_refresh"`
HALeaseTimeout day.Duration `mapstructure:"ha_lease_timeout" yaml:"ha_lease_timeout"`
RetentionPeriod day.Duration `mapstructure:"default_retention_period" yaml:"default_retention_period"`
Rollups *rollup.Config `mapstructure:"rollups" yaml:"rollups,omitempty"`
ChunkInterval day.Duration `mapstructure:"default_chunk_interval" yaml:"default_chunk_interval"`
Compression *bool `mapstructure:"compress_data" yaml:"compress_data"` // Using pointer to check if the the value was set.
HALeaseRefresh day.Duration `mapstructure:"ha_lease_refresh" yaml:"ha_lease_refresh"`
HALeaseTimeout day.Duration `mapstructure:"ha_lease_timeout" yaml:"ha_lease_timeout"`
RetentionPeriod day.Duration `mapstructure:"default_retention_period" yaml:"default_retention_period"`
Rollups *rollup.Config `mapstructure:"rollup" yaml:"rollup,omitempty"`
}

// Traces contains dataset configuration options for traces data.
Expand Down
4 changes: 2 additions & 2 deletions pkg/internal/day/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func StringToDayDurationHookFunc() mapstructure.DecodeHookFunc {
return data, nil
}

var d DayDuration
var d Duration

if t != reflect.TypeOf(d) {
return data, nil
Expand All @@ -93,6 +93,6 @@ func StringToDayDurationHookFunc() mapstructure.DecodeHookFunc {
if err != nil {
return nil, err
}
return DayDuration(d), nil
return Duration(d), nil
}
}
9 changes: 5 additions & 4 deletions pkg/runner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/timescale/promscale/pkg/pgmodel"
"github.com/timescale/promscale/pkg/pgmodel/common/extension"
"github.com/timescale/promscale/pkg/pgmodel/common/schema"
"github.com/timescale/promscale/pkg/rollup"
"github.com/timescale/promscale/pkg/tenancy"
"github.com/timescale/promscale/pkg/util"
"github.com/timescale/promscale/pkg/version"
Expand Down Expand Up @@ -169,13 +170,13 @@ func CreateClient(r prometheus.Registerer, cfg *Config) (*pgclient.Client, error
if cfg.DatasetConfig != "" {
log.Warn("msg", "Ignoring `startup.dataset.config` in favor of the newer `startup.dataset` config option since both were set.")
}
err = cfg.DatasetCfg.Apply(conn)
err = cfg.DatasetCfg.Apply(context.Background(), conn)
} else if cfg.DatasetConfig != "" {
err = applyDatasetConfig(conn, cfg.DatasetConfig)
err = applyDatasetConfig(context.Background(), conn, cfg.DatasetConfig)
} else {
// We apply downsampling settings even when DatasetConfig is not given, which is the most common case.
downsampleCfg := &dataset.Downsample{}
err = downsampleCfg.Apply(conn)
rollupCfg := &rollup.Config{}
err = rollupCfg.Apply(context.Background(), conn)
if err != nil {
return nil, fmt.Errorf("error applying downsampling configuration: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/runner/config_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"
"github.com/timescale/promscale/pkg/dataset"
"github.com/timescale/promscale/pkg/internal/day"
)

// unmarshalRule defines that the subtree located on the `key` of the Viper
Expand Down Expand Up @@ -260,7 +260,7 @@ func applyUnmarshalRules(v *viper.Viper, unmarshalRules []unmarshalRule) error {
rule.target,
viper.DecodeHook(
mapstructure.ComposeDecodeHookFunc(
dataset.StringToDayDurationHookFunc(),
day.StringToDayDurationHookFunc(),
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.StringToSliceHookFunc(","),
),
Expand Down
12 changes: 6 additions & 6 deletions pkg/runner/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/stretchr/testify/require"
"github.com/timescale/promscale/pkg/dataset"
"github.com/timescale/promscale/pkg/internal/day"
)

func TestParseFlags(t *testing.T) {
Expand Down Expand Up @@ -281,12 +281,12 @@ startup:
c.ListenAddr = "localhost:9201"
c.AuthConfig.BasicAuthUsername = "promscale"
c.AuthConfig.BasicAuthPassword = "my-password"
c.DatasetCfg.Metrics.ChunkInterval = dataset.DayDuration(24 * time.Hour)
c.DatasetCfg.Metrics.ChunkInterval = day.Duration(24 * time.Hour)
c.DatasetCfg.Metrics.Compression = func(b bool) *bool { return &b }(false)
c.DatasetCfg.Metrics.HALeaseRefresh = dataset.DayDuration(24 * time.Hour * 2)
c.DatasetCfg.Metrics.HALeaseTimeout = dataset.DayDuration(24 * time.Hour * 3)
c.DatasetCfg.Metrics.RetentionPeriod = dataset.DayDuration(24 * time.Hour * 4)
c.DatasetCfg.Traces.RetentionPeriod = dataset.DayDuration(24 * time.Hour * 5)
c.DatasetCfg.Metrics.HALeaseRefresh = day.Duration(24 * time.Hour * 2)
c.DatasetCfg.Metrics.HALeaseTimeout = day.Duration(24 * time.Hour * 3)
c.DatasetCfg.Metrics.RetentionPeriod = day.Duration(24 * time.Hour * 4)
c.DatasetCfg.Traces.RetentionPeriod = day.Duration(24 * time.Hour * 5)
c.DatasetConfig = "metrics:\n default_chunk_interval: 1h\n"
return c
},
Expand Down

0 comments on commit 25f9997

Please sign in to comment.