Skip to content

Commit 8ce039c

Browse files
committed
docs: improve documentation clarity and readability throughout
- Improve description of the Queue library for better clarity and readability - Change "Supports" to "Integrates with" for backend services - Rephrase installation instructions for better clarity - Update comments in code examples for better clarity and grammar - Add "for more details" to documentation references for better guidance Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 9227273 commit 8ce039c

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

README.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
[![Run Tests](https://github.com/golang-queue/queue/actions/workflows/go.yml/badge.svg)](https://github.com/golang-queue/queue/actions/workflows/go.yml)
55
[![codecov](https://codecov.io/gh/golang-queue/queue/branch/master/graph/badge.svg?token=SSo3mHejOE)](https://codecov.io/gh/golang-queue/queue)
66

7-
Queue is a Golang library for spawning and managing a Goroutine pool, allowing you to create multiple workers based on the CPU capacity of the machine.
7+
Queue is a Golang library that helps you create and manage a pool of Goroutines (lightweight threads). It allows you to efficiently run multiple tasks in parallel, utilizing the CPU capacity of your machine.
88

99
## Features
1010

1111
- [x] Supports [Circular buffer](https://en.wikipedia.org/wiki/Circular_buffer) queues.
12-
- [x] Supports [NSQ](https://nsq.io/) (a real-time distributed messaging platform) as a backend.
13-
- [x] Supports [NATS](https://nats.io/) (connective technology for adaptive edge and distributed systems) as a backend.
14-
- [x] Supports [Redis Pub/Sub](https://redis.io/docs/manual/pubsub/) as a backend.
15-
- [x] Supports [Redis Streams](https://redis.io/docs/manual/data-types/streams/) as a backend.
16-
- [x] Supports [RabbitMQ](https://www.rabbitmq.com/) as a backend.
12+
- [x] Integrates with [NSQ](https://nsq.io/) for real-time distributed messaging.
13+
- [x] Integrates with [NATS](https://nats.io/) for adaptive edge and distributed systems.
14+
- [x] Integrates with [Redis Pub/Sub](https://redis.io/docs/manual/pubsub/).
15+
- [x] Integrates with [Redis Streams](https://redis.io/docs/manual/data-types/streams/).
16+
- [x] Integrates with [RabbitMQ](https://www.rabbitmq.com/).
1717

1818
## Queue Scenario
1919

@@ -35,13 +35,13 @@ Go version **1.22** or above
3535

3636
## Installation
3737

38-
Install the stable version:
38+
To install the stable version:
3939

4040
```sh
4141
go get github.com/golang-queue/queue
4242
```
4343

44-
Install the latest version:
44+
To install the latest version:
4545

4646
```sh
4747
go get github.com/golang-queue/queue@master
@@ -51,7 +51,7 @@ go get github.com/golang-queue/queue@master
5151

5252
### Basic Usage of Pool (using the Task function)
5353

54-
By calling the `QueueTask()` method, tasks are scheduled to be executed by workers (goroutines) in the pool.
54+
By calling the `QueueTask()` method, you can schedule tasks to be executed by workers (Goroutines) in the pool.
5555

5656
```go
5757
package main
@@ -68,13 +68,13 @@ func main() {
6868
taskN := 100
6969
rets := make(chan string, taskN)
7070

71-
// initial queue pool
71+
// initialize the queue pool
7272
q := queue.NewPool(5)
73-
// shutdown the service and notify all the worker
74-
// wait all jobs are complete.
73+
// shut down the service and notify all workers
74+
// wait until all jobs are complete
7575
defer q.Release()
7676

77-
// assign tasks in queue
77+
// assign tasks to the queue
7878
for i := 0; i < taskN; i++ {
7979
go func(i int) {
8080
if err := q.QueueTask(func(ctx context.Context) error {
@@ -86,7 +86,7 @@ func main() {
8686
}(i)
8787
}
8888

89-
// wait until all tasks done
89+
// wait until all tasks are done
9090
for i := 0; i < taskN; i++ {
9191
fmt.Println("message:", <-rets)
9292
time.Sleep(20 * time.Millisecond)
@@ -96,7 +96,7 @@ func main() {
9696

9797
### Basic Usage of Pool (using a message queue)
9898

99-
Define a new message struct and implement the `Bytes()` function to encode the message. Use the `WithFn` function to handle the message from the queue.
99+
Define a new message struct and implement the `Bytes()` function to encode the message. Use the `WithFn` function to handle messages from the queue.
100100

101101
```go
102102
package main
@@ -129,7 +129,7 @@ func main() {
129129
taskN := 100
130130
rets := make(chan string, taskN)
131131

132-
// initial queue pool
132+
// initialize the queue pool
133133
q := queue.NewPool(5, queue.WithFn(func(ctx context.Context, m core.TaskMessage) error {
134134
var v job
135135
if err := json.Unmarshal(m.Payload(), &v); err != nil {
@@ -139,11 +139,11 @@ func main() {
139139
rets <- "Hi, " + v.Name + ", " + v.Message
140140
return nil
141141
}))
142-
// shutdown the service and notify all the worker
143-
// wait all jobs are complete.
142+
// shut down the service and notify all workers
143+
// wait until all jobs are complete
144144
defer q.Release()
145145

146-
// assign tasks in queue
146+
// assign tasks to the queue
147147
for i := 0; i < taskN; i++ {
148148
go func(i int) {
149149
if err := q.Queue(&job{
@@ -155,7 +155,7 @@ func main() {
155155
}(i)
156156
}
157157

158-
// wait until all tasks done
158+
// wait until all tasks are done
159159
for i := 0; i < taskN; i++ {
160160
fmt.Println("message:", <-rets)
161161
time.Sleep(50 * time.Millisecond)
@@ -165,7 +165,7 @@ func main() {
165165

166166
## Using NSQ as a Queue
167167

168-
Refer to the [NSQ documentation](https://github.com/golang-queue/nsq).
168+
Refer to the [NSQ documentation](https://github.com/golang-queue/nsq) for more details.
169169

170170
```go
171171
package main
@@ -222,7 +222,7 @@ func main() {
222222
queue.WithWorker(w),
223223
)
224224

225-
// assign tasks in queue
225+
// assign tasks to the queue
226226
for i := 0; i < taskN; i++ {
227227
go func(i int) {
228228
q.Queue(&job{
@@ -231,20 +231,20 @@ func main() {
231231
}(i)
232232
}
233233

234-
// wait until all tasks done
234+
// wait until all tasks are done
235235
for i := 0; i < taskN; i++ {
236236
fmt.Println("message:", <-rets)
237237
time.Sleep(50 * time.Millisecond)
238238
}
239239

240-
// shutdown the service and notify all the worker
240+
// shut down the service and notify all workers
241241
q.Release()
242242
}
243243
```
244244

245245
## Using NATS as a Queue
246246

247-
Refer to the [NATS documentation](https://github.com/golang-queue/nats).
247+
Refer to the [NATS documentation](https://github.com/golang-queue/nats) for more details.
248248

249249
```go
250250
package main
@@ -302,10 +302,10 @@ func main() {
302302
log.Fatal(err)
303303
}
304304

305-
// start the five worker
305+
// start the workers
306306
q.Start()
307307

308-
// assign tasks in queue
308+
// assign tasks to the queue
309309
for i := 0; i < taskN; i++ {
310310
go func(i int) {
311311
q.Queue(&job{
@@ -314,20 +314,20 @@ func main() {
314314
}(i)
315315
}
316316

317-
// wait until all tasks done
317+
// wait until all tasks are done
318318
for i := 0; i < taskN; i++ {
319319
fmt.Println("message:", <-rets)
320320
time.Sleep(50 * time.Millisecond)
321321
}
322322

323-
// shutdown the service and notify all the worker
323+
// shut down the service and notify all workers
324324
q.Release()
325325
}
326326
```
327327

328328
## Using Redis (Pub/Sub) as a Queue
329329

330-
Refer to the [Redis documentation](https://github.com/golang-queue/redisdb).
330+
Refer to the [Redis documentation](https://github.com/golang-queue/redisdb) for more details.
331331

332332
```go
333333
package main
@@ -384,10 +384,10 @@ func main() {
384384
log.Fatal(err)
385385
}
386386

387-
// start the five worker
387+
// start the workers
388388
q.Start()
389389

390-
// assign tasks in queue
390+
// assign tasks to the queue
391391
for i := 0; i < taskN; i++ {
392392
go func(i int) {
393393
q.Queue(&job{
@@ -396,13 +396,13 @@ func main() {
396396
}(i)
397397
}
398398

399-
// wait until all tasks done
399+
// wait until all tasks are done
400400
for i := 0; i < taskN; i++ {
401401
fmt.Println("message:", <-rets)
402402
time.Sleep(50 * time.Millisecond)
403403
}
404404

405-
// shutdown the service and notify all the worker
405+
// shut down the service and notify all workers
406406
q.Release()
407407
}
408408
```

0 commit comments

Comments
 (0)