common

package module
v0.0.0-...-491eb26 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: GPL-3.0 Imports: 11 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Head  = newlinePrintfFunc(color.New(color.FgHiMagenta).Add(color.Bold).Add(color.Underline).PrintfFunc())
	Out   = newlinePrintfFunc(color.New(color.FgHiWhite).PrintfFunc())
	Info  = newlinePrintfFunc(color.New(color.FgCyan).PrintfFunc())
	Warn  = newlinePrintfFunc(color.New(color.FgHiYellow).Add(color.Bold).PrintfFunc())
	Err   = errorPrintfFunc(color.New(color.FgHiRed).Add(color.Bold).PrintfFunc())
	Fatal = func(format string, args ...interface{}) {
		msg := fmt.Sprintf(format, args...)
		color.New(color.FgHiRed).Add(color.Bold).Add(color.BgBlack).Println(msg)
		os.Exit(1)
	}
	Ok              = newlinePrintfFunc(color.New(color.FgHiGreen).PrintfFunc())
	TELEGRAM_TOKEN  string
	CHAT_ID         string
	PYTHON_API_HOST string
	REGISTRY_HOST   string
)

Functions

func ExternalIP

func ExternalIP() (string, error)

func FailError

func FailError(err error, format string, args ...interface{})

func GetEnv

func GetEnv(key string, defaultValue string) string

It returns the value if found, otherwise the provided default value.

func GetEnvAsBool

func GetEnvAsBool(key string, defaultValue bool) bool

It returns the value if found, otherwise the provided default value.

func GetEnvAsInt

func GetEnvAsInt(key string, defaultValue int) int

It returns the value if found, otherwise the provided default value.

func HealthHandler

func HealthHandler() http.HandlerFunc

HealthHandler returns an HTTP handler function for the health check endpoint.

func RegisterService

func RegisterService(service *ServiceConfig) error

func SendMessageToTelegram

func SendMessageToTelegram(message string)

SendMessageToChat sends a message to the chat using the Python API.

Types

type HealthCheck

type HealthCheck struct {
	Endpoint string `json:"endpoint"`
	Interval string `json:"interval"`
	Timeout  string `json:"timeout"`
}

type MinIOConfig

type MinIOConfig struct {
	Endpoint        string
	AccessKeyID     string
	SecretAccessKey string
	UseSSL          bool
	TemplatesBucket string // Add bucket name to config
}

Config holds the configuration for MinIO.

func LoadMinIOConfig

func LoadMinIOConfig() *MinIOConfig

LoadConfig loads the configuration from environment variables.

type PostgreSQLConfig

type PostgreSQLConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
}

func LoadPostgreSQLConfig

func LoadPostgreSQLConfig() *PostgreSQLConfig

LoadConfig loads the PostgreSQL database configuration from environment variables.

type RabbitMQConfig

type RabbitMQConfig struct {
	Host     string
	Username string
	Password string
}

Config holds the configuration for RabbitMQ

func LoadRabbitMQConfig

func LoadRabbitMQConfig() *RabbitMQConfig

LoadConfig loads the configuration from environment variables

type RedisConfig

type RedisConfig struct {
	Host string
	Port string
}

func LoadRedisConfig

func LoadRedisConfig() *RedisConfig

LoadConfig loads the Redis configuration from environment variables.

type ServiceConfig

type ServiceConfig struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Address     string      `json:"address"`
	Port        int         `json:"port"`
	HealthCheck HealthCheck `json:"healthCheck"`
}

func LoadServiceConfig

func LoadServiceConfig(jsonData []byte) (*ServiceConfig, error)

Jump to

Keyboard shortcuts

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