libParams

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptParams added in v0.16.1

func EncryptParams[T any](keyByte, ivByte []byte, paramFile string, params *ApplicationParams[T]) error

func GetValueFromMap added in v0.16.0

func GetValueFromMap[T any](name string, mp map[string]T) *T

func LogRotate added in v0.9.29

func LogRotate(logger *lumberjack.Logger)

func Write added in v0.16.1

func Write[T any](params *ApplicationParams[T], path string) error

Types

type ApplicationParams added in v0.16.0

type ApplicationParams[SpecialParams any] struct {
	Network               map[string]NetworkParams        `yaml:"networks"` // Definition of all networks, all networks will be started at startup
	Logging               LogParams                       `yaml:"logging"`
	DB                    map[string]DbParams             `yaml:"db"`                    // Database connection strings
	SecurityModule        map[string]SecurityModule       `yaml:"securityModule"`        // Security modules if exists
	RemoteApis            map[string]libCallApi.RemoteApi `yaml:"remoteApis"`            // List of remote-api definition
	Constants             map[string]Constants            `yaml:"constants"`             // Constants used in app [response constants should be placed here]
	ParameterGroups       map[string]ParametersMap        `yaml:"parameterGroups"`       // Simple string parameters groupped by names
	SecureParameterGroups map[string]SecureParametersMap  `yaml:"secureParameterGroups"` // Encrypted string parameters, will be parsed at startup
	Specific              *SpecialParams                  `yaml:"specific"`              // Application specific args, should be parsed as yaml
	Metrics               *ginprom.Prometheus             `json:"-"`                     // Applications metrics storage
}

Application can be designed with below params as default

func DecryptParams added in v0.16.1

func DecryptParams[T any](keyByte, ivByte []byte, params *ApplicationParams[T]) (*ApplicationParams[T], error)

func Load added in v0.16.1

func Load[T any](path string) (*ApplicationParams[T], error)

func (ApplicationParams[SpecialParams]) GetConstants added in v0.16.0

func (m ApplicationParams[SpecialParams]) GetConstants(name string) *Constants

func (ApplicationParams[SpecialParams]) GetDB added in v0.16.0

func (m ApplicationParams[SpecialParams]) GetDB(name string) *DbParams

func (ApplicationParams[SpecialParams]) GetLogging added in v0.16.0

func (m ApplicationParams[SpecialParams]) GetLogging() LogParams

func (ApplicationParams[SpecialParams]) GetNetwork added in v0.16.0

func (m ApplicationParams[SpecialParams]) GetNetwork(name string) *NetworkParams

func (ApplicationParams[SpecialParams]) GetParam added in v0.16.1

func (m ApplicationParams[SpecialParams]) GetParam(group, name string) *string

func (ApplicationParams[SpecialParams]) GetRemoteApi added in v0.16.0

func (m ApplicationParams[SpecialParams]) GetRemoteApi(name string) *libCallApi.RemoteApi

func (ApplicationParams[SpecialParams]) GetSecureParam added in v0.16.1

func (m ApplicationParams[SpecialParams]) GetSecureParam(group, name string) *SecurityParam

func (ApplicationParams[SpecialParams]) GetSecurityModule added in v0.16.0

func (m ApplicationParams[SpecialParams]) GetSecurityModule(name string) *SecurityModule

func (ApplicationParams[SpecialParams]) GetSpecificParams added in v0.16.0

func (m ApplicationParams[SpecialParams]) GetSpecificParams(name string) any

type Constants added in v0.16.0

type Constants struct {
	ErrorDesc   map[string]string `yaml:"errorDesc"`
	MessageDesc map[string]string `yaml:"messageDesc"`
}

type DbParams added in v0.16.0

type DbParams struct {
	DataBaseType    string        `yaml:"dbType"`
	DataBaseAddress SecurityParam `yaml:"dbAddress"`
}

type LogParams added in v0.16.0

type LogParams struct {
	LogPath     string        `yaml:"logPath"`
	LogSize     int           `yaml:"logSize"`
	LogCompress bool          `yaml:"logCompress"`
	SkipPaths   []string      `yaml:"skipPaths"`
	LogHeader   string        `yaml:"logHeader"`
	UseSlog     bool          `yaml:"useSlog"`
	Splunk      *SplunkParams `yaml:"splunkParams"`
}

Logging related params

type NetworkParams added in v0.16.0

type NetworkParams struct {
	Port       string `yaml:"port"`
	StaticPort string `yaml:"staticPort"`
	StaticPath string `yaml:"staticPath"`
	///////////////////// TLS ////////////////////////////////////////////
	TlsPort string `yaml:"tlsPort"`
	TlsKey  string `yaml:"tlsKey"`
	TlsCert string `yaml:"tlsCert"`
}

Network related Params

type ParamInterface added in v0.9.1

type ParamInterface interface {
	GetNetwork(name string) *NetworkParams
	GetLogging() LogParams
	GetDB(name string) *DbParams
	GetSecurityModule(name string) *SecurityModule
	GetRemoteApi(name string) *libCallApi.RemoteApi
	GetParam(group, name string) *string
	GetSecureParam(group, name string) *SecurityParam
	GetConstants(name string) *Constants
	GetSpecificParams(name string) any
}

type ParametersMap added in v0.16.0

type ParametersMap struct {
	Params map[string]string `yaml:"params"`
}

type SecureParametersMap added in v0.16.0

type SecureParametersMap struct {
	SecureParams map[string]SecurityParam `yaml:"secureParams"`
}

type SecurityModule added in v0.16.0

type SecurityModule struct {
	Type   string            `yaml:"type"`
	Params map[string]string `yaml:"params"`
	libCrypto.Sm
}

type SecurityParam added in v0.16.0

type SecurityParam struct {
	IsPlain bool   `yaml:"isPlain,omitempty"`
	Value   string `yaml:"value"`
}

func Decrypt added in v0.16.1

func Decrypt(key, iv, name string, field SecurityParam) (*SecurityParam, error)

func FillCipher added in v0.16.1

func FillCipher(key, iv string, field SecurityParam) (*SecurityParam, error)

type SplunkParams added in v0.16.0

type SplunkParams struct {
	URL        string `yaml:"url"`        // Splunk HEC endpoint (e.g., "https://<splunk-server>:8088/services/collector/event")
	Token      string `yaml:"token"`      // HEC token
	SourceType string `yaml:"source"`     // Splunk source type
	Source     string `yaml:"sourceType"` // Splunk source
	Index      string `yaml:"index"`      // Splunk index
	RawHandler bool   `yaml:"rawHandler"`
}

SplunkParams holds configuration for the Splunk logger.

Jump to

Keyboard shortcuts

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