Skip to content

Commit

Permalink
updates sync config to use protobuf duration type to allow for friend…
Browse files Browse the repository at this point in the history
…lier API
  • Loading branch information
kishie committed Feb 12, 2024
1 parent 9e175d7 commit 9830cb6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
6 changes: 5 additions & 1 deletion charts/beskar-ostree/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,8 @@ configData:
gcs:
bucket: beskar-ostree
azure:
container: beskar-ostree
container: beskar-ostree

sync:
timeout: 3600s # 1 hour
max_worker_count: 10
18 changes: 11 additions & 7 deletions internal/pkg/config/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@

package config

import "time"
import (
"time"

"google.golang.org/protobuf/types/known/durationpb"
)

const (
DefaultSyncTimeout = time.Hour
DefaultSyncMaxWorkerCount = 10
)

type SyncConfig struct {
Timeout time.Duration `yaml:"timeout"`
MaxWorkerCount int `yaml:"max_worker_count"`
Timeout durationpb.Duration `yaml:"timeout"`
MaxWorkerCount int `yaml:"max_worker_count"`
}

func (sc SyncConfig) GetTimeout() time.Duration {
if sc.Timeout <= 0 {
func (sc *SyncConfig) GetTimeout() time.Duration {
if !sc.Timeout.IsValid() || sc.Timeout.GetSeconds() <= 0 {
return DefaultSyncTimeout
}

return sc.Timeout
return sc.Timeout.AsDuration()
}

func (sc SyncConfig) GetMaxWorkerCount() int {
func (sc *SyncConfig) GetMaxWorkerCount() int {
if sc.MaxWorkerCount <= 0 {
return DefaultSyncMaxWorkerCount
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ gossip:
- 127.0.0.1:5102

sync:
timeout: 3600 # 1 hour
timeout: 3600s # 1 hour
max_worker_count: 10

0 comments on commit 9830cb6

Please sign in to comment.