Add comprehensive examples demonstrating workqueue use cases #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds two comprehensive, runnable examples to the repository demonstrating practical use cases of the workqueue package.
Examples Added
1. URL Crawl Frontier (
examples/url-crawler/)Demonstrates how to use workqueue as a crawl frontier for a web crawler with:
DelayedUntilExpiresAt2. Function Queue with Worker Pool (
examples/function-queue/)Demonstrates storing and executing functions as work items with:
Documentation
Each example includes:
main.gowith detailed commentsREADME.mdexplaining concepts, how to run, and production adaptationsBoth examples can be run immediately with
go run main.goand produce clear, educational output showing the queue in action.Related
This addresses the need for practical examples showing how to use workqueue for real-world use cases like crawl frontiers and background job processing systems.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.