Skip to content

Commit 24a13ca

Browse files
committed
docs: improve documentation for Worker and QueuedMessage interfaces
- Improve comments for the `Worker` interface methods to provide clearer descriptions. - Add detailed comments for the `QueuedMessage` interface. Signed-off-by: appleboy <[email protected]>
1 parent 30e3a12 commit 24a13ca

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

core/worker.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,29 @@ import (
44
"context"
55
)
66

7-
// Worker interface
7+
// Worker represents a worker that processes queued messages.
8+
// It provides methods to run the worker, shut it down, queue messages, and request messages from the queue.
89
type Worker interface {
9-
// Run is called to start the worker
10+
// Run starts the worker and processes the given task in the provided context.
11+
// It returns an error if the task cannot be processed.
1012
Run(ctx context.Context, task QueuedMessage) error
11-
// Shutdown is called if stop all worker
13+
14+
// Shutdown stops the worker and performs any necessary cleanup.
15+
// It returns an error if the shutdown process fails.
1216
Shutdown() error
13-
// Queue to send message in Queue
17+
18+
// Queue adds a task to the worker's queue.
19+
// It returns an error if the task cannot be added to the queue.
1420
Queue(task QueuedMessage) error
15-
// Request to get message from Queue
21+
22+
// Request retrieves a task from the worker's queue.
23+
// It returns the queued message and an error if the retrieval fails.
1624
Request() (QueuedMessage, error)
1725
}
1826

19-
// QueuedMessage ...
27+
// QueuedMessage represents an interface for a message that can be queued.
28+
// It requires the implementation of a Bytes method, which returns the message
29+
// content as a slice of bytes.
2030
type QueuedMessage interface {
2131
Bytes() []byte
2232
}

0 commit comments

Comments
 (0)