calculator

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentCountersCalculator

type ComponentCountersCalculator interface {
	// CalculateCounters calculates counters for the component by dependency alarm change and returns true if component state is changed as the first argument, and a new component state as the second one.
	CalculateCounters(ctx context.Context, entity *types.Entity, alarm *types.Alarm, alarmChange types.AlarmChange) (bool, int, error)
	// RecomputeCounters recomputes all counters for component's dependencies, return a new calculated component state.
	RecomputeCounters(ctx context.Context, component *types.Entity) (int, error)
	// RecomputeAll sends entityupdated events for all components with state settings, which should recompute counters.
	RecomputeAll(ctx context.Context) error
}

func NewComponentCountersCalculator

func NewComponentCountersCalculator(dbClient mongo.DbClient, eventsSender entitycounters.EventsSender) ComponentCountersCalculator

type ComponentCountersStrategy

type ComponentCountersStrategy interface {
	// CanSkip defines conditions where we can say that counters won't be changed and we can skip calculation
	CanSkip(calcData entitycounters.ComponentCountersCalcData) bool
	// Calculate contains counters calculation logic.
	Calculate(calcData entitycounters.ComponentCountersCalcData) entitycounters.EntityCounters
}

type EntityServiceCountersCalculator

type EntityServiceCountersCalculator interface {
	// CalculateCounters calculates counters for the entity service by dependency alarm change and returns a map with updated entity service ids and a new calculated state and output.
	CalculateCounters(ctx context.Context, entity *types.Entity, alarm *types.Alarm, alarmChange types.AlarmChange) (map[string]entitycounters.UpdatedServicesInfo, error)
	// RecomputeCounters recomputes all counters for service's dependencies, returns a map with updated entity service id and a new calculated state and output.
	RecomputeCounters(ctx context.Context, service *types.Entity) (map[string]entitycounters.UpdatedServicesInfo, error)
	// RecomputeAll sends recomputeentityservice events for all entity services, which should recompute counters.
	RecomputeAll(ctx context.Context) error
}

func NewEntityServiceCountersCalculator

func NewEntityServiceCountersCalculator(dbClient mongo.DbClient, executor template.Executor, eventsSender entitycounters.EventsSender) EntityServiceCountersCalculator

type EntityServiceCountersStrategy

type EntityServiceCountersStrategy interface {
	// CanSkip defines conditions where we can say that counters won't be changed and we can skip calculation
	CanSkip(calcData entitycounters.EntityServiceCountersCalcData) bool
	// Calculate contains counters calculation logic.
	Calculate(calcData entitycounters.EntityServiceCountersCalcData) entitycounters.EntityCounters
}

Jump to

Keyboard shortcuts

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