Skip to content

Commit

Permalink
v0.0.19 release~!!
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Oct 26, 2023
1 parent 59f84f4 commit 2883cab
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lang/pack/TagCountPack.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func (this *TagCountPack) Put(name string, v interface{}) {
case string:
this.Data.Put(name, value.NewTextValue(v.(string)))
default:
panic(fmt.Sprintf("Panic, Not supported type %T. available type: value.Value, int, int32, int64, float32, float64, string ", v))
// panic(fmt.Sprintf("Panic, Not supported type %T. available type: value.Value, int, int32, int64, float32, float64, string ", v))
this.Data.Put(name, value.NewTextValue(fmt.Sprintf("%v", v)))
}
}

Expand Down
3 changes: 3 additions & 0 deletions lang/pack/TagCountPack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/whatap/golib/io"
"github.com/whatap/golib/lang/value"
)

func TestTagCoutPackDefault(t *testing.T) {
Expand All @@ -25,6 +26,7 @@ func TestTagCoutPackDefault(t *testing.T) {
p.Put("TESTLONG7", uint64(7))
p.Put("TESTFLOAT1", float32(1.5))
p.Put("TESTFLOAT2", float64(2.5))
p.Put("TESTBOOL", true)

assert.Equal(t, p.GetLong("TESTLONG1"), int64(1))
assert.Equal(t, p.GetLong("TESTLONG2"), int64(2))
Expand All @@ -35,6 +37,7 @@ func TestTagCoutPackDefault(t *testing.T) {
assert.Equal(t, p.GetLong("TESTLONG7"), int64(7))
assert.Equal(t, p.GetFloat("TESTFLOAT1"), float64(1.5))
assert.Equal(t, p.GetFloat("TESTFLOAT2"), float64(2.5))
assert.Equal(t, p.Get("TESTBOOL").(*value.TextValue).Val, "true")

dout := io.NewDataOutputX()
p.Write(dout)
Expand Down
126 changes: 126 additions & 0 deletions logger/logfile/logs/RUM-rumctl-20231026.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
2023/10/26 08:03:48
2023/10/26 08:03:48 ## OPEN LOG FILE rumctl 20231026 08:03:48.539 ##
2023/10/26 08:03:48
2023/10/26 08:03:48 [tytttt] [tytttt]

2023/10/26 08:03:48 [Error] Error

2023/10/26 08:03:48
2023/10/26 08:03:48 ## OPEN LOG FILE rumctl 20231026 08:03:48.539 ##
2023/10/26 08:03:48
2023/10/26 08:03:48 [tytttt] [tytttt]

2023/10/26 08:03:48 [Error] Error

2023/10/26 08:03:48
2023/10/26 08:03:48 ## OPEN LOG FILE rumctl 20231026 08:03:48.539 ##
2023/10/26 08:03:48
2023/10/26 08:03:48 [tytttt] [tytttt]

2023/10/26 08:03:48 [Error] Error

2023/10/26 08:04:09
2023/10/26 08:04:09 ## OPEN LOG FILE rumctl 20231026 08:04:09.298 ##
2023/10/26 08:04:09
2023/10/26 08:04:09 [tytttt] [tytttt]

2023/10/26 08:04:09 [Error] Error

2023/10/26 08:04:09
2023/10/26 08:04:09 ## OPEN LOG FILE rumctl 20231026 08:04:09.298 ##
2023/10/26 08:04:09
2023/10/26 08:04:09 [tytttt] [tytttt]

2023/10/26 08:04:09 [Error] Error

2023/10/26 08:04:09
2023/10/26 08:04:09 ## OPEN LOG FILE rumctl 20231026 08:04:09.299 ##
2023/10/26 08:04:09
2023/10/26 08:04:09 [tytttt] [tytttt]

2023/10/26 08:04:09 [Error] Error

2023/10/26 08:04:29
2023/10/26 08:04:29 ## OPEN LOG FILE rumctl 20231026 08:04:29.99 ##
2023/10/26 08:04:29
2023/10/26 08:04:29 [tytttt] [tytttt]

2023/10/26 08:04:29 [Error] Error

2023/10/26 08:04:29
2023/10/26 08:04:29 ## OPEN LOG FILE rumctl 20231026 08:04:29.99 ##
2023/10/26 08:04:29
2023/10/26 08:04:29 [tytttt] [tytttt]

2023/10/26 08:04:29 [Error] Error

2023/10/26 08:04:29
2023/10/26 08:04:29 ## OPEN LOG FILE rumctl 20231026 08:04:29.99 ##
2023/10/26 08:04:29
2023/10/26 08:04:29 [tytttt] [tytttt]

2023/10/26 08:04:29 [Error] Error

2023/10/26 08:04:52
2023/10/26 08:04:52 ## OPEN LOG FILE rumctl 20231026 08:04:52.24 ##
2023/10/26 08:04:52
2023/10/26 08:04:52 [tytttt] [tytttt]

2023/10/26 08:04:52 [Error] Error

2023/10/26 08:04:52
2023/10/26 08:04:52 ## OPEN LOG FILE rumctl 20231026 08:04:52.24 ##
2023/10/26 08:04:52
2023/10/26 08:04:52 [tytttt] [tytttt]

2023/10/26 08:04:52 [Error] Error

2023/10/26 08:04:52
2023/10/26 08:04:52 ## OPEN LOG FILE rumctl 20231026 08:04:52.25 ##
2023/10/26 08:04:52
2023/10/26 08:04:52 [tytttt] [tytttt]

2023/10/26 08:04:52 [Error] Error

2023/10/26 08:05:13
2023/10/26 08:05:13 ## OPEN LOG FILE rumctl 20231026 08:05:13.455 ##
2023/10/26 08:05:13
2023/10/26 08:05:13 [tytttt] [tytttt]

2023/10/26 08:05:13 [Error] Error

2023/10/26 08:05:13
2023/10/26 08:05:13 ## OPEN LOG FILE rumctl 20231026 08:05:13.455 ##
2023/10/26 08:05:13
2023/10/26 08:05:13 [tytttt] [tytttt]

2023/10/26 08:05:13 [Error] Error

2023/10/26 08:05:13
2023/10/26 08:05:13 ## OPEN LOG FILE rumctl 20231026 08:05:13.455 ##
2023/10/26 08:05:13
2023/10/26 08:05:13 [tytttt] [tytttt]

2023/10/26 08:05:13 [Error] Error

2023/10/26 08:05:33
2023/10/26 08:05:33 ## OPEN LOG FILE rumctl 20231026 08:05:33.787 ##
2023/10/26 08:05:33
2023/10/26 08:05:33 [tytttt] [tytttt]

2023/10/26 08:05:33 [Error] Error

2023/10/26 08:05:33
2023/10/26 08:05:33 ## OPEN LOG FILE rumctl 20231026 08:05:33.787 ##
2023/10/26 08:05:33
2023/10/26 08:05:33 [tytttt] [tytttt]

2023/10/26 08:05:33 [Error] Error

2023/10/26 08:05:33
2023/10/26 08:05:33 ## OPEN LOG FILE rumctl 20231026 08:05:33.787 ##
2023/10/26 08:05:33
2023/10/26 08:05:33 [tytttt] [tytttt]

2023/10/26 08:05:33 [Error] Error

42 changes: 42 additions & 0 deletions logger/logfile/logs/whatap-boot-20231026.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
2023/10/26 08:03:48
2023/10/26 08:03:48 ## OPEN LOG FILE boot 20231026 08:03:48.539 ##
2023/10/26 08:03:48
2023/10/26 08:03:48 [aaa] [aaa]

2023/10/26 08:03:48 [Error] Error

2023/10/26 08:04:09
2023/10/26 08:04:09 ## OPEN LOG FILE boot 20231026 08:04:09.297 ##
2023/10/26 08:04:09
2023/10/26 08:04:09 [aaa] [aaa]

2023/10/26 08:04:09 [Error] Error

2023/10/26 08:04:29
2023/10/26 08:04:29 ## OPEN LOG FILE boot 20231026 08:04:29.98 ##
2023/10/26 08:04:29
2023/10/26 08:04:29 [aaa] [aaa]

2023/10/26 08:04:29 [Error] Error

2023/10/26 08:04:52
2023/10/26 08:04:52 ## OPEN LOG FILE boot 20231026 08:04:52.23 ##
2023/10/26 08:04:52
2023/10/26 08:04:52 [aaa] [aaa]

2023/10/26 08:04:52 [Error] Error

2023/10/26 08:05:13
2023/10/26 08:05:13 ## OPEN LOG FILE boot 20231026 08:05:13.454 ##
2023/10/26 08:05:13
2023/10/26 08:05:13 [aaa] [aaa]

2023/10/26 08:05:13 [Error] Error

2023/10/26 08:05:33
2023/10/26 08:05:33 ## OPEN LOG FILE boot 20231026 08:05:33.787 ##
2023/10/26 08:05:33
2023/10/26 08:05:33 [aaa] [aaa]

2023/10/26 08:05:33 [Error] Error

10 changes: 8 additions & 2 deletions net/oneway/OneWayTcpClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ func GetOneWayTcpClient(opts ...OneWayTcpClientOption) *OneWayTcpClient {
}
func newOneWayTcpClient(opts ...OneWayTcpClientOption) *OneWayTcpClient {
p := new(OneWayTcpClient)
p.Queue = queue.NewRequestQueue(netQueueSize)

o := &oneWayTcpClientConfig{}
o := &oneWayTcpClientConfig{QueueSize: netQueueSize}
for _, opt := range opts {
opt.apply(o)
}

p.Queue = queue.NewRequestQueue(int(o.QueueSize))
p.Log = o.Log
if p.Log == nil {
p.Log = &logger.EmptyLogger{}
Expand Down Expand Up @@ -312,6 +313,7 @@ func (this *OneWayTcpClient) ApplyConfig(conf config.Config) {
host := conf.GetValue("whatap.server.host")
port := conf.GetValueDef("whatap.server.port", "6600")
servers := wnet.GetWhatapHosts(host, port)
qSize := int(conf.GetInt("oneway_queue_size", 0))

this.Pcode = conf.GetLong("pcode", 0)
this.Oid = conf.GetInt("oid", 0)
Expand All @@ -324,4 +326,8 @@ func (this *OneWayTcpClient) ApplyConfig(conf config.Config) {
this.Close()
this.Connect()
}

if qSize > 0 && qSize != this.Queue.GetCapacity() {
this.Queue.SetCapacity(qSize)
}
}
19 changes: 19 additions & 0 deletions net/oneway/OneWayTcpClient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@ func TestMultiConnect(t *testing.T) {
assert.Equal(oneway.Oid, testOid)
}

func TestWithQueueSize(t *testing.T) {
assert := assert.New(t)

//option
oneway := GetOneWayTcpClient(WithUseQueue(), WithQueueSize(10000))

assert.Equal(oneway.Queue.GetCapacity(), 10000)
oneway.Close()
oneway.Destroy()

//non-option - default
oneway = GetOneWayTcpClient(WithUseQueue())

assert.Equal(oneway.Queue.GetCapacity(), 1000)
oneway.Close()
oneway.Destroy()

}

func TestConfigApply(t *testing.T) {
assert := assert.New(t)
conf := &config.MockConfig{}
Expand Down
7 changes: 7 additions & 0 deletions net/oneway/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type oneWayTcpClientConfig struct {
Pcode int64
Oid int32
UseQueue bool
QueueSize int32
ConfigObserver *config.ConfigObserver
}

Expand Down Expand Up @@ -97,6 +98,12 @@ func WithUseQueue() OneWayTcpClientOption {
})
}

func WithQueueSize(size int32) OneWayTcpClientOption {
return newFuncOneWayTcpClientOption(func(c *oneWayTcpClientConfig) {
c.QueueSize = size
})
}

func WithConfigObserver(obj *config.ConfigObserver) OneWayTcpClientOption {
return newFuncOneWayTcpClientOption(func(c *oneWayTcpClientConfig) {
c.ConfigObserver = obj
Expand Down
23 changes: 23 additions & 0 deletions util/hexa32/Hexa32_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package hexa32

import (
// "fmt"
"testing"

"github.com/stretchr/testify/assert"
)

func TestToSting32(t *testing.T) {
s := int64(-743752992412427445)
v := ToString32(s)
s1 := "zkkincvom0p5l"
assert.Equal(t, s1, v)

}

func TestToLong32(t *testing.T) {
s := "zkkincvom0p5l"
s1 := int64(-743752992412427445)
v := ToLong32(s)
assert.Equal(t, s1, v)
}

0 comments on commit 2883cab

Please sign in to comment.