Files
kmsvc-manage/internal/core/queue/change_visibility.go
T
riotpiaole b1f039ae25 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.
2026-06-21 17:08:24 -07:00

30 lines
859 B
Go

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
}