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

docs(README.md): Add Middleware section with details on new middlewares. #51

Merged
merged 5 commits into from
Dec 6, 2024

Conversation

flc1125
Copy link
Owner

@flc1125 flc1125 commented Dec 6, 2024

Summary by CodeRabbit

  • New Features

    • Added a new section in the README detailing middleware options for the cron library.
    • Introduced documentation for the "Distributed No Overlapping Middleware" with usage examples.
    • Added documentation for the otel middleware to enhance observability.
  • Chores

    • Updated the .gitignore file to include _example and modify .todo.
    • Removed several example files related to cron job scheduling.

These updates enhance user understanding of middleware options and ensure cleaner version control management.

@flc1125 flc1125 added this to the v4.2.0 milestone Dec 6, 2024
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 6, 2024
Copy link

coderabbitai bot commented Dec 6, 2024

Warning

Rate limit exceeded

@flc1125 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 785af8c and 9775766.

Walkthrough

The changes in this pull request involve modifications to several files, primarily focusing on the .gitignore and README.md files. The .gitignore file now includes a new entry for _example and a modified entry for .todo. Additionally, a new section titled "Middleware" has been added to the README.md, detailing various middleware options for the cron library. Several Go files related to middleware and examples have been deleted, which included implementations for various middleware functionalities.

Changes

File Path Change Summary
.gitignore Added entry _example and modified entry for .todo to ensure it is ignored.
README.md New section "Middleware" added, describing middleware options: recovery, delayoverlapping, nooverlapping, distributednooverlapping, and otel.
_example/entry/context/main.go Deleted file containing a Go program for scheduling a recurring task with go-cron.
_example/entry/middleware/main.go Deleted file with a simple Go application utilizing middleware for task scheduling.
_example/middleware/delayoverlapping/main.go Deleted file with a Go application using delayoverlapping middleware for scheduling tasks.
_example/middleware/nooverlapping/main.go Deleted file with a Go application using nooverlapping middleware for task scheduling.
_example/middleware/recovery/main.go Deleted file containing a Go application demonstrating recovery middleware with scheduled tasks.
_example/readme/main.go Deleted file that managed scheduled jobs and demonstrated middleware usage.
middleware/distributednooverlapping/README.md New file added with documentation for "Distributed No Overlapping Middleware" and usage example.
middleware/otel/README.md New file added with documentation for the otel middleware and usage example.

Poem

In the land of code where rabbits play,
New middleware hops in, brightening the day.
With _example tucked safely away,
And tasks that won't overlap or sway.
Let's celebrate changes, both big and small,
In our coding burrow, we welcome them all! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot bot added the documentation Improvements or additions to documentation label Dec 6, 2024
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.53%. Comparing base (e6e8f95) to head (9775766).
Report is 1 commits behind head on 4.x.

Additional details and impacted files
@@           Coverage Diff           @@
##              4.x      #51   +/-   ##
=======================================
  Coverage   95.53%   95.53%           
=======================================
  Files          17       17           
  Lines         874      874           
=======================================
  Hits          835      835           
  Misses         33       33           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (1)
middleware/distributednooverlapping/README.md (1)

35-37: Document mutex TTL considerations

The comment about TTL should be expanded to explain the implications.

Add a note explaining:

// The mutex TTL should be set carefully:
// 1. Too short: Job might be executed multiple times if it runs longer than TTL
// 2. Too long: If the process crashes, the lock might prevent other instances from running the job
// 
// Recommended: Set TTL to (expected_job_duration * 2) + buffer_time
🧰 Tools
🪛 Markdownlint (0.35.0)

36-36: Column: 1
Hard tabs

(MD010, no-hard-tabs)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e6e8f95 and 1c64ccb.

📒 Files selected for processing (9)
  • .gitignore (1 hunks)
  • README.md (1 hunks)
  • _example/entry/context/main.go (0 hunks)
  • _example/entry/middleware/main.go (0 hunks)
  • _example/middleware/delayoverlapping/main.go (0 hunks)
  • _example/middleware/nooverlapping/main.go (0 hunks)
  • _example/middleware/recovery/main.go (0 hunks)
  • _example/readme/main.go (0 hunks)
  • middleware/distributednooverlapping/README.md (1 hunks)
💤 Files with no reviewable changes (6)
  • _example/readme/main.go
  • _example/middleware/delayoverlapping/main.go
  • _example/entry/middleware/main.go
  • _example/entry/context/main.go
  • _example/middleware/nooverlapping/main.go
  • _example/middleware/recovery/main.go
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🧰 Additional context used
🪛 Markdownlint (0.35.0)
middleware/distributednooverlapping/README.md

11-11: Column: 1
Hard tabs

(MD010, no-hard-tabs)


12-12: Column: 1
Hard tabs

(MD010, no-hard-tabs)


13-13: Column: 1
Hard tabs

(MD010, no-hard-tabs)


14-14: Column: 1
Hard tabs

(MD010, no-hard-tabs)


16-16: Column: 1
Hard tabs

(MD010, no-hard-tabs)


17-17: Column: 1
Hard tabs

(MD010, no-hard-tabs)


18-18: Column: 1
Hard tabs

(MD010, no-hard-tabs)


19-19: Column: 1
Hard tabs

(MD010, no-hard-tabs)


23-23: Column: 1
Hard tabs

(MD010, no-hard-tabs)


27-27: Column: 1
Hard tabs

(MD010, no-hard-tabs)


28-28: Column: 1
Hard tabs

(MD010, no-hard-tabs)


32-32: Column: 1
Hard tabs

(MD010, no-hard-tabs)


36-36: Column: 1
Hard tabs

(MD010, no-hard-tabs)


40-40: Column: 1
Hard tabs

(MD010, no-hard-tabs)


41-41: Column: 1
Hard tabs

(MD010, no-hard-tabs)


42-42: Column: 1
Hard tabs

(MD010, no-hard-tabs)


46-46: Column: 1
Hard tabs

(MD010, no-hard-tabs)


47-47: Column: 1
Hard tabs

(MD010, no-hard-tabs)


48-48: Column: 1
Hard tabs

(MD010, no-hard-tabs)


50-50: Column: 1
Hard tabs

(MD010, no-hard-tabs)


52-52: Column: 1
Hard tabs

(MD010, no-hard-tabs)


53-53: Column: 1
Hard tabs

(MD010, no-hard-tabs)


54-54: Column: 1
Hard tabs

(MD010, no-hard-tabs)


55-55: Column: 1
Hard tabs

(MD010, no-hard-tabs)


56-56: Column: 1
Hard tabs

(MD010, no-hard-tabs)


58-58: Column: 1
Hard tabs

(MD010, no-hard-tabs)


59-59: Column: 1
Hard tabs

(MD010, no-hard-tabs)


61-61: Column: 1
Hard tabs

(MD010, no-hard-tabs)


62-62: Column: 1
Hard tabs

(MD010, no-hard-tabs)


64-64: Column: 1
Hard tabs

(MD010, no-hard-tabs)

Comment on lines +58 to +59
_, _ = c.AddJob("* * * * * *", &basicJob{"one"})
_, _ = c.AddJob("* * * * * *", &basicJob{"two"})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling for job registration

The example ignores potential errors when adding jobs.

-_, _ = c.AddJob("* * * * * *", &basicJob{"one"})
-_, _ = c.AddJob("* * * * * *", &basicJob{"two"})
+if _, err := c.AddJob("* * * * * *", &basicJob{"one"}); err != nil {
+    log.Fatal("Failed to add job one:", err)
+}
+if _, err := c.AddJob("* * * * * *", &basicJob{"two"}); err != nil {
+    log.Fatal("Failed to add job two:", err)
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_, _ = c.AddJob("* * * * * *", &basicJob{"one"})
_, _ = c.AddJob("* * * * * *", &basicJob{"two"})
if _, err := c.AddJob("* * * * * *", &basicJob{"one"}); err != nil {
log.Fatal("Failed to add job one:", err)
}
if _, err := c.AddJob("* * * * * *", &basicJob{"two"}); err != nil {
log.Fatal("Failed to add job two:", err)
}
🧰 Tools
🪛 Markdownlint (0.35.0)

58-58: Column: 1
Hard tabs

(MD010, no-hard-tabs)


59-59: Column: 1
Hard tabs

(MD010, no-hard-tabs)

Comment on lines +46 to +48
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling for Redis connection

The example should demonstrate proper error handling for production use.

 rdb := redis.NewClient(&redis.Options{
     Addr: "localhost:6379",
 })
+
+if err := rdb.Ping(context.Background()).Err(); err != nil {
+    log.Fatal("Failed to connect to Redis:", err)
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})
if err := rdb.Ping(context.Background()).Err(); err != nil {
log.Fatal("Failed to connect to Redis:", err)
}
🧰 Tools
🪛 Markdownlint (0.35.0)

46-46: Column: 1
Hard tabs

(MD010, no-hard-tabs)


47-47: Column: 1
Hard tabs

(MD010, no-hard-tabs)


48-48: Column: 1
Hard tabs

(MD010, no-hard-tabs)

…Overlapping Middleware
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (8)
middleware/otel/README.md (5)

1-3: Fix grammatical error in the introduction

There's a grammatical error in the middleware description.

-The `otel` is a middleware for that provides observability with OpenTelemetry.
+The `otel` middleware provides observability with OpenTelemetry.

33-36: Add meaningful implementation in Run method

The current Run method contains a placeholder comment without actual implementation. Consider adding a realistic example that demonstrates how tracing works with a real task.

 func (b *basicJob) Run(ctx context.Context) error {
-    // do something
+    // Simulate some work that can be traced
+    time.Sleep(100 * time.Millisecond)
+    fmt.Println("Job executed:", time.Now())
     return nil
 }
🧰 Tools
🪛 Markdownlint (0.35.0)

34-34: Column: 1
Hard tabs

(MD010, no-hard-tabs)


35-35: Column: 1
Hard tabs

(MD010, no-hard-tabs)


39-41: Add explanatory comments for OpenTelemetry setup

The OpenTelemetry configuration could benefit from more detailed comments explaining the purpose of each component.

-    // configure otel, the following is just a demonstration provider.
+    // Configure OpenTelemetry with an in-memory exporter for demonstration
+    // In production, you would typically use an exporter that sends data
+    // to your observability backend (e.g., Jaeger, Zipkin)
     imsb := tracetest.NewInMemoryExporter()
     tp := trace.NewTracerProvider(trace.WithSyncer(imsb))
🧰 Tools
🪛 Markdownlint (0.35.0)

39-39: Column: 1
Hard tabs

(MD010, no-hard-tabs)


40-40: Column: 1
Hard tabs

(MD010, no-hard-tabs)


41-41: Column: 1
Hard tabs

(MD010, no-hard-tabs)


54-55: Add explanation for the sleep duration

The purpose of the sleep duration should be explained to help readers understand the example better.

+    // Wait for 10 seconds to collect some spans for demonstration
     time.Sleep(10 * time.Second)
     fmt.Println("spans:", len(imsb.GetSpans()))
🧰 Tools
🪛 Markdownlint (0.35.0)

54-54: Column: 1
Hard tabs

(MD010, no-hard-tabs)


55-55: Column: 1
Hard tabs

(MD010, no-hard-tabs)


59-63: Add context to the output section

The output section would be more helpful with an explanation of what the spans represent and how they relate to the job execution.

 output:
 
 ```shell
+# Shows the number of spans collected over 10 seconds
+# (1 span per second due to the "* * * * * *" schedule)
 spans: 10

</blockquote></details>
<details>
<summary>middleware/distributednooverlapping/README.md (3)</summary><blockquote>

`16-20`: **Document version requirements**

Please add version requirements for the dependencies:
- Minimum required version of `go-cron`
- Compatible Redis versions
- Go version requirements

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Markdownlint (0.35.0)</summary>

16-16: Column: 1
Hard tabs

(MD010, no-hard-tabs)

---

17-17: Column: 1
Hard tabs

(MD010, no-hard-tabs)

---

18-18: Column: 1
Hard tabs

(MD010, no-hard-tabs)

---

19-19: Column: 1
Hard tabs

(MD010, no-hard-tabs)

</details>

</details>

---

`35-37`: **Review mutex TTL duration**

The current TTL of 60 hours seems excessive for a job that runs every second and takes 1 second to complete.

Consider reducing the TTL to a more reasonable duration:

```diff
-func (j *basicJob) GetMutexTTL() time.Duration {
-	return time.Hour * 60 // the ttl suggests greater than the running time of the job
-}
+func (j *basicJob) GetMutexTTL() time.Duration {
+	return time.Second * 5 // 5x the expected running time for safety
+}
🧰 Tools
🪛 Markdownlint (0.35.0)

36-36: Column: 1
Hard tabs

(MD010, no-hard-tabs)


68-76: Add explanation for the example output

The output section would be more helpful with explanations of:

  • Why certain jobs run at specific times
  • How the distributed locking prevents overlap
  • What the timing patterns indicate

Add explanatory text before the output:

The output below demonstrates:
- Jobs running sequentially without overlap
- Distributed locking ensuring only one instance runs at a time
- Alternating execution between job instances
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1c64ccb and 785af8c.

📒 Files selected for processing (2)
  • middleware/distributednooverlapping/README.md (1 hunks)
  • middleware/otel/README.md (1 hunks)
🧰 Additional context used
🪛 Markdownlint (0.35.0)
middleware/distributednooverlapping/README.md

11-11: Column: 1
Hard tabs

(MD010, no-hard-tabs)


12-12: Column: 1
Hard tabs

(MD010, no-hard-tabs)


13-13: Column: 1
Hard tabs

(MD010, no-hard-tabs)


14-14: Column: 1
Hard tabs

(MD010, no-hard-tabs)


16-16: Column: 1
Hard tabs

(MD010, no-hard-tabs)


17-17: Column: 1
Hard tabs

(MD010, no-hard-tabs)


18-18: Column: 1
Hard tabs

(MD010, no-hard-tabs)


19-19: Column: 1
Hard tabs

(MD010, no-hard-tabs)


23-23: Column: 1
Hard tabs

(MD010, no-hard-tabs)


27-27: Column: 1
Hard tabs

(MD010, no-hard-tabs)


28-28: Column: 1
Hard tabs

(MD010, no-hard-tabs)


32-32: Column: 1
Hard tabs

(MD010, no-hard-tabs)


36-36: Column: 1
Hard tabs

(MD010, no-hard-tabs)


40-40: Column: 1
Hard tabs

(MD010, no-hard-tabs)


41-41: Column: 1
Hard tabs

(MD010, no-hard-tabs)


42-42: Column: 1
Hard tabs

(MD010, no-hard-tabs)


46-46: Column: 1
Hard tabs

(MD010, no-hard-tabs)


47-47: Column: 1
Hard tabs

(MD010, no-hard-tabs)


48-48: Column: 1
Hard tabs

(MD010, no-hard-tabs)


50-50: Column: 1
Hard tabs

(MD010, no-hard-tabs)


52-52: Column: 1
Hard tabs

(MD010, no-hard-tabs)


53-53: Column: 1
Hard tabs

(MD010, no-hard-tabs)


54-54: Column: 1
Hard tabs

(MD010, no-hard-tabs)


55-55: Column: 1
Hard tabs

(MD010, no-hard-tabs)


56-56: Column: 1
Hard tabs

(MD010, no-hard-tabs)


58-58: Column: 1
Hard tabs

(MD010, no-hard-tabs)


59-59: Column: 1
Hard tabs

(MD010, no-hard-tabs)


61-61: Column: 1
Hard tabs

(MD010, no-hard-tabs)


62-62: Column: 1
Hard tabs

(MD010, no-hard-tabs)


64-64: Column: 1
Hard tabs

(MD010, no-hard-tabs)

middleware/otel/README.md

11-11: Column: 1
Hard tabs

(MD010, no-hard-tabs)


12-12: Column: 1
Hard tabs

(MD010, no-hard-tabs)


13-13: Column: 1
Hard tabs

(MD010, no-hard-tabs)


15-15: Column: 1
Hard tabs

(MD010, no-hard-tabs)


16-16: Column: 1
Hard tabs

(MD010, no-hard-tabs)


17-17: Column: 1
Hard tabs

(MD010, no-hard-tabs)


18-18: Column: 1
Hard tabs

(MD010, no-hard-tabs)


25-25: Column: 1
Hard tabs

(MD010, no-hard-tabs)


26-26: Column: 1
Hard tabs

(MD010, no-hard-tabs)


30-30: Column: 1
Hard tabs

(MD010, no-hard-tabs)


34-34: Column: 1
Hard tabs

(MD010, no-hard-tabs)


35-35: Column: 1
Hard tabs

(MD010, no-hard-tabs)


39-39: Column: 1
Hard tabs

(MD010, no-hard-tabs)


40-40: Column: 1
Hard tabs

(MD010, no-hard-tabs)


41-41: Column: 1
Hard tabs

(MD010, no-hard-tabs)


43-43: Column: 1
Hard tabs

(MD010, no-hard-tabs)


44-44: Column: 1
Hard tabs

(MD010, no-hard-tabs)


45-45: Column: 1
Hard tabs

(MD010, no-hard-tabs)


46-46: Column: 1
Hard tabs

(MD010, no-hard-tabs)


47-47: Column: 1
Hard tabs

(MD010, no-hard-tabs)


49-49: Column: 1
Hard tabs

(MD010, no-hard-tabs)


51-51: Column: 1
Hard tabs

(MD010, no-hard-tabs)


52-52: Column: 1
Hard tabs

(MD010, no-hard-tabs)


54-54: Column: 1
Hard tabs

(MD010, no-hard-tabs)


55-55: Column: 1
Hard tabs

(MD010, no-hard-tabs)

🔇 Additional comments (3)
middleware/distributednooverlapping/README.md (3)

1-4: Enhance the introduction section with more details

The introduction should be expanded to include key features, requirements, and implementation details as previously suggested.


46-48: Add error handling for Redis connection

The Redis connection setup should include proper error handling.

🧰 Tools
🪛 Markdownlint (0.35.0)

46-46: Column: 1
Hard tabs

(MD010, no-hard-tabs)


47-47: Column: 1
Hard tabs

(MD010, no-hard-tabs)


48-48: Column: 1
Hard tabs

(MD010, no-hard-tabs)


58-59: Add error handling for job registration

The example ignores potential errors when adding jobs.

🧰 Tools
🪛 Markdownlint (0.35.0)

58-58: Column: 1
Hard tabs

(MD010, no-hard-tabs)


59-59: Column: 1
Hard tabs

(MD010, no-hard-tabs)

otel.WithTracerProvider(tp), // custom otel.TracerProvider
))

_, _ = c.AddJob("* * * * * *", &basicJob{})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Handle errors from AddJob

The error returned from AddJob should be properly handled instead of being silently ignored.

-    _, _ = c.AddJob("* * * * * *", &basicJob{})
+    if _, err := c.AddJob("* * * * * *", &basicJob{}); err != nil {
+        log.Fatal("Failed to add job:", err)
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_, _ = c.AddJob("* * * * * *", &basicJob{})
if _, err := c.AddJob("* * * * * *", &basicJob{}); err != nil {
log.Fatal("Failed to add job:", err)
}
🧰 Tools
🪛 Markdownlint (0.35.0)

49-49: Column: 1
Hard tabs

(MD010, no-hard-tabs)

Comment on lines +31 to +33
func (j *basicJob) GetMutexKey() string {
return "basic:job"
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Make mutex key unique per job instance

The current implementation uses a static mutex key "basic:job" for all jobs. This could cause unnecessary blocking between different job instances.

Consider using the job's slug in the mutex key:

-func (j *basicJob) GetMutexKey() string {
-	return "basic:job"
-}
+func (j *basicJob) GetMutexKey() string {
+	return fmt.Sprintf("basic:job:%s", j.slug)
+}

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Markdownlint (0.35.0)

32-32: Column: 1
Hard tabs

(MD010, no-hard-tabs)

@flc1125 flc1125 merged commit c84b07c into 4.x Dec 6, 2024
8 checks passed
@flc1125 flc1125 deleted the docs branch December 19, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant