policy

package
v0.0.0-...-3736fb9 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package policy provides policy primatives, policy registration and functions to run policies against a WorkReq that is submitted to the system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, p Policy, s Settings)

Register registers a policy by name with an empty Settings that will be copied to provide the Settings we will read out of the config file.

func Run

func Run(ctx context.Context, req *pb.WorkReq, args ...PolicyArgs) error

Run runs all policies runners that are passed concurrently.

Types

type Policy

type Policy interface {
	// Run runs the policy against a request with settings that are specific
	// to the policy. settings can be nil for certain implementations.
	Run(ctx context.Context, req *pb.WorkReq, settings Settings) error
}

Policy represents a policy that is defined to check a WorkReq is compliant.

type PolicyArgs

type PolicyArgs struct {
	// Name of the policy in the registry.
	Name string
	// Settings for that policy invocation.
	Settings Settings
}

PolicyArgs detail a policy and settings to use to invoke it.

type Settings

type Settings interface {
	// Validate validates the Settings for a Policy.
	Validate() error
}

Setting holds a struct that is used to hold the Policy settings that are invoked. These are defined per policy. This should always be a struct and not a *struct.

func GetSettings

func GetSettings(name string) (Settings, error)

GetSettings fetches the Settings for a named Policy.

Directories

Path Synopsis
Package config stores the policy configuration Go representation, a global variable called Policies that is for reading the Config as it is updated on disk and configuration validation to make sure errors don't slip in to the Config.
Package config stores the policy configuration Go representation, a global variable called Policies that is for reading the Config as it is updated on disk and configuration validation to make sure errors don't slip in to the Config.
register
restrictjobtypes
Package restrictjobtypes provides a policy that can be invoked to ensure that a WorkReq only contains jobs of certain types.
Package restrictjobtypes provides a policy that can be invoked to ensure that a WorkReq only contains jobs of certain types.
sameargs
Package sameargs defines a generic policy that can be used to look at Jobs of certain types and validate that every Job of that type has certain arguments that are the same for every invocation.
Package sameargs defines a generic policy that can be used to look at Jobs of certain types and validate that every Job of that type has certain arguments that are the same for every invocation.
startorend
Package startorend implements a policy that can be used to check that a WorkReq has a particular Job in the first block or the last block with certain settings.
Package startorend implements a policy that can be used to check that a WorkReq has a particular Job in the first block or the last block with certain settings.

Jump to

Keyboard shortcuts

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