update packages

This commit is contained in:
kevin 2020-07-28 18:26:55 +08:00
parent 6ba8cc02c1
commit b1975d29a7
9 changed files with 6 additions and 233 deletions

View File

@ -3,7 +3,7 @@ package dq
import (
"sync"
"github.com/beanstalkd/beanstalk"
"github.com/beanstalkd/go-beanstalk"
)
type connection struct {

View File

@ -6,7 +6,7 @@ import (
"zero/core/logx"
"zero/core/syncx"
"github.com/beanstalkd/beanstalk"
"github.com/beanstalkd/go-beanstalk"
)
type (

View File

@ -7,7 +7,7 @@ import (
"strings"
"time"
"github.com/beanstalkd/beanstalk"
"github.com/beanstalkd/go-beanstalk"
)
var ErrTimeBeforeNow = errors.New("can't schedule task to past time")

View File

@ -1,65 +0,0 @@
package main
import (
"log"
"time"
"zero/core/stores/clickhouse"
"zero/core/stores/sqlx"
)
func main() {
conn := clickhouse.New("tcp://127.0.0.1:9000")
_, err := conn.Exec(`
CREATE TABLE IF NOT EXISTS example (
country_code FixedString(2),
os_id UInt8,
browser_id UInt8,
categories Array(Int16),
action_day Date,
action_time DateTime
) engine=Memory
`)
if err != nil {
log.Fatal(err)
}
conn.Transact(func(session sqlx.Session) error {
stmt, err := session.Prepare("INSERT INTO example (country_code, os_id, browser_id, categories, action_day, action_time) VALUES (?, ?, ?, ?, ?, ?)")
if err != nil {
log.Fatal(err)
}
defer stmt.Close()
for i := 0; i < 10; i++ {
_, err := stmt.Exec("RU", 10+i, 100+i, []int16{1, 2, 3}, time.Now(), time.Now())
if err != nil {
log.Fatal(err)
}
}
return nil
})
var items []struct {
CountryCode string `db:"country_code"`
OsID uint8 `db:"os_id"`
BrowserID uint8 `db:"browser_id"`
Categories []int16 `db:"categories"`
ActionTime time.Time `db:"action_time"`
}
err = conn.QueryRows(&items, "SELECT country_code, os_id, browser_id, categories, action_time FROM example")
if err != nil {
log.Fatal(err)
}
for _, item := range items {
log.Printf("country: %s, os: %d, browser: %d, categories: %v, action_time: %s",
item.CountryCode, item.OsID, item.BrowserID, item.Categories, item.ActionTime)
}
if _, err := conn.Exec("DROP TABLE example"); err != nil {
log.Fatal(err)
}
}

View File

@ -1,41 +0,0 @@
package main
import (
"encoding/json"
"fmt"
"log"
jsonx "github.com/segmentio/encoding/json"
)
type A struct {
AA string `json:"aa,omitempty"`
}
type B struct {
*A
BB string `json:"bb,omitempty"`
}
func main() {
var b B
b.BB = "b"
b.A = new(A)
b.A.AA = ""
fmt.Println("github.com/segmentio/encoding/json")
data, err := jsonx.Marshal(b)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(data))
fmt.Println()
fmt.Println("encoding/json")
data, err = json.Marshal(b)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(data))
}

View File

@ -1,74 +0,0 @@
package testjson
import (
"encoding/json"
"testing"
jsoniter "github.com/json-iterator/go"
segment "github.com/segmentio/encoding/json"
)
const input = `{"@timestamp":"2020-02-12T14:02:10.849Z","@metadata":{"beat":"filebeat","type":"doc","version":"6.1.1","topic":"k8slog"},"index":"k8slog","offset":908739,"stream":"stdout","topic":"k8slog","k8s_container_name":"shield-rpc","k8s_pod_namespace":"xx-xiaoheiban","stage":"gray","prospector":{"type":"log"},"k8s_node_name":"cn-hangzhou.i-bp15w8irul9hmm3l9mxz","beat":{"name":"log-pilot-7s6qf","hostname":"log-pilot-7s6qf","version":"6.1.1"},"source":"/host/var/lib/docker/containers/4e6dca76f3e38fb8b39631e9bb3a19f9150cc82b1dab84f71d4622a08db20bfb/4e6dca76f3e38fb8b39631e9bb3a19f9150cc82b1dab84f71d4622a08db20bfb-json.log","level":"info","duration":"39.425µs","content":"172.25.5.167:49976 - /remoteshield.Filter/Filter - {\"sentence\":\"王XX2月12日作业\"}","k8s_pod":"shield-rpc-57c9dc6797-55skf","docker_container":"k8s_shield-rpc_shield-rpc-57c9dc6797-55skf_xx-xiaoheiban_a8341ba0-30ee-11ea-8ac4-00163e0fb3ef_0"}`
func BenchmarkStdJsonMarshal(b *testing.B) {
m := make(map[string]interface{})
if err := json.Unmarshal([]byte(input), &m); err != nil {
b.FailNow()
}
for i := 0; i < b.N; i++ {
if _, err := json.Marshal(m); err != nil {
b.FailNow()
}
}
}
func BenchmarkJsonIteratorMarshal(b *testing.B) {
m := make(map[string]interface{})
if err := jsoniter.Unmarshal([]byte(input), &m); err != nil {
b.FailNow()
}
for i := 0; i < b.N; i++ {
if _, err := jsoniter.Marshal(m); err != nil {
b.FailNow()
}
}
}
func BenchmarkSegmentioMarshal(b *testing.B) {
m := make(map[string]interface{})
if err := segment.Unmarshal([]byte(input), &m); err != nil {
b.FailNow()
}
for i := 0; i < b.N; i++ {
if _, err := jsoniter.Marshal(m); err != nil {
b.FailNow()
}
}
}
func BenchmarkStdJsonUnmarshal(b *testing.B) {
for i := 0; i < b.N; i++ {
m := make(map[string]interface{})
if err := json.Unmarshal([]byte(input), &m); err != nil {
b.FailNow()
}
}
}
func BenchmarkJsonIteratorUnmarshal(b *testing.B) {
for i := 0; i < b.N; i++ {
m := make(map[string]interface{})
if err := jsoniter.Unmarshal([]byte(input), &m); err != nil {
b.FailNow()
}
}
}
func BenchmarkSegmentioUnmarshal(b *testing.B) {
for i := 0; i < b.N; i++ {
m := make(map[string]interface{})
if err := segment.Unmarshal([]byte(input), &m); err != nil {
b.FailNow()
}
}
}

View File

@ -1,31 +0,0 @@
package testjson
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMarshal(t *testing.T) {
type A struct {
A string `json:"a"`
AA string `json:"aa"`
}
type B struct {
A // can't be A A, or A `json...`
B string `json:"b"`
}
type C struct {
A `json:"a"`
C string `json:"c"`
}
a := A{A: "a", AA: "aa"}
b := B{A: a, B: "b"}
c := C{A: a, C: "c"}
bstr, _ := json.Marshal(b)
cstr, _ := json.Marshal(c)
assert.Equal(t, `{"a":"a","aa":"aa","b":"b"}`, string(bstr))
assert.Equal(t, `{"a":{"a":"a","aa":"aa"},"c":"c"}`, string(cstr))
}

8
go.mod
View File

@ -7,8 +7,7 @@ require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 // indirect
github.com/alicebob/miniredis v2.5.0+incompatible
github.com/beanstalkd/beanstalk v0.0.0-20200229072127-2b7b37f17578
github.com/beanstalkd/go-beanstalk v0.0.0-20200229072127-2b7b37f17578 // indirect
github.com/beanstalkd/go-beanstalk v0.1.0
github.com/coreos/bbolt v1.3.1-coreos.6 // indirect
github.com/coreos/etcd v3.3.18+incompatible
github.com/coreos/go-semver v0.2.0 // indirect
@ -17,7 +16,6 @@ require (
github.com/dchest/siphash v1.2.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fatih/color v1.9.0 // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/frankban/quicktest v1.7.2 // indirect
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
github.com/go-redis/redis v6.15.7+incompatible
@ -36,24 +34,20 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.14.3 // indirect
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/json-iterator/go v1.1.9
github.com/justinas/alice v1.2.0
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/kshvakov/clickhouse v1.3.11
github.com/lib/pq v1.3.0
github.com/mailru/easyjson v0.7.1 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/olekukonko/tablewriter v0.0.4
github.com/olivere/elastic v6.2.30+incompatible
github.com/onsi/ginkgo v1.7.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/pierrec/lz4 v2.5.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.5.1
github.com/segmentio/encoding v0.1.12
github.com/segmentio/kafka-go v0.3.5
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/spaolacci/murmur3 v1.1.0

14
go.sum
View File

@ -16,10 +16,8 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGn
github.com/alicebob/miniredis v2.5.0+incompatible h1:yBHoLpsyjupjz3NL3MhKMVkR41j82Yjf3KFv7ApYzUI=
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
github.com/beanstalkd/beanstalk v0.0.0-20200229072127-2b7b37f17578 h1:9bjGO11r2d8O5uPJDrA93RR6uPzzIE4pPvjYn+k/ej8=
github.com/beanstalkd/beanstalk v0.0.0-20200229072127-2b7b37f17578/go.mod h1:WFv1+FwOgzmP6by3Dp6MAQpwyGl/JZxR2l1kf14rjFU=
github.com/beanstalkd/go-beanstalk v0.0.0-20200229072127-2b7b37f17578 h1:xdUBa6pQOvMgjhnVhp4gFTKGlpO/wLa5Qw5lBEGRqsU=
github.com/beanstalkd/go-beanstalk v0.0.0-20200229072127-2b7b37f17578/go.mod h1:Q3f6RCbUHp8RHSfBiPUZBojK76rir8Rl+KINuz2/sYs=
github.com/beanstalkd/go-beanstalk v0.1.0 h1:IiNwYbAoVBDs5xEOmleGoX+DRD3Moz99EpATbl8672w=
github.com/beanstalkd/go-beanstalk v0.1.0/go.mod h1:/G8YTyChOtpOArwLTQPY1CHB+i212+av35bkPXXj56Y=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@ -58,8 +56,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.7.2 h1:2QxQoC1TS09S7fhCPsrvqYdvP1H5M1P1ih5ABm3BTYk=
github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
@ -158,8 +154,6 @@ github.com/kshvakov/clickhouse v1.3.11 h1:dtzTJY0fCA+MWkLyuKZaNPkmSwdX4gh8+Klic9
github.com/kshvakov/clickhouse v1.3.11/go.mod h1:/SVBAcqF3u7rxQ9sTWCZwf8jzzvxiZGeQvtmSF2BBEc=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8=
github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
@ -183,8 +177,6 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/olivere/elastic v6.2.30+incompatible h1:9JdhoNFfUF809qM1S5WLz3CZaxazd/mDty9XXwDRz4Q=
github.com/olivere/elastic v6.2.30+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@ -219,8 +211,6 @@ github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLk
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/segmentio/encoding v0.1.12 h1:SwIDXReTDnlYqOcLachzJEczAEihST7Mx7nGlAWCJ3Q=
github.com/segmentio/encoding v0.1.12/go.mod h1:RWhr02uzMB9gQC1x+MfYxedtmBibb9cZ6Vv9VxRSSbw=
github.com/segmentio/kafka-go v0.3.5 h1:2JVT1inno7LxEASWj+HflHh5sWGfM0gkRiLAxkXhGG4=
github.com/segmentio/kafka-go v0.3.5/go.mod h1:OT5KXBPbaJJTcvokhWR2KFmm0niEx3mnccTwjmLvSi4=
github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=