file

package
v0.42.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultInterval for re-loading the bundle file.
	DefaultInterval = time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader loads a bundle from a file. If started, it loads the bundle periodically until closed.

func New

func New(opa *opa.OPA) *Loader

New constructs a new file loader periodically reloading the bundle from a file.

func (*Loader) Close

func (l *Loader) Close()

Close stops the loading, releasing all resources.

func (*Loader) Init

func (l *Loader) Init() (*Loader, error)

Init initializes the loader after its construction and configuration. If invalid config, will return ErrInvalidConfig.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context) error

Load loads the bundle from a file and installs it. The possible returned errors are ErrInvalidBundle (in case of an error in loading or opening the bundle) and the ones SetPolicyData of OPA returns.

func (*Loader) Start

func (l *Loader) Start(ctx context.Context) error

Start starts the periodic loading byt calling Load, failing if the bundle loading fails.

func (*Loader) WithErrorLogger

func (l *Loader) WithErrorLogger(logger func(error)) *Loader

WithErrorLogger configures an error logger invoked with all the errors.

func (*Loader) WithFile

func (l *Loader) WithFile(filename string) *Loader

WithFile configures the file to load the bundle from.

func (*Loader) WithInterval

func (l *Loader) WithInterval(interval time.Duration) *Loader

WithInterval configures the delay between bundle file reloading.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL