risk

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(typeName string, factory Factory)

Register registers a risk actor factory under the given type name. Typically called from init() in each risk actor package.

func RuleFactory

func RuleFactory(typeName string, cat *catalog.Catalog, c *cache.Cache, config map[string]any) (rule.Rule, error)

RuleFactory creates a Rule from a type name and config map.

Types

type Checker

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

Checker aggregates risk rules and evaluates them sequentially. The first rule that returns an error causes the check to fail.

func (*Checker) Check

func (c *Checker) Check(cmd command.RiskCheck) error

Check runs all rules against the given command. Returns nil if all rules pass, or the first error encountered.

type CheckerBuilder

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

CheckerBuilder constructs a Checker by accumulating rules.

func NewCheckerBuilder

func NewCheckerBuilder() *CheckerBuilder

NewCheckerBuilder creates a new CheckerBuilder.

func (*CheckerBuilder) AddRule

func (b *CheckerBuilder) AddRule(r rule.Rule) *CheckerBuilder

AddRule appends a rule to the builder.

func (*CheckerBuilder) Build

func (b *CheckerBuilder) Build() *Checker

Build creates the Checker from the accumulated rules.

type CheckerEntry

type CheckerEntry struct {
	Type   string         `yaml:"type"`
	Config map[string]any `yaml:"config"`
}

CheckerEntry describes a single rule to add to the Checker.

type Config

type Config struct {
	Actor   []actor.Entry  `yaml:"actor"`
	Checker []CheckerEntry `yaml:"checker"`
}

Config contains risk engine configuration.

type Engine

type Engine struct {
	engine.EngineBase
	// contains filtered or unexported fields
}

Engine manages risk calculations and limits. It constructs actors from config via the factory registry and builds a Checker from configured rules to gate order flow.

func NewEngine

func NewEngine(cat *catalog.Catalog, msgBus *msgbus.MsgBus, c *cache.Cache) *Engine

NewEngine creates a new risk engine.

func (*Engine) Execute

func (e *Engine) Execute(cmd msgbus.Command, bus *msgbus.MsgBus)

Execute routes commands to the appropriate handler.

func (*Engine) Init

func (e *Engine) Init(config Config)

Init initializes the risk engine: constructs actors from config, builds the checker from configured rules, and registers command handlers.

func (*Engine) Start

func (e *Engine) Start()

Start starts the risk engine and all its actors.

func (*Engine) Stop

func (e *Engine) Stop()

Stop stops the risk engine and all its actors.

type Factory

type Factory func(cat *catalog.Catalog, bus *msgbus.MsgBus, c *cache.Cache) actor.Actor

Factory is a constructor function that creates a risk actor.

Directories

Path Synopsis
actor

Jump to

Keyboard shortcuts

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