config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AMQP

type AMQP struct {
	BrokerURL      string        `mapstructure:"broker_url"`
	ConsumerTag    string        `mapstructure:"consumer_tag"`
	PrefetchCount  int           `mapstructure:"prefetch_count"`
	AllowedVHosts  []string      `mapstructure:"allowed_vhosts"`
	ReconnectDelay time.Duration `mapstructure:"reconnect_delay"`
}

AMQP contains RabbitMQ configuration

type Config

type Config struct {
	Server    Server    `mapstructure:"server"`
	AMQP      AMQP      `mapstructure:"amqp"`
	OrgEvents OrgEvents `mapstructure:"org_events"`
	Db        Db        `mapstructure:"db"`
}

Config represents the service configuration

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads configuration from file and environment variables

type Db

type Db struct {
	Name           string        `mapstructure:"name"`
	Username       string        `mapstructure:"username"`
	Password       string        `mapstructure:"password"`
	Host           string        `mapstructure:"host"`
	Port           int           `mapstructure:"port"`
	BatchSize      int           `mapstructure:"batch_size"`
	FlushInterval  time.Duration `mapstructure:"flush_interval"`
	MaxConnections int           `mapstructure:"max_connections"`
	MaxIdleConns   int           `mapstructure:"max_idle_conns"`
}

Db contains Db configuration

type DeviceModelRules

type DeviceModelRules struct {
	DeviceModel string            `yaml:"device_model"`
	DisplayName string            `yaml:"display_name"`
	Rules       []EventRuleConfig `yaml:"rules"`
}

DeviceModelRules represents event rules for a specific device model

type EventRuleConfig

type EventRuleConfig struct {
	RuleKey     string `yaml:"rule_key"`
	Operator    string `yaml:"operator"`
	Operand     string `yaml:"operand"`
	EventType   string `yaml:"event_type"`
	EventLevel  string `yaml:"event_level"`
	Description string `yaml:"description"`
	Status      string `yaml:"status"`
	IsActive    bool   `yaml:"is_active"`
}

EventRuleConfig represents a single event rule configuration

type EventRulesConfig

type EventRulesConfig struct {
	DeviceModels []DeviceModelRules `yaml:"device_models"`
}

EventRulesConfig represents the aggregated event rules configuration

func LoadEventRulesConfig

func LoadEventRulesConfig(path string) (*EventRulesConfig, error)

LoadEventRulesConfig loads event rules from a YAML file

func LoadEventRulesFromDir

func LoadEventRulesFromDir(dir string) (*EventRulesConfig, error)

LoadEventRulesFromDir loads all event rule YAML files from a directory Each file should contain a single device model's rules

type OrgEvents

type OrgEvents struct {
	Exchange    string `mapstructure:"exchange"`
	Queue       string `mapstructure:"queue"`
	RoutingKey  string `mapstructure:"routing_key"`
	ConsumerTag string `mapstructure:"consumer_tag"`
}

OrgEvents contains organization events configuration

type Server

type Server struct {
	LogLevel            string `mapstructure:"log_level"`
	APIPort             int    `mapstructure:"api_port"`
	AlertsProcessorsCfg string `mapstructure:"alerts_processors_path"`
	EventRulesDir       string `mapstructure:"event_rules_dir"`
}

Server contains server configuration

Jump to

Keyboard shortcuts

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