Skip to content

Commit b0e3dac

Browse files
dxyinmecoticomAH-darkwithrjplibi
authored
Develop to Master (#98)
* opt: use runtime/debug.Stack() to print stack trace of panic (#93) * 提升测试覆盖率,增加go1.22的test action. (#94) * chore: use `redis.UniversalClient` instead of `*redis.Client` (#88) * make dcron running locally, update cron test, add GetJobs / GetJob function for dcron. (#89) * 增加code coverage, 修复GetJob bug,增加devcontainer方便开发者 (#91) * add example app to readme * add NodeID function into dcron * Deps: updated github.com/go-redis/redis/v8 to github.com/redis/go-redis/v9 (#73) * add cron lib * fix warning * logger removal : phares1 * add robfig/cron to dcron (#75) * add NodeID function into dcron * add cron lib * fix warning * logger removal : phares * revert 1.22 * update etcd driver * update * fix get nodes * update * update for fix TAT * Revert "update etcd driver" This reverts commit a21ebf7. * Revert "deps: updated go-redis to v9 (#79)" This reverts commit 0b85b24. * update * update * refact etcd * Revert "refact etcd" This reverts commit 049bed1. * Revert "update" This reverts commit 9c71fd6. * update * refactor etcddriver * fix error * update * Revert "update" This reverts commit 6cfcfe6. * Revert "fix error" This reverts commit 99b2d82. * Revert "refactor etcddriver" This reverts commit a576ac3. * update * update * remove comments, and fix * add comments * Add comments, add split the E2E test cases and other test cases. (#80) * add example app to readme * add NodeID function into dcron * add cron lib * fix warning * logger removal : phares1 * update test workflow * revert 1.22 * update etcd driver * update * fix get nodes * update * update for fix TAT * Revert "update etcd driver" This reverts commit a21ebf7. * Revert "deps: updated go-redis to v9 (#79)" This reverts commit 0b85b24. * update * update * refact etcd * Revert "refact etcd" This reverts commit 049bed1. * Revert "update" This reverts commit 9c71fd6. * update * refactor etcddriver * fix error * update * Revert "update" This reverts commit 6cfcfe6. * Revert "fix error" This reverts commit 99b2d82. * Revert "refactor etcddriver" This reverts commit a576ac3. * update * update * remove comments, and fix * add comments * merge e2e test and normal test * move e2etest to origin path * add timeout to avoid pipeline timeout * add getjobs related function * update * remove redis config in test workflow * update * update chain test in windows * update action version for node 16 -> node 20 * add test for dcron locally * update readme * update * fix code bug * Update devcontainer and etcd driver test --------- Co-authored-by: Ava Ackerman <[email protected]> Co-authored-by: libi <[email protected]> * update test coverage * make driver withOption -> WithOption * update go.mod * update go.mod * update protobuf version * etcd to 3.5.12 * fix etcd * fix etcd * Revert "fix etcd" This reverts commit a21bf33. * update miniredis * update * update go.mod * update go mod * update go mod --------- Co-authored-by: AHdark <[email protected]> Co-authored-by: Ava Ackerman <[email protected]> Co-authored-by: libi <[email protected]> * remove 1.22 test action to increase the test coverage. (#97) --------- Co-authored-by: coti <[email protected]> Co-authored-by: AHdark <[email protected]> Co-authored-by: Ava Ackerman <[email protected]> Co-authored-by: libi <[email protected]>
1 parent 9c0c1ea commit b0e3dac

13 files changed

+306
-162
lines changed

Diff for: .github/workflows/test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ jobs:
3434
uses: codecov/codecov-action@v4
3535
env:
3636
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
37-

Diff for: cron/chain.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package cron
22

33
import (
4-
"fmt"
5-
"runtime"
4+
"runtime/debug"
65
"sync"
76
"time"
87

@@ -45,14 +44,7 @@ func Recover(logger dlog.Logger) JobWrapper {
4544
return FuncJob(func() {
4645
defer func() {
4746
if r := recover(); r != nil {
48-
const size = 64 << 10
49-
buf := make([]byte, size)
50-
buf = buf[:runtime.Stack(buf, false)]
51-
err, ok := r.(error)
52-
if !ok {
53-
err = fmt.Errorf("%v", r)
54-
}
55-
logger.Errorf("panic: stack %v\n%v\n", err, string(buf))
47+
logger.Errorf("panic: stack %v\n%s\n", r, debug.Stack())
5648
}
5749
}()
5850
j.Run()

Diff for: dcron_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ func runSecondNode(id string, wg *sync.WaitGroup, runningTime time.Duration, t *
171171
dcron.CronOptionChain(cron.Recover(
172172
cron.DefaultLogger,
173173
)),
174+
dcron.WithHashReplicas(20),
175+
dcron.CronOptionLocation(time.Local),
174176
)
175177
var err error
176178
err = dcr.AddFunc("job1", "*/5 * * * * *", func() {

Diff for: driver/driver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type DriverV2 interface {
2727
// stop the goroutine of keep connection.
2828
Stop(ctx context.Context) (err error)
2929

30-
withOption(opt Option) (err error)
30+
WithOption(opt Option) (err error)
3131
}
3232

3333
func NewRedisDriver(redisClient redis.UniversalClient) DriverV2 {

Diff for: driver/etcddriver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (e *EtcdDriver) Init(serverName string, opts ...Option) {
174174
e.serviceName = serverName
175175
e.nodeID = GetNodeId(serverName)
176176
for _, opt := range opts {
177-
e.withOption(opt)
177+
e.WithOption(opt)
178178
}
179179
}
180180

@@ -204,7 +204,7 @@ func (e *EtcdDriver) Stop(ctx context.Context) (err error) {
204204
return
205205
}
206206

207-
func (e *EtcdDriver) withOption(opt Option) (err error) {
207+
func (e *EtcdDriver) WithOption(opt Option) (err error) {
208208
switch opt.Type() {
209209
case OptionTypeTimeout:
210210
{

Diff for: driver/redisdriver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (rd *RedisDriver) Init(serviceName string, opts ...Option) {
4949
rd.nodeID = GetNodeId(rd.serviceName)
5050

5151
for _, opt := range opts {
52-
rd.withOption(opt)
52+
rd.WithOption(opt)
5353
}
5454
}
5555

@@ -130,7 +130,7 @@ func (rd *RedisDriver) scan(ctx context.Context, matchStr string) ([]string, err
130130
return ret, nil
131131
}
132132

133-
func (rd *RedisDriver) withOption(opt Option) (err error) {
133+
func (rd *RedisDriver) WithOption(opt Option) (err error) {
134134
switch opt.Type() {
135135
case OptionTypeTimeout:
136136
{

Diff for: driver/rediszsetdriver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (rd *RedisZSetDriver) Init(serviceName string, opts ...Option) {
4444
rd.serviceName = serviceName
4545
rd.nodeID = GetNodeId(serviceName)
4646
for _, opt := range opts {
47-
rd.withOption(opt)
47+
rd.WithOption(opt)
4848
}
4949
}
5050

@@ -95,7 +95,7 @@ func (rd *RedisZSetDriver) Stop(ctx context.Context) (err error) {
9595
return
9696
}
9797

98-
func (rd *RedisZSetDriver) withOption(opt Option) (err error) {
98+
func (rd *RedisZSetDriver) WithOption(opt Option) (err error) {
9999
switch opt.Type() {
100100
case OptionTypeTimeout:
101101
{

Diff for: go.mod

+43-41
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,82 @@ module github.com/libi/dcron
33
go 1.19
44

55
require (
6-
github.com/alicebob/miniredis/v2 v2.31.0
6+
github.com/alicebob/miniredis/v2 v2.32.1
77
github.com/google/uuid v1.5.0
88
github.com/redis/go-redis/v9 v9.3.1
9-
github.com/stretchr/testify v1.8.4
9+
github.com/stretchr/testify v1.9.0
1010
go.etcd.io/etcd/api/v3 v3.5.11
1111
go.etcd.io/etcd/client/v3 v3.5.11
1212
go.etcd.io/etcd/tests/v3 v3.5.11
1313
)
1414

1515
require (
16-
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect
16+
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
1717
github.com/beorn7/perks v1.0.1 // indirect
1818
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
1919
github.com/cespare/xxhash/v2 v2.2.0 // indirect
20-
github.com/coreos/go-semver v0.3.1 // indirect
21-
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
20+
github.com/coreos/go-semver v0.3.0 // indirect
21+
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
2222
github.com/davecgh/go-spew v1.1.1 // indirect
2323
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
24-
github.com/dustin/go-humanize v1.0.1 // indirect
24+
github.com/dustin/go-humanize v1.0.0 // indirect
2525
github.com/go-logr/logr v1.3.0 // indirect
2626
github.com/go-logr/stdr v1.2.2 // indirect
2727
github.com/gogo/protobuf v1.3.2 // indirect
28-
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
28+
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
2929
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3030
github.com/golang/protobuf v1.5.3 // indirect
31-
github.com/google/btree v1.1.2 // indirect
32-
github.com/gorilla/websocket v1.5.1 // indirect
33-
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
31+
github.com/google/btree v1.0.1 // indirect
32+
github.com/gorilla/websocket v1.4.2 // indirect
33+
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
3434
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
3535
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
36-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
37-
github.com/jonboulle/clockwork v0.4.0 // indirect
38-
github.com/json-iterator/go v1.1.12 // indirect
39-
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
36+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
37+
github.com/jonboulle/clockwork v0.2.2 // indirect
38+
github.com/json-iterator/go v1.1.11 // indirect
39+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
4040
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
41-
github.com/modern-go/reflect2 v1.0.2 // indirect
41+
github.com/modern-go/reflect2 v1.0.1 // indirect
4242
github.com/pmezard/go-difflib v1.0.0 // indirect
43-
github.com/prometheus/client_golang v1.17.0 // indirect
44-
github.com/prometheus/client_model v0.5.0 // indirect
45-
github.com/prometheus/common v0.45.0 // indirect
46-
github.com/prometheus/procfs v0.12.0 // indirect
47-
github.com/sirupsen/logrus v1.9.3 // indirect
43+
github.com/prometheus/client_golang v1.11.1 // indirect
44+
github.com/prometheus/client_model v0.2.0 // indirect
45+
github.com/prometheus/common v0.26.0 // indirect
46+
github.com/prometheus/procfs v0.6.0 // indirect
47+
github.com/sirupsen/logrus v1.7.0 // indirect
4848
github.com/soheilhy/cmux v0.1.5 // indirect
4949
github.com/spf13/pflag v1.0.5 // indirect
50-
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 // indirect
51-
github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510 // indirect
50+
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
51+
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
5252
github.com/yuin/gopher-lua v1.1.1 // indirect
5353
go.etcd.io/bbolt v1.3.8 // indirect
5454
go.etcd.io/etcd/client/pkg/v3 v3.5.11 // indirect
5555
go.etcd.io/etcd/client/v2 v2.305.11 // indirect
5656
go.etcd.io/etcd/pkg/v3 v3.5.11 // indirect
5757
go.etcd.io/etcd/raft/v3 v3.5.11 // indirect
5858
go.etcd.io/etcd/server/v3 v3.5.11 // indirect
59-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
60-
go.opentelemetry.io/otel v1.21.0 // indirect
61-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
62-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect
63-
go.opentelemetry.io/otel/metric v1.21.0 // indirect
64-
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
65-
go.opentelemetry.io/otel/trace v1.21.0 // indirect
59+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.0 // indirect
60+
go.opentelemetry.io/otel v1.20.0 // indirect
61+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.20.0 // indirect
62+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.20.0 // indirect
63+
go.opentelemetry.io/otel/metric v1.20.0 // indirect
64+
go.opentelemetry.io/otel/sdk v1.20.0 // indirect
65+
go.opentelemetry.io/otel/trace v1.20.0 // indirect
6666
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
67-
go.uber.org/multierr v1.11.0 // indirect
68-
go.uber.org/zap v1.26.0 // indirect
69-
golang.org/x/crypto v0.17.0 // indirect
70-
golang.org/x/net v0.19.0 // indirect
71-
golang.org/x/sys v0.15.0 // indirect
72-
golang.org/x/text v0.14.0 // indirect
73-
golang.org/x/time v0.5.0 // indirect
74-
google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4 // indirect
75-
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
76-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
67+
go.uber.org/atomic v1.7.0 // indirect
68+
go.uber.org/multierr v1.6.0 // indirect
69+
go.uber.org/zap v1.17.0 // indirect
70+
golang.org/x/crypto v0.14.0 // indirect
71+
golang.org/x/net v0.17.0 // indirect
72+
golang.org/x/sys v0.14.0 // indirect
73+
golang.org/x/text v0.13.0 // indirect
74+
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
75+
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
76+
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
77+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
7778
google.golang.org/grpc v1.59.0 // indirect
7879
google.golang.org/protobuf v1.31.0 // indirect
79-
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
80+
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
81+
gopkg.in/yaml.v2 v2.4.0 // indirect
8082
gopkg.in/yaml.v3 v3.0.1 // indirect
81-
sigs.k8s.io/yaml v1.4.0 // indirect
83+
sigs.k8s.io/yaml v1.2.0 // indirect
8284
)

0 commit comments

Comments
 (0)