Skip to content

Commit

Permalink
feat: upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
miaolz123 committed Jul 28, 2020
1 parent 79c40ab commit ba43f79
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 145 deletions.
2 changes: 1 addition & 1 deletion cache/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type person struct {

func main() {
c, err := cache.NewRedisCacher(&cache.RedisConfig{
URL: "172.18.130.38:16379",
URL: "192.168.31.61:6379",
Password: "KgqvdOdYV5",
Retries: 10,
})
Expand Down
2 changes: 1 addition & 1 deletion errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func GetErrorCode(err error) int32 {
func addError(err *Error) *Error {
e, ok := allErrors[err.Code]
if ok {
log.Fatalw("duplate error code", "exists_err", e, "new_err", err)
log.L.WithFields(log.F{"exists_err": e, "new_err": err}).Fatal("duplate error code")
}

allErrors[err.Code] = err
Expand Down
25 changes: 25 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
_ "github.com/gxxgle/go-utils/cache"
_ "github.com/gxxgle/go-utils/config"
_ "github.com/gxxgle/go-utils/db"
_ "github.com/gxxgle/go-utils/env"
_ "github.com/gxxgle/go-utils/errors"
_ "github.com/gxxgle/go-utils/ip"
_ "github.com/gxxgle/go-utils/iriser"
_ "github.com/gxxgle/go-utils/json"
_ "github.com/gxxgle/go-utils/log"
_ "github.com/gxxgle/go-utils/math"
_ "github.com/gxxgle/go-utils/mongo"
_ "github.com/gxxgle/go-utils/mq"
_ "github.com/gxxgle/go-utils/path"
_ "github.com/gxxgle/go-utils/pool"
_ "github.com/gxxgle/go-utils/proxy"
_ "github.com/gxxgle/go-utils/schedule"
_ "github.com/gxxgle/go-utils/sync"
)

func main() {
println("ok")
}
26 changes: 14 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ require (
github.com/doug-martin/goqu/v9 v9.9.0
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
github.com/go-redis/redis/v7 v7.2.0
github.com/go-redis/redis/v7 v7.4.0
github.com/go-sql-driver/mysql v1.5.0
github.com/golang/protobuf v1.3.3 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/imroc/req v0.3.0
github.com/json-iterator/go v1.1.9
github.com/json-iterator/go v1.1.10
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/kataras/iris/v12 v12.1.8
github.com/klauspost/compress v1.10.10 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/lib/pq v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/lib/pq v1.8.0 // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/moul/http2curl v1.0.0 // indirect
Expand All @@ -30,19 +31,20 @@ require (
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shopspring/decimal v1.2.0
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/sirupsen/logrus v1.5.0
github.com/sirupsen/logrus v1.6.0
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/streadway/amqp v0.0.0-20200108173154-1c71cc93ed71
github.com/streadway/amqp v1.0.0
github.com/stretchr/objx v0.3.0 // indirect
github.com/tidwall/gjson v1.6.0
github.com/valyala/fasthttp v1.12.0 // indirect
github.com/valyala/fasthttp v1.15.1 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
golang.org/x/crypto v0.0.0-20200427165652-729f1e841bcc // indirect
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0
gopkg.in/yaml.v2 v2.2.8 // indirect
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381
gopkg.in/yaml.v2 v2.3.0 // indirect
xorm.io/builder v0.3.7
xorm.io/xorm v1.0.1
xorm.io/xorm v1.0.3
)
183 changes: 64 additions & 119 deletions go.sum

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions mq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *rabbitmq) run() {
select {
case err := <-c.Errors():
if err != nil {
log.Errorw("go-utils mq rabbitmq client error", "err", err)
log.L.WithError(err).Error("go-utils mq rabbitmq client run")
}

case <-c.exit:
Expand All @@ -92,8 +92,11 @@ func newRabbitmqPublisher(cli *rabbitmq, exchange string) *rabbitmqPublisher {
func (p *rabbitmqPublisher) send(msg *Message) {
err := p.puber.PublishWithRoutingKey(amqp.Publishing{Body: msg.Body}, msg.Key)
if err != nil {
log.Errorw("go-utils mq rabbitmq publisher send message error", "exchange",
p.exchange, "key", msg.Key, "body", string(msg.Body))
log.L.WithError(err).WithFields(log.F{
"exchange": p.exchange,
"key": msg.Key,
"body": string(msg.Body),
}).Error("go-utils mq rabbitmq publisher send message")
}
}

Expand All @@ -112,7 +115,7 @@ func (p *rabbitmqPublisher) run() {

close(p.msgs)
p.cli.wg.Done()
log.Infow("go-utils mq rabbitmq publisher stopped", "exchange", p.exchange)
log.L.WithField("exchange", p.exchange).Info("go-utils mq rabbitmq publisher stopped")
}()
}

Expand Down Expand Up @@ -144,22 +147,24 @@ func (s *rabbitmqSubscriber) Subscribe(handler func([]byte) error) {
select {
case msg := <-s.coner.Deliveries():
if err := handler(msg.Body); err != nil {
log.Errorw("go-utils mq rabbitmq subscriber handler message error",
"queue", s.queue, "body", string(msg.Body), "err", err)
log.L.WithError(err).WithFields(log.F{
"queue": s.queue,
"body": string(msg.Body),
}).Error("go-utils mq rabbitmq subscriber handler message")
continue
}
msg.Ack(false)

case err := <-s.coner.Errors():
if err != nil {
log.Errorw("go-utils mq rabbitmq subscriber error", "queue", s.queue, "err", err)
log.L.WithError(err).WithField("queue", s.queue).Error("go-utils mq rabbitmq subscriber")
}

case <-s.cli.exit:
}
}

s.cli.wg.Done()
log.Infow("go-utils mq rabbitmq subscriber stopped", "queue", s.queue)
log.L.WithField("queue", s.queue).Info("go-utils mq rabbitmq subscriber stopped")
}()
}
7 changes: 5 additions & 2 deletions pool/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ func (tp *TaskPool) Stop() {

start := time.Now()
defer func() {
log.Infow("go-utils stop taskpool", "taskpool_name", tp.name, "cost", time.Since(start))
log.L.WithFields(log.F{
"taskpool_name": tp.name,
"cost": time.Since(start),
}).Info("go-utils stop taskpool")
}()

tp.stopped = true
Expand All @@ -64,7 +67,7 @@ func (tp *TaskPool) loopRun() {
func (tp *TaskPool) run() {
defer func() {
if err := recover(); err != nil {
log.Errorw("go-utils task crash", "err", err)
log.L.WithField("error", err).Error("go-utils task crash")
}
}()

Expand Down
4 changes: 2 additions & 2 deletions sync/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func (m *redisMutex) Lock() {
return
}

log.Errorw("go-utils redislock lock error", "key", m.key, "err", err)
log.L.WithError(err).WithField("key", m.key).Error("go-utils redislock lock error")
}
}

func (m *redisMutex) Unlock() {
if err := m.lock.Release(); err != nil {
log.Errorw("go-utils redislock unlock error", "key", m.key, "err", err)
log.L.WithError(err).WithField("key", m.key).Error("go-utils redislock unlock error")
}
}

0 comments on commit ba43f79

Please sign in to comment.