Skip to content

Commit

Permalink
Merge pull request #4 from weni-ai/rollup-timeout-configs
Browse files Browse the repository at this point in the history
add new configs for rollup timeouts
  • Loading branch information
rasoro authored Apr 24, 2024
2 parents 21a0c24 + 533da0b commit c96d690
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions archives/archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func GetMissingMonthlyArchives(ctx context.Context, db *sqlx.DB, now time.Time,

// BuildRollupArchive builds a monthly archive from the files present on S3
func BuildRollupArchive(ctx context.Context, db *sqlx.DB, conf *Config, s3Client s3iface.S3API, monthlyArchive *Archive, now time.Time, org Org, archiveType ArchiveType) error {
ctx, cancel := context.WithTimeout(ctx, time.Hour)
ctx, cancel := context.WithTimeout(ctx, time.Hour*time.Duration(conf.BuildRollupArchiveTimeout))
defer cancel()

start := time.Now()
Expand Down Expand Up @@ -813,7 +813,7 @@ func createArchives(ctx context.Context, db *sqlx.DB, config *Config, s3Client s

// RollupOrgArchives rolls up monthly archives from our daily archives
func RollupOrgArchives(ctx context.Context, now time.Time, config *Config, db *sqlx.DB, s3Client s3iface.S3API, org Org, archiveType ArchiveType) ([]*Archive, error) {
ctx, cancel := context.WithTimeout(ctx, time.Hour*3)
ctx, cancel := context.WithTimeout(ctx, time.Hour*time.Duration(config.RollupOrgTimeout))
defer cancel()

log := logrus.WithFields(logrus.Fields{
Expand Down
6 changes: 6 additions & 0 deletions archives/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type Config struct {
Delete bool `help:"whether to delete messages and runs from the db after archival (default false)"`
ExitOnCompletion bool `help:"whether archiver should exit after completing archiving job (default false)"`
StartTime string `help:"what time archive jobs should run in UTC HH:MM "`

RollupOrgTimeout int `help:"rollup timeout for all org archives, limit in hours (default 3)"`
BuildRollupArchiveTimeout int `help:"rollup for single archive timeout, limit in hours (default 1)"`
}

// NewConfig returns a new default configuration object
Expand Down Expand Up @@ -52,6 +55,9 @@ func NewConfig() *Config {
Delete: false,
ExitOnCompletion: false,
StartTime: "00:01",

RollupOrgTimeout: 3,
BuildRollupArchiveTimeout: 1,
}

return &config
Expand Down

0 comments on commit c96d690

Please sign in to comment.