utils

package
v0.0.0-...-ed86741 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CPU_CORES_CPUINFO_ERROR  = -2
	LAVG_TREND_CPUINFO_ERROR = -1
	LAVG_TREND_ERROR         = 0
	LAVG_TREND_INCREASING    = 1
	LAVG_TREND_NORMAL        = 2
	LAVG_LOAD_LEVEL_YELLOW   = 70
	DEL_FILE_LIST_E_SLEEP    = 60
)

Variables

This section is empty.

Functions

func GetFieldTagMap

func GetFieldTagMap(d interface{}, tagIdentifier string) map[string]string

func GetFieldValue

func GetFieldValue(d interface{}, field string) interface{}

func GetTagValueMap

func GetTagValueMap(d interface{}, tagIdentifier string) map[string]string

Types

type Migrator

type Migrator struct {
	ProceedOnError bool
}

func (*Migrator) Migrate

func (m *Migrator) Migrate(db *sql.DB, filePath string) error

func (*Migrator) Values

func (m *Migrator) Values(proceedOnError bool)

type RDBMS

type RDBMS struct {
	Conn    *sql.DB
	ConnErr error
	Conf    *RDBMSConfig
}

func (*RDBMS) Close

func (d *RDBMS) Close() error

func (*RDBMS) Connect

func (d *RDBMS) Connect() error

func (*RDBMS) ConnectM2

func (d *RDBMS) ConnectM2() error

func (*RDBMS) DropTable

func (d *RDBMS) DropTable(tableName string) error

func (*RDBMS) SelectRows

func (d *RDBMS) SelectRows(tableName, columns, condition, limit, offset, orderBy string) *sql.Rows

*

  • @param type string $dbObj
  • @param type string $tablename
  • @param type string $columns
  • @param type string $condition
  • @param type integer $limit
  • @param type integer $offset
  • @param type string $order_by
  • @return array

func (*RDBMS) UpdateRows

func (d *RDBMS) UpdateRows(table string, updateDataArray map[string]string, optionDataArray map[string]string) *sql.Rows

*

  • @param type string $dbObj
  • @param type string $tablename
  • @param type string updateDataArray
  • @param type string optionDataArray
  • @return type rows

func (*RDBMS) UpdateTable

func (d *RDBMS) UpdateTable(table string, updateDataArray map[string]string, optionDataArray map[string]string) (sql.Result, error)

type RDBMSConfig

type RDBMSConfig struct {
	DriverName      string // Name of the SQL driver viz., mysql, postgres, sqlite etc
	HostName        string // Hostname of the SQL server
	Port            int64  // Port number of the SQL server
	Database        string // Name of the database to connect to on the SQL server
	UserName        string // Username part of the SQL server credentials
	Password        string // Password for the afore-defined UserName
	MaxOpenConns    int    // Maximum number of connections to be opened
	MaxIdleConns    int    // Maximum number of idle connections to be kept
	MaxLifeTimeConn int    // Maximum life of connection (in seconds)
}

func (*RDBMSConfig) Connect

func (c *RDBMSConfig) Connect() (*sql.DB, error)

func (*RDBMSConfig) DSN

func (c *RDBMSConfig) DSN() string

func (*RDBMSConfig) String

func (c *RDBMSConfig) String() string

func (*RDBMSConfig) Values

func (c *RDBMSConfig) Values(driverName, hostName string, port int64, database, userName, password string, maxOpenconns, maxIdleConns, maxLifeTimeConn int)

type Utils

type Utils struct {
	Log *log.Logger
}

func NewUtils

func NewUtils(l *log.Logger) *Utils

func (*Utils) CPUCores

func (u *Utils) CPUCores() int32

func (*Utils) CPUInfo

func (u *Utils) CPUInfo() ([]cpu.InfoStat, error)

func (*Utils) DeleteFileByAge

func (u *Utils) DeleteFileByAge(path string, minAgeForDeletion time.Duration) (bool, error)

func (*Utils) DeleteFileList

func (u *Utils) DeleteFileList(fileExtToClean, directoryPath string) int

func (*Utils) DeleteFileListE

func (u *Utils) DeleteFileListE(fileExtToClean, directoryPath string) int

DeleteFileListE( fileExtToClean, directoryPath string) int Empathetic version of the DeleteFileList() function. Checks system load average for overages and depending upon the result pauses or keeps deletion going

func (*Utils) FileExists

func (u *Utils) FileExists(path string) bool

func (*Utils) GetFileList

func (u *Utils) GetFileList(directoryPath string) map[int]string

func (*Utils) ImplodeMapIntString

func (u *Utils) ImplodeMapIntString(glue string, pieces map[int]string) string

func (*Utils) ImplodeStringArr

func (u *Utils) ImplodeStringArr(glue string, pieces []string) string

func (*Utils) LoadAvg

func (u *Utils) LoadAvg() (*load.AvgStat, error)

func (*Utils) LoadAvgCheck

func (u *Utils) LoadAvgCheck() int

func (*Utils) MicroTime

func (u *Utils) MicroTime() float64

func (*Utils) PrintAWSIPs

func (u *Utils) PrintAWSIPs(ipVersion int, region, service, networkBorderGroup string)

See: https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html

func (*Utils) PrintCloudflareIPV4IPs

func (u *Utils) PrintCloudflareIPV4IPs(appendDeny bool)

func (*Utils) PrintCloudflareIPV6IPs

func (u *Utils) PrintCloudflareIPV6IPs(appendDeny bool)

func (*Utils) PrintGithubIPs

func (u *Utils) PrintGithubIPs(appendDeny bool)

func (*Utils) RenderTemplate

func (u *Utils) RenderTemplate(res http.ResponseWriter, templateType string, templateName string, data interface{})

RenderTemplate serves HTML template

Jump to

Keyboard shortcuts

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