calculator

package
v0.32.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatorModuleFactory

func CalculatorModuleFactory(ctx context.Context, config cfg.Config, logger log.Logger) (map[string]kernel.ModuleFactory, error)

func NewCalculatorModule

func NewCalculatorModule(handlers map[string]Handler, settings *CalculatorSettings) kernel.ModuleFactory

func NewPerRunnerMetricHandlerWithInterfaces

func NewPerRunnerMetricHandlerWithInterfaces(logger log.Logger, clock clock.Clock, cwClient gosoCloudwatch.Client, calculatorSettings *CalculatorSettings) *perRunnerMetricHandler

func ReadHandlerSettings

func ReadHandlerSettings[T any](config cfg.Config, name string, settings T) T

func RegisterHandlerFactory

func RegisterHandlerFactory(name string, factory HandlerFactory)

Types

type CalculatorModule

type CalculatorModule struct {
	kernel.EssentialModule
	kernel.ServiceStage
	// contains filtered or unexported fields
}

func NewCalculatorModuleWithInterfaces

func NewCalculatorModuleWithInterfaces(
	logger log.Logger,
	leaderElection ddb.LeaderElection,
	cwClient gosoCloudwatch.Client,
	metricWriter metric.Writer,
	ticker clock.Ticker,
	handlers map[string]Handler,
	memberId string,
	settings *CalculatorSettings,
) *CalculatorModule

func (*CalculatorModule) Run

func (u *CalculatorModule) Run(ctx context.Context) error

type CalculatorSettings

type CalculatorSettings struct {
	Cloudwatch          CloudWatchSettings `cfg:"cloudwatch"`
	DynamoDb            DynamoDbSettings   `cfg:"dynamodb"`
	Enabled             bool               `cfg:"enabled" default:"false"`
	Ecs                 EcsSettings        `cfg:"ecs"`
	LeaderElection      string             `cfg:"leader_election" default:"metric_calculator"`
	Period              time.Duration      `cfg:"period" default:"1m"`
	CloudWatchNamespace string
}

type CloudWatchNamingSettings

type CloudWatchNamingSettings struct {
	Pattern string `cfg:"pattern,nodecode" default:"{project}/{env}/{family}/{group}-{app}"`
}

type CloudWatchSettings

type CloudWatchSettings struct {
	Client string `cfg:"client"`
}

type DynamoDbNamingSettings

type DynamoDbNamingSettings struct {
	Pattern string `cfg:"pattern,nodecode" default:"{project}-{env}-{family}-{modelId}"`
}

type DynamoDbSettings

type DynamoDbSettings struct {
	Naming DynamoDbNamingSettings `cfg:"naming"`
}

type EcsSettings

type EcsSettings struct {
	Cluster string `cfg:"cluster" default:"{app_project}-{env}-{app_family}"`
	Service string `cfg:"service" default:"{app_group}-{app_name}"`
}

type Handler

type Handler interface {
	GetMetrics(ctx context.Context) (metric.Data, error)
}

type HandlerFactory

type HandlerFactory func(ctx context.Context, config cfg.Config, logger log.Logger, calculatorSettings *CalculatorSettings) (Handler, error)

type PerRunnerMetricHandler

type PerRunnerMetricHandler interface {
	CalculatePerRunnerMetrics(ctx context.Context, name string, currentValue float64, settings *PerRunnerMetricSettings) (*metric.Datum, error)
}

type PerRunnerMetricSettings

type PerRunnerMetricSettings struct {
	Enabled            bool          `cfg:"enabled" default:"true"`
	MaxIncreasePercent float64       `cfg:"max_increase_percent" default:"200"`
	MaxIncreasePeriod  time.Duration `cfg:"max_increase_period" default:"5m"`
	Period             time.Duration `cfg:"period" default:"1m"`
	TargetValue        float64       `cfg:"target_value" default:"0"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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