apputil

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 10 Imported by: 0

README

apputil

Application utility functions for enterprise software development

  • Logger using uber-go/zap + gopkg.in/natefinch/lumberjack.v2

  • Unique ID using muyo/sno

  • General utility functions

    • IsEmptyJson: check if given data is an empty JSON object

Version 1.2.0

  • Add Time Sorted ID features from github.com/vishal-bihani/go-tsid

Documentation

Index

Constants

View Source
const (
	MSG_CREATE_FACTORY_ERROR = "Error fetching customized TsidFactory, fallback to default"
	MSG_TSID_GENERATE_ERROR  = "Error generating tsid, fallback to default generator"
)

Variables

View Source
var AppZapConfig zapcore.EncoderConfig
View Source
var AppZapConsoleEncoder zapcore.Encoder
View Source
var AppZapCore zapcore.Core
View Source
var AppZapFileEncoder zapcore.Encoder
View Source
var AppZapWriter zapcore.WriteSyncer
View Source
var Logger *zap.Logger
View Source
var ZapLevel zapcore.Level

Functions

func ChangeLogLevel

func ChangeLogLevel(level string)

func GenerateExtendedTsidNumber added in v1.2.0

func GenerateExtendedTsidNumber(options ...bool) string

func GenerateRequestID

func GenerateRequestID() sno.ID

func GenerateRequestIDByte

func GenerateRequestIDByte() []byte

func GenerateRequestIDString

func GenerateRequestIDString() string

func GenerateTsidBytes added in v1.2.0

func GenerateTsidBytes(options ...bool) []byte

func GenerateTsidNumber added in v1.2.0

func GenerateTsidNumber() int64

func GenerateTsidString added in v1.2.0

func GenerateTsidString(options ...bool) string

*

  • GenerateTsidString
  • @params options - [usePrefix, useSuffix]

func GetEpoch added in v1.2.0

func GetEpoch() int64

func GetIDMeta

func GetIDMeta() byte

func GetNodeBits added in v1.2.0

func GetNodeBits() int32

func GetNodeId added in v1.2.0

func GetNodeId() int32

func GetPrefix added in v1.2.0

func GetPrefix() string

func GetSuffix added in v1.2.0

func GetSuffix() string

func InitWithConfig added in v1.2.0

func InitWithConfig(config *UidConfig)

func InitializeLogger

func InitializeLogger(maxSize int, maxBackups int, maxAge int, compress bool, logBaseDir string)

func IsEmptyJson added in v1.1.0

func IsEmptyJson(data interface{}) bool

func SetEpoch added in v1.2.0

func SetEpoch(b int64)

func SetIDMeta

func SetIDMeta(b byte)

func SetNodeBits added in v1.2.0

func SetNodeBits(b int32)

func SetNodeId added in v1.2.0

func SetNodeId(b int32)

func SetPrefix added in v1.2.0

func SetPrefix(s string)

func SetSuffix added in v1.2.0

func SetSuffix(s string)

Types

type UidConfig added in v1.2.0

type UidConfig struct {
	Meta     byte
	NodeId   int32
	NodeBits int32
	Epoch    int64
	Prefix   string
	Suffix   string
}

Jump to

Keyboard shortcuts

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