Skip to content

Commit c41e4e6

Browse files
committed
Adds func documentation
1 parent 6148a97 commit c41e4e6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

consumer.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
//go:generate mockgen -source=driver/driver.go -package=squeue_test -destination=driver_test.go
1111

12-
// NewConsumer
12+
// NewConsumer creates a new consumer for the given T type of messages
1313
func NewConsumer[T json.Unmarshaler](d driver.Driver) Consumer[T] {
1414
return Consumer[T]{d}
1515
}
@@ -18,7 +18,11 @@ type Consumer[T json.Unmarshaler] struct {
1818
driver driver.Driver
1919
}
2020

21-
// TODO: document Consume
21+
// Consume retrieves messages from the given queue.
22+
// Any provided options will be sent to the underlying driver.
23+
// The messages are indefinetely consumed from the queue and
24+
// sent to the chan Message[T].
25+
// To stop consuming messages is sufficient to cancel the context.Context
2226
func (p *Consumer[T]) Consume(ctx context.Context, queue string, opts ...func(message any)) (chan Message[T], error) {
2327
messages, err := p.driver.Consume(ctx, queue, opts...)
2428
if err != nil {
@@ -57,7 +61,8 @@ func (p *Consumer[T]) Consume(ctx context.Context, queue string, opts ...func(me
5761
return outMsg, nil
5862
}
5963

60-
// TODO: document Ack
64+
// Ack explicitly acknowldge the message handling.
65+
// It can be implemented as No Operation for some drivers.
6166
func (p *Consumer[T]) Ack(queue string, m Message[T]) error {
6267
return p.driver.Ack(queue, m.ID)
6368
}

producer.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ type Producer struct {
1616
driver driver.Driver
1717
}
1818

19-
// TODO: document Enqueue
19+
// Enqueue sends a message to the given queue
20+
// any provided options will be sent to the
21+
// underlying driver
2022
func (q *Producer) Enqueue(queue string, message json.Marshaler, opts ...func(message any)) error {
2123
data, err := json.Marshal(message)
2224
if err != nil {

0 commit comments

Comments
 (0)