Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove(crontab): remove distributednooverlapping/tracing middleware #456

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 6 additions & 30 deletions crontab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,20 @@ import (
"context"

"github.com/flc1125/go-cron/v4"
"github.com/go-kratos/kratos/v2"
"github.com/redis/go-redis/v9"

"github.com/go-kratos-ecosystem/components/v2/crontab"
"github.com/go-kratos-ecosystem/components/v2/crontab/middleware/distributednooverlapping"
"github.com/go-kratos-ecosystem/components/v2/crontab/middleware/distributednooverlapping/redismutex"
"github.com/go-kratos/kratos/v2"
)

type testJob struct {
distributednooverlapping.DefaultTTLJobWithMutex // optional, if you don't need to implement GetMutexTTL
}

var _ distributednooverlapping.JobWithMutex = (*testJob)(nil)

func (m *testJob) Run(context.Context) error {
// do something
return nil
}

func (m *testJob) GetMutexKey() string {
return "test"
}

func main() {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})

c := cron.New(
cron.WithSeconds(),
cron.WithMiddleware(
distributednooverlapping.New(
redismutex.New(rdb, redismutex.WithPrefix("cron:mutex")),
),
),
cron.WithMiddleware( /*...*/ ),
)

_, _ = c.AddJob("* * * * * *", &testJob{})
_, _ = c.AddFunc("* * * * * *", func(context.Context) error {
// do something
return nil
})

// kratos app start
app := kratos.New(
Expand Down
36 changes: 6 additions & 30 deletions crontab/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,20 @@ import (
"context"

"github.com/flc1125/go-cron/v4"
"github.com/go-kratos/kratos/v2"
"github.com/redis/go-redis/v9"

"github.com/go-kratos-ecosystem/components/v2/crontab"
"github.com/go-kratos-ecosystem/components/v2/crontab/middleware/distributednooverlapping"
"github.com/go-kratos-ecosystem/components/v2/crontab/middleware/distributednooverlapping/redismutex"
"github.com/go-kratos/kratos/v2"
)

type testJob struct {
distributednooverlapping.DefaultTTLJobWithMutex // optional, if you don't need to implement GetMutexTTL
}

var _ distributednooverlapping.JobWithMutex = (*testJob)(nil)

func (m *testJob) Run(context.Context) error {
// do something
return nil
}

func (m *testJob) GetMutexKey() string {
return "test"
}

func Example() {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})

c := cron.New(
cron.WithSeconds(),
cron.WithMiddleware(
distributednooverlapping.New(
redismutex.New(rdb, redismutex.WithPrefix("cron:mutex")),
),
),
cron.WithMiddleware( /*...*/ ),
)

_, _ = c.AddJob("* * * * * *", &testJob{})
_, _ = c.AddFunc("* * * * * *", func(context.Context) error {
// do something
return nil
})

// kratos app start
app := kratos.New(
Expand Down

This file was deleted.

48 changes: 0 additions & 48 deletions crontab/middleware/distributednooverlapping/redismutex/mutex.go

This file was deleted.

36 changes: 0 additions & 36 deletions crontab/middleware/distributednooverlapping/types.go

This file was deleted.

107 changes: 0 additions & 107 deletions crontab/middleware/tracing/tracing.go

This file was deleted.

Loading