package config import ( "caatsm/pkg/utils" "fmt" "os" "regexp" "strings" "time" "github.com/spf13/viper" "go.uber.org/zap" "go.uber.org/zap/zapcore" "gopkg.in/natefinch/lumberjack.v2" ) var MyConfig *Config type Config struct { Nats NatsConfig Subscription SubscriptionConfig Timeouts TimeoutsConfig Hasura HasuraConfig } type NatsConfig struct { Client string URL string Cluster string } type SubscriptionConfig struct { Topic string `mapstructure:"topic"` QueueGroup string `mapstructure:"queue_group"` } type TimeoutsConfig struct { Server time.Duration `mapstructure:"server"` ReconnectWait time.Duration `mapstructure:"reconnect_wait"` Close time.Duration `mapstructure:"close"` AckWait time.Duration `mapstructure:"ack_wait"` } type BodyConfig struct { Patterns []PatternConfig } type PatternConfig struct { Pattern string Comments string Expression *regexp.Regexp } type HasuraConfig struct { Endpoint string Secret string } // LoggerConfig represents the configuration for the logger. type LoggerConfig struct { ZapConfig zap.Config `json:"zapConfig"` LumberjackConfig LumberjackConfig `json:"lumberjackConfig"` } // LumberjackConfig represents the configuration for lumberjack logging. type LumberjackConfig struct { Filename string `json:"filename"` MaxSize int `json:"maxSize"` MaxBackups int `json:"maxBackups"` MaxAge int `json:"maxAge"` Compress bool `json:"compress"` } const ( EnvProd = "prod" // logConfigFile = "configs/log_config.json" // arrPatternString represents the regular expression pattern used to match arrival patterns. // The pattern matches strings in the format: "(TYPE-NUMBER-SSR-DEPARTURE-ARRIVAL)". // The pattern captures the following named groups: // - category: the three-letter category code // - number: the alphanumeric flight number // - ssr: the alphanumeric SSR code // - departure: the four-letter departure airport code // - arrival: the four-letter arrival airport code arrPatternString = `^\((?P[A-Z]{3})` + `-(?P[A-Z0-9]+)(\/?(?P[A-Z0-9]+))?` + `-(?P[A-Z]{4})` + `-(?P[A-Z]{4})(?P