-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Aug 21, 2023
1 parent
146e229
commit 14e1b55
Showing
18 changed files
with
535 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
module github.com/whatap/golib | ||
|
||
go 1.14 | ||
go 1.17 | ||
|
||
require ( | ||
github.com/BurntSushi/toml v0.3.1 // indirect | ||
github.com/google/uuid v1.3.0 | ||
github.com/kr/pretty v0.3.0 // indirect | ||
github.com/magiconair/properties v1.8.7 | ||
github.com/natefinch/lumberjack v2.0.0+incompatible | ||
github.com/shirou/gopsutil v3.21.11+incompatible | ||
github.com/stretchr/testify v1.8.1 | ||
golang.org/x/text v0.7.0 | ||
) | ||
|
||
require ( | ||
github.com/BurntSushi/toml v0.3.1 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/go-ole/go-ole v1.2.6 // indirect | ||
github.com/kr/pretty v0.3.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/objx v0.5.0 // indirect | ||
github.com/tklauser/go-sysconf v0.3.11 // indirect | ||
github.com/tklauser/numcpus v0.6.0 // indirect | ||
github.com/yusufpapurcu/wmi v1.2.2 // indirect | ||
golang.org/x/text v0.7.0 | ||
golang.org/x/sys v0.2.0 // indirect | ||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect | ||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package lang | ||
|
||
const ( | ||
EVENT_LEVEL_CRITICAL = 30 | ||
EVENT_LEVEL_WARNING = 20 | ||
EVENT_LEVEL_INFO = 10 | ||
EVENT_LEVEL_NONE = 0 | ||
) | ||
|
||
var EventLevelName = map[int]string{30: "CRITICAL", 20: "WARNING", 10: "INFO", 0: "NONE"} | ||
var EventLevelValue = map[string]int{"CRITICAL": 30, "WARNING": 20, "INFO": 10, "NONE": 0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package lang | ||
|
||
const ( | ||
MESSAGE_FILE_WRITE_OPEN = "FileWriteOpen" | ||
MESSAGE_FILE_READ_OPEN = "FileReadOpen" | ||
MESSAGE_JSP = "JSP" | ||
MESSAGE_CLOSE_CONNECTION = "Close Connection" | ||
MESSAGE_TRANSACTION_BACKSTACK = "TRANSACTION BACKSTACK" | ||
MESSAGE_PREPARED_SQL = "prepare-sql" | ||
MESSAGE_OPEN_CONNECTION_STACK = "Open Connection Stack" | ||
MESSAGE_CAP_ARG = "TraceArgs" | ||
MESSAGE_CAP_RETURN = "TraceReturn" | ||
MESSAGE_CAP_THIS = "TraceConstructor" | ||
MESSAGE_CONN_ALLOC_DUP = "Connection allocated to multi-threads" | ||
MESSAGE_THREAD_START = "Thread-Start" | ||
MESSAGE_SOCKET_OPEN = "SocketOpen" | ||
MESSAGE_CUSTOM_OPEN = "CustomOpen" | ||
MESSAGE_CUSTOM_CLOSE = "CustomClose" | ||
MESSAGE_ASYNC_CTX = "AsyncCtx" | ||
MESSAGE_EXCEPTION = "EXCEPTION" | ||
MESSAGE_THREAD_CHILD = "Child-Thread-Call" | ||
MESSAGE_ORIGIN_URL = "OriginURL" | ||
MESSAGE_MESSAGE = "MESSAGE" | ||
MESSAGE_METHOD_DEBUG = "Debug-Method" | ||
MESSAGE_VIRTUAL_TX = "Virtual-Tx" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package pack | ||
|
||
import ( | ||
"github.com/whatap/golib/io" | ||
"github.com/whatap/golib/util/compressutil" | ||
"github.com/whatap/golib/util/stringutil" | ||
) | ||
|
||
const ( | ||
ZIPPED = 1 | ||
UN_ZIPPED = 0 | ||
) | ||
|
||
type LogSinkZipPack struct { | ||
AbstractPack | ||
|
||
Records []byte | ||
RecordCount int | ||
Status byte | ||
} | ||
|
||
func NewLogSinkZipPack() *LogSinkZipPack { | ||
p := new(LogSinkZipPack) | ||
return p | ||
} | ||
|
||
func (this *LogSinkZipPack) GetPackType() int16 { | ||
return PACK_LOGSINK_ZIP | ||
} | ||
|
||
func (this *LogSinkZipPack) Write(dout *io.DataOutputX) { | ||
this.AbstractPack.Write(dout) | ||
|
||
dout.WriteByte(this.Status) | ||
dout.WriteDecimal(int64(this.RecordCount)) | ||
dout.WriteBlob(this.Records) | ||
} | ||
func (this *LogSinkZipPack) Read(din *io.DataInputX) { | ||
this.AbstractPack.Read(din) | ||
|
||
this.Status = din.ReadByte() | ||
this.RecordCount = int(din.ReadDecimal()) | ||
this.Records = din.ReadBlob() | ||
} | ||
|
||
func (this *LogSinkZipPack) SetRecords(records []byte, zipMinSize int) { | ||
this.Records, _ = this.doZip(records, zipMinSize) | ||
} | ||
|
||
func (this *LogSinkZipPack) doZip(records []byte, zipMinSize int) ([]byte, error) { | ||
if this.Status != UN_ZIPPED { | ||
return records, nil | ||
} | ||
if len(records) < zipMinSize { | ||
return records, nil | ||
} | ||
this.Status = ZIPPED | ||
return compressutil.DoZip(records) | ||
} | ||
|
||
func (this *LogSinkZipPack) doUnZip() ([]byte, error) { | ||
if this.Status != ZIPPED { | ||
return this.Records, nil | ||
} | ||
return compressutil.UnZip(this.Records) | ||
} | ||
|
||
func (this *LogSinkZipPack) GetRecords() []*LogSinkPack { | ||
items := make([]*LogSinkPack, 0) | ||
if this.Records == nil { | ||
return items | ||
} | ||
data, err := this.doUnZip() | ||
if err != nil { | ||
return items | ||
} | ||
|
||
in := io.NewDataInputX(data) | ||
for i := 0; i < this.RecordCount; i++ { | ||
tmp := ReadPack(in) | ||
if tmp != nil { | ||
if p, ok := tmp.(*LogSinkPack); ok { | ||
p.Pcode = this.Pcode | ||
p.Oid = this.Oid | ||
p.Okind = this.Okind | ||
p.Onode = this.Onode | ||
// time 은 자기시간 사용 | ||
items = append(items, p) | ||
} | ||
} | ||
} | ||
|
||
return items | ||
|
||
} | ||
|
||
func (this *LogSinkZipPack) ToString() string { | ||
sb := stringutil.NewStringBuffer() | ||
sb.Append("LogSinkZipPack ") | ||
sb.Append(this.AbstractPack.ToString()) | ||
sb.AppendFormat("records=%d bytes", len(this.Records)) | ||
return sb.ToString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
package service | ||
|
||
import () | ||
|
||
const ( | ||
GET byte = 1 | ||
POST byte = 2 | ||
PUT byte = 3 | ||
DELETE byte = 4 | ||
GET byte = 1 | ||
POST byte = 2 | ||
PUT byte = 3 | ||
DELETE byte = 4 | ||
PATCH byte = 5 | ||
OPTIONS byte = 6 | ||
HEAD byte = 7 | ||
TRACE byte = 8 | ||
) | ||
|
||
var WebMethodName = map[string]byte{"GET": 1, "POST": 2, "PUT": 3, "DELETE": 4} | ||
var WebMethodValue = map[byte]string{1: "GET", 2: "POST", 3: "PUT", 4: "DELETE"} | ||
var WebMethodName = map[string]byte{"GET": 1, "POST": 2, "PUT": 3, "DELETE": 4, "PATCH": 5, "OPTIONS": 6, "HEAD": 7, "TRACE": 8} | ||
var WebMethodValue = map[byte]string{1: "GET", 2: "POST", 3: "PUT", 4: "DELETE", 5: "PATCH", 6: "OPTIONS", 7: "HEAD", 8: "TRACE"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.