tf

package
v1.0.62 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PubSubLogIAmAliveKey = "log:-i-am-alive-"
View Source
var PubSubLogIAmAliveValue = "yes"
View Source
var PubSubLogKey = "log:pub-sub-channel:"
View Source
var URLDownloadPath string

Functions

func AddRefCount added in v1.0.51

func AddRefCount(requestId string)

func CloseLogFile

func CloseLogFile(requestId string)

func FileDownloadMiddleware

func FileDownloadMiddleware(path string, fp io.WriteCloser) gin.HandlerFunc

func FileDownloadMiddleware(path string, fp *os.File) gin.HandlerFunc {

func GenUUID

func GenUUID() string

GenUUID generates a UUID and returns it.

func GetLogFile

func GetLogFile(requestId string) (fpOut io.WriteCloser)

func GetLogFile(requestId string) (fpOut *os.File) {

func GetLogFilePtr

func GetLogFilePtr(c *gin.Context) (perReqLog io.WriteCloser)

func GetLogFilePtr(c *gin.Context) (perReqLog *os.File) {

func InFileDownloadList

func InFileDownloadList(s string) (fn string, found bool)

func RequestIdMiddleware

func RequestIdMiddleware() gin.HandlerFunc

func ResetLogFile

func ResetLogFile(newLf io.WriteCloser)

func ResetLogFile(newLf *os.File) {

func SetLogFile

func SetLogFile(requestId string, fp io.WriteCloser)

func SetLogFile(requestId string, fp *os.File) {

func TimedCleanupLogFile

func TimedCleanupLogFile()

func ValidateAuthKeyHmac added in v1.0.58

func ValidateAuthKeyHmac(AuthKey, Pw string) bool

Types

type LogMessage added in v1.0.58

type LogMessage struct {
	Cmd         string `json:"Cmd,omitempty"`
	Data        string `json:"Data,omitempty"`
	ReqId       string `json:"ReqId,omitempty"`
	FileName    string `json:"FileName,omitempty"`
	ClusterName string `json:"ClusterName,omitempty"`
	AuthKey     string `json:"AuthKey,omitempty"`
}

type RedisLogger added in v1.0.58

type RedisLogger struct {
	ReqId       string
	FileName    string
	ClusterName string
	AuthKey     string `json:"AuthKey,omitempty"`
	// contains filtered or unexported fields
}

func (RedisLogger) Close added in v1.0.58

func (ee RedisLogger) Close() (err error)

func (RedisLogger) Command added in v1.0.58

func (ee RedisLogger) Command(cmd string) (err error)

func (RedisLogger) Flush added in v1.0.58

func (ee RedisLogger) Flush() (err error)

func (RedisLogger) Write added in v1.0.58

func (ee RedisLogger) Write(p []byte) (int, error)

type RequestLogFile

type RequestLogFile struct {
	// contains filtered or unexported fields
}

type TfType added in v1.0.58

type TfType struct {
	Ctx         context.Context
	Rdb         *redis.Client
	ClusterName string
}

func NewSetupTf added in v1.0.58

func NewSetupTf(ctx context.Context, rdb *redis.Client, ClusterName string) (ex *TfType)

func (*TfType) AliveCheck added in v1.0.58

func (ttf *TfType) AliveCheck(AuthKey string) bool

/*

type LogMessage struct {
	Cmd         string `json:"Cmd,omitempty"`
	Data        string `json:"Data,omitempty"`
	ReqId       string `json:"ReqId,omitempty"`
	FileName    string `json:"FileName,omitempty"`
	ClusterName string `json:"ClusterName,omitempty"`
	AuthKey     string `json:"AuthKey,omitempty"`
}

*/ case "x.alive.check":

dbgo.Fprintf(logRedisLogger, "%(magenta)Received 'x.alive.check': %s\n", dbgo.SVar(message))
dbgo.Fprintf(os.Stderr, "%(magenta)Received 'x.alive.check': %s\n", dbgo.SVar(message))
xkey := "logsvr-alive:" + tf.ReqId
err := rdb.Set(ctx, xkey, tf.Data, 60*time.Second).Err() // Use ReqId as Id, use Data as Data.
if err != nil {
	dbgo.Fprintf(os.Stderr, "%(red)Error setting i-am-alive message, key=%s value=%s\n", xKey, tf.Data)
	dbgo.Fprintf(logRedisLogger, "%(red)Error setting i-am-alive message, key=%s value=%s\n", xKey, tf.Data)
}

func (*TfType) CheckRedisWorking added in v1.0.58

func (ttf *TfType) CheckRedisWorking() (err error)

CheckRedisWorking does a test set and get to redis client rdb is setup as global in main.go this is called in main.go if UseRedis == "yes" in local cfg

func (*TfType) NewRedisLogger added in v1.0.58

func (ttf *TfType) NewRedisLogger(ReqId, AuthKey, clusterName string) (lm *RedisLogger, wp io.WriteCloser, err error)

func (*TfType) NewRedisLoggerFile added in v1.0.58

func (ttf *TfType) NewRedisLoggerFile(FileName, AuthKey, clusterName string) (lm *RedisLogger, wp io.WriteCloser, err error)

func (*TfType) RequestLogger added in v1.0.58

func (ttf *TfType) RequestLogger(LogFileName, AuthKey, clusterName string) gin.HandlerFunc

Jump to

Keyboard shortcuts

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