policyhandler

package
v3.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PoliciesCacheTtlEnvVar = "POLICIES_CACHE_TTL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PolicyHandler

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

PolicyHandler

func NewPolicyHandler

func NewPolicyHandler(clusterName string) *PolicyHandler

NewPolicyHandler creates and returns an instance of the `PolicyHandler`. The function initializes the `PolicyHandler` only if it hasn't been previously created. The PolicyHandler supports caching of downloaded policies and exceptions by setting the `POLICIES_CACHE_TTL` environment variable (default is no caching).

func (*PolicyHandler) CollectPolicies

func (policyHandler *PolicyHandler) CollectPolicies(ctx context.Context, policyIdentifier []cautils.PolicyIdentifier, scanInfo *cautils.ScanInfo) (*cautils.OPASessionObj, error)

type TimedCache

type TimedCache[T any] struct {
	// contains filtered or unexported fields
}

TimedCache provides functionality for managing a timed cache. The timed cache holds a value for a specified time duration (TTL). After the TTL has passed, the value is invalidated.

The cache is thread safe.

func NewTimedCache

func NewTimedCache[T any](ttl time.Duration) *TimedCache[T]

func (*TimedCache[T]) Get

func (c *TimedCache[T]) Get() (T, bool)

func (*TimedCache[T]) Invalidate

func (c *TimedCache[T]) Invalidate()

func (*TimedCache[T]) Set

func (c *TimedCache[T]) Set(value T)

func (*TimedCache[T]) Stop added in v3.0.3

func (c *TimedCache[T]) Stop()

Jump to

Keyboard shortcuts

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