-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
40 lines (33 loc) · 1.03 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package provider
import (
"time"
"github.com/logicmonitor/lm-k8s-webhook/lm-config-reloader/pkg/fetcher"
)
// RemoteProvider is the interface to be implmented by the remote config providers
type RemoteProvider interface {
fetcher.Fetcher
GetParsedPullInterval() (time.Duration, error)
GetPullInterval() string
SetPullInterval(string)
}
// DefaultRemoteProvider holds basic providers data
type DefaultRemoteProvider struct {
Provider string
PullInterval string
}
// GetParsedPullInterval returns the parsed duration
func (rp *DefaultRemoteProvider) GetParsedPullInterval() (time.Duration, error) {
// If pull interval is not provided
if rp.PullInterval == "" {
return 0, nil
}
return time.ParseDuration(rp.PullInterval)
}
// SetPullInterval sets the pullInterval
func (rp *DefaultRemoteProvider) SetPullInterval(pullInterval string) {
rp.PullInterval = pullInterval
}
// GetPullInterval returns the pullInterval assigned to remote provider
func (rp *DefaultRemoteProvider) GetPullInterval() string {
return rp.PullInterval
}