common

package
v0.0.0-...-9810caa Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package common contains many useful functions for logging, config, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompatibleLog

func CompatibleLog(conf *Config) string

CompatibleLog for making log_file and log_dir compatible

func GetFileNameDayAndOldDay

func GetFileNameDayAndOldDay(conf *DatabaseConf, prefix string) (string, string)

GetFileNameDayAndOldDay get name of new file and old file

func GetLastNum

func GetLastNum(str string, split string) int

GetLastNum get file name number suffix

func Hostname

func Hostname(conf *DatabaseConf) string

Hostname get current hostname

func MyNewLogger

func MyNewLogger(conf *Config, logFile string) *logs.BeeLogger

MyNewLogger constructor of needed logger

Types

type BaseConf

type BaseConf struct {
	BaseDir      string `toml:"basedir"`
	SnapshotDir  string `toml:"snapshot_dir"`
	SnapshotDay  int    `toml:"snapshot_day"`
	LogDir       string `toml:"log_dir"`
	LogFile      string `toml:"log_file"`
	LogLevel     int    `toml:"log_level"`
	FalconClient string `toml:"falcon_client"`
	IgnoreFile   string `toml:"ignore_file"`
}

BaseConf config about dir, log, etc.

type Config

type Config struct {
	Base  BaseConf       `toml:"default"`
	Mysql []DatabaseConf `toml:"mysql"`
}

Config for initializing. This can be loaded from TOML file with -c

func NewConfig

func NewConfig(file string) (*Config, error)

NewConfig the constructor of config

type DatabaseConf

type DatabaseConf struct {
	User     string `toml:"user"`
	Password string `toml:"password"`
	Host     string `toml:"host"`
	Port     int    `toml:"port"`
	Endpoint string `toml:"endpoint"`
}

DatabaseConf config about database

type DbConn

type DbConn struct {
	Conn   mysql.Conn
	Health bool
}

func NewMySQLConnection

func NewMySQLConnection(conf DatabaseConf) (*DbConn, error)

NewMySQLConnection the constructor of mysql connecting

func (DbConn) HealthCheck

func (dbConn DbConn) HealthCheck()

Jump to

Keyboard shortcuts

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