package file

import "github.com/open-policy-agent/opa/internal/wasm/sdk/opa/loader/file"

Index

Constants

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

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.

Source Files

config.go loader.go

Version
v0.56.0
Published
Aug 31, 2023
Platform
js/wasm
Imports
7 packages
Last checked
1 hour ago

Tools for package owners.