Skip to content

Commit 90e93fd

Browse files
committed
fix(lint): add comments.
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent e2f8e3a commit 90e93fd

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

consumer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var _ Worker = (*Consumer)(nil)
1313

1414
var errMaxCapacity = errors.New("max capacity reached")
1515

16-
// Worker for simple queue using channel
16+
// Consumer for simple queue using channel
1717
type Consumer struct {
1818
taskQueue chan QueuedMessage
1919
runFunc func(context.Context, QueuedMessage) error
@@ -32,6 +32,7 @@ func (s *Consumer) decBusyWorker() {
3232
s.metric.DecBusyWorker()
3333
}
3434

35+
// BusyWorkers returns the numbers of workers has been busy.
3536
func (s *Consumer) BusyWorkers() uint64 {
3637
return s.metric.BusyWorkers()
3738
}

options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func WithTimeOut(t time.Duration) Option {
6767
}
6868
}
6969

70+
// Options for custom args in Queue
7071
type Options struct {
7172
workerCount int
7273
timeout time.Duration
@@ -77,6 +78,7 @@ type Options struct {
7778
metric Metric
7879
}
7980

81+
// NewOptions initialize the default value for the options
8082
func NewOptions(opts ...Option) *Options {
8183
o := &Options{
8284
workerCount: defaultWorkerCount,

pool.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package queue
22

3+
// NewPool initializes a new pool
34
func NewPool(size int, opts ...Option) *Queue {
45
o := []Option{
56
WithWorkerCount(size),

queue.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func (j Job) Bytes() []byte {
4747
return j.Payload
4848
}
4949

50+
// Encode for encoding the structure
5051
func (j Job) Encode() []byte {
5152
b, _ := json.Marshal(j)
5253
return b
@@ -107,7 +108,7 @@ func (q *Queue) Shutdown() {
107108
})
108109
}
109110

110-
// Workers returns the numbers of workers has been created.
111+
// Release for graceful shutdown.
111112
func (q *Queue) Release() {
112113
q.Shutdown()
113114
q.Wait()
@@ -143,7 +144,7 @@ func (q *Queue) Queue(job QueuedMessage) error {
143144
return q.handleQueue(q.timeout, job)
144145
}
145146

146-
// Queue to queue all job
147+
// QueueWithTimeout to queue all job with specified timeout.
147148
func (q *Queue) QueueWithTimeout(timeout time.Duration, job QueuedMessage) error {
148149
return q.handleQueue(timeout, job)
149150
}

0 commit comments

Comments
 (0)