Documentation ¶
Index ¶
- Constants
- type Loader
- func (l *Loader) Close()
- func (l *Loader) Init() (*Loader, error)
- func (l *Loader) Load(ctx context.Context) error
- func (l *Loader) Start(ctx context.Context) error
- func (l *Loader) WithClient(client *http.Client) *Loader
- func (l *Loader) WithErrorLogger(logger func(error)) *Loader
- func (l *Loader) WithInterval(min, max time.Duration) *Loader
- func (l *Loader) WithPrepareRequest(prepare func(*http.Request) error) *Loader
- func (l *Loader) WithURL(url string) *Loader
Constants ¶
const ( // MinRetryDelay determines the minimum retry interval in case // of an error. MinRetryDelay = 100 * time.Millisecond // DefaultMinDelay is the default minimum re-downloading // interval in case of a previously successful download. DefaultMinDelay = 60 * time.Second // DefaultMaxDelay is the default maximum re-downloading // interval in case of a previously successful download. DefaultMaxDelay = 120 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader downloads a bundle over HTTP. If started, it downloads the bundle periodically until closed.
func (*Loader) Close ¶
func (l *Loader) Close()
Close stops the downloading, releasing all resources.
func (*Loader) Init ¶
Init initializes the loader after its construction and configuration. If invalid config, will return ErrInvalidConfig.
func (*Loader) Load ¶
Load downloads the bundle from a remote location and installs it. The possible returned errors are ErrInvalidBundle (in case of an error in downloading or opening the bundle) and the ones SetPolicyData of OPA returns.
func (*Loader) Start ¶
Start starts the periodic downloads, blocking until the first successful download. If cancelled, will return context.Cancelled.
func (*Loader) WithClient ¶
WithClient configures the HTTP client to use. If not configured, http.DefaultClient is used.
func (*Loader) WithErrorLogger ¶
WithErrorLogger configures an error logger invoked with all the errors.
func (*Loader) WithInterval ¶
WithInterval configures the minimum and maximum delay between bundle downloads.
func (*Loader) WithPrepareRequest ¶
WithPrepareRequest configures a handler to customize the HTTP requests before their sending. The HTTP request is not modified after the handle invocation.