statesetting

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: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeNumber = iota
	TypePercentage
)
View Source
const (
	JUnitID   = "junit"
	ServiceID = "service"

	MethodWorst        = "worst"
	MethodWorstOfShare = "worst_of_share"
	MethodInherited    = "inherited"
	MethodDependencies = "dependencies"

	CalculationMethodNumber = "number"
	CalculationMethodShare  = "share"

	CalculationCondGT = "gt"
	CalculationCondLT = "lt"

	RuleTypeComponent = "component"
	RuleTypeService   = "service"

	StateSettingsNotificationID = "state_settings_notify_id"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Get(ctx context.Context, settingID string) (*StateSetting, error)
}

func NewMongoAdapter

func NewMongoAdapter(client mongo.DbClient) Adapter

type Assigner

type Assigner interface {
	AssignStateSetting(ctx context.Context, entity *types.Entity, commRegister mongo.CommandsRegister) (bool, error)
	LoadRules(ctx context.Context) error
}

func NewService

func NewService(dbClient mongo.DbClient, logger zerolog.Logger) Assigner

type Counters

type Counters struct {
	OK       int
	Minor    int
	Major    int
	Critical int
}

func (Counters) GetTotal

func (c Counters) GetTotal() int

type JUnitThreshold

type JUnitThreshold struct {
	Minor    float64 `bson:"minor"`
	Major    float64 `bson:"major"`
	Critical float64 `bson:"critical"`
	Type     int     `bson:"type"`
}

func (JUnitThreshold) GetState

func (s JUnitThreshold) GetState(value, total int64) int

type JUnitThresholds

type JUnitThresholds struct {
	Skipped  JUnitThreshold `bson:"skipped"`
	Errors   JUnitThreshold `bson:"errors"`
	Failures JUnitThreshold `bson:"failures"`
}

func (JUnitThresholds) GetState

func (s JUnitThresholds) GetState(skipped, errors, failures, total int64) int

type Listener

type Listener interface {
	Listen(ctx context.Context, ch <-chan RuleUpdatedMessage)
}

func NewListener

func NewListener(
	dbClient mongo.DbClient,
	publisher libamqp.Publisher,
	encoder encoding.Encoder,
	logger zerolog.Logger,
) Listener

type RuleChangesWatcher

type RuleChangesWatcher interface {
	Watch(ctx context.Context) error
}

func NewRulesChangesWatcher

func NewRulesChangesWatcher(client mongo.DbClient, service Assigner) RuleChangesWatcher

type RuleUpdatedMessage

type RuleUpdatedMessage struct {
	OldPattern *pattern.Entity // nil if a state setting is new
	OldType    string

	NewPattern *pattern.Entity
	NewType    string
}

type StateSetting

type StateSetting struct {
	ID       string `bson:"_id"`
	Title    string `bson:"title"`
	Method   string `bson:"method"`
	Enabled  *bool  `bson:"enabled,omitempty"`
	Priority int64  `bson:"priority"`
	Type     string `bson:"type,omitempty"`

	EntityPattern          *pattern.Entity `bson:"entity_pattern,omitempty"`
	InheritedEntityPattern *pattern.Entity `bson:"inherited_entity_pattern,omitempty"`

	JUnitThresholds *JUnitThresholds `bson:"junit_thresholds,omitempty"`
	StateThresholds *StateThresholds `bson:"state_thresholds,omitempty"`
}

func DefaultWorst

func DefaultWorst() StateSetting

type StateThreshold

type StateThreshold struct {
	Method string `bson:"method"`
	State  string `bson:"state"`
	Cond   string `bson:"cond"`
	Value  int    `bson:"value"`
}

func (*StateThreshold) IsReached

func (s *StateThreshold) IsReached(c Counters) bool

type StateThresholds

type StateThresholds struct {
	Critical *StateThreshold `bson:"critical,omitempty"`
	Major    *StateThreshold `bson:"major,omitempty"`
	Minor    *StateThreshold `bson:"minor,omitempty"`
	OK       *StateThreshold `bson:"ok,omitempty"`
}

Jump to

Keyboard shortcuts

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