You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 🎨 [ESLint](https://eslint.org/) - for code linting _(and formatting)_
24
-
- 📦️ [pkg.pr.new](https://pkg.pr.new) - Continuous (Preview) Releases for your libraries
25
-
- 🐙 [GitHub Actions](https://github.com/features/actions) - runs your CI _(fixes code style issues, tags releases & creates its changelogs, runs the test suite, etc.)_
22
+
## Installation
26
23
27
-
## Get Started
24
+
```bash
25
+
bun add bun-queue
26
+
```
28
27
29
-
It's rather simple to get your package development started:
28
+
## Basic Usage
30
29
31
-
```bash
32
-
# you may use this GitHub template or the following command:
33
-
bunx degit stacksjs/bun-starter my-pkg
34
-
cd my-pkg
30
+
```typescript
31
+
import { Queue } from'bun-queue'
32
+
33
+
// Create a queue
34
+
const emailQueue =newQueue('emails')
35
+
36
+
// Add a job to the queue
37
+
const job =awaitemailQueue.add({
38
+
to: 'user@example.com',
39
+
subject: 'Welcome',
40
+
body: 'Welcome to our platform!'
41
+
})
42
+
43
+
console.log(`Job ${job.id} added to the queue`)
44
+
45
+
// Process jobs
46
+
emailQueue.process(5, async (job) => {
47
+
const { to, subject, body } =job.data
48
+
49
+
// Update progress
50
+
awaitjob.updateProgress(10)
51
+
52
+
// Simulate sending email
53
+
console.log(`Sending email to ${to} with subject: ${subject}`)
console.log(`Rate limited. Try again in ${resetIn}ms.`)
148
+
}
149
+
```
150
+
151
+
## Configuration
152
+
153
+
```typescript
154
+
import { Queue } from'bun-queue'
155
+
156
+
// Configure queue with options
157
+
const queue =newQueue('tasks', {
158
+
redis: {
159
+
url: 'redis://username:password@localhost:6379'
160
+
// Or provide your own client
161
+
// client: myRedisClient
162
+
},
163
+
prefix: 'myapp', // prefix for Redis keys (default: 'queue')
164
+
defaultJobOptions: {
165
+
attempts: 5,
166
+
backoff: {
167
+
type: 'exponential',
168
+
delay: 5000
169
+
}
170
+
}
171
+
})
172
+
```
173
+
174
+
## Environment Variables
175
+
176
+
The library reads these environment variables (in order of precedence):
177
+
178
+
-`REDIS_URL`: Redis connection string
179
+
- Default is `redis://localhost:6379` if not set
44
180
45
181
## Testing
46
182
@@ -50,7 +186,7 @@ bun test
50
186
51
187
## Changelog
52
188
53
-
Please see our [releases](https://github.com/stackjs/bun-bull/releases) page for more information on what has changed recently.
189
+
Please see our [releases](https://github.com/stackjs/bun-queue/releases) page for more information on what has changed recently.
54
190
55
191
## Contributing
56
192
@@ -60,15 +196,15 @@ Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
60
196
61
197
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
62
198
63
-
[Discussions on GitHub](https://github.com/stacksjs/bun-starter/discussions)
199
+
[Discussions on GitHub](<https://github.com/stacksjs/bun-> queue/discussions)
64
200
65
201
For casual chit-chat with others using this package:
66
202
67
203
[Join the Stacks Discord Server](https://discord.gg/stacksjs)
68
204
69
205
## Postcardware
70
206
71
-
“Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.
207
+
"Software that is free, but hopes for a postcard." We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.
72
208
73
209
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
74
210
@@ -86,10 +222,10 @@ The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.
0 commit comments