feat(queue): add message-plane core logic for send/receive/delete/visibility
Implements SendMessage (size cap, FIFO dedup, shard routing), ReceiveMessage (long-poll loop across active+closing shards, FIFO per-group exclusivity gating, redelivery hand-out), DeleteMessage (ack + low-watermark offset advancement), and ChangeMessageVisibility against the Redis state layer and a real Kafka producer/consumer.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package queue
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
goredis "github.com/redis/go-redis/v9"
|
||||
|
||||
kmsvcredis "github.com/rockliang/kafka-management-service/internal/redis"
|
||||
)
|
||||
|
||||
type ChangeVisibilityService struct {
|
||||
Redis *goredis.Client
|
||||
}
|
||||
|
||||
// ChangeMessageVisibility implements ChangeMessageVisibility (design.md
|
||||
// §2b): extends (or shortens) how long a received message stays invisible
|
||||
// to other consumers, without affecting its receive count.
|
||||
func (s *ChangeVisibilityService) ChangeMessageVisibility(ctx context.Context, queueName, receiptHandle string, newTimeout time.Duration) error {
|
||||
ok, err := kmsvcredis.ExtendVisibility(ctx, s.Redis, queueName, receiptHandle, newTimeout)
|
||||
if err != nil {
|
||||
return fmt.Errorf("change visibility %s: %w", queueName, err)
|
||||
}
|
||||
if !ok {
|
||||
return fmt.Errorf("receipt handle not found or already expired")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user