feat: apply durable event acknowledgements
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
rvboxv1 "github.com/rvbox/rvbox/gen/go/rvbox/v1"
|
||||
"github.com/rvbox/rvbox/internal/domain"
|
||||
)
|
||||
|
||||
var ErrInvalidEventAck = errors.New("invalid event acknowledgement")
|
||||
|
||||
type EventAckStore interface {
|
||||
Ack(context.Context, domain.UUID, uint64) error
|
||||
}
|
||||
|
||||
// ApplyEventAck releases only the cumulative, server-confirmed event prefix.
|
||||
// The spool remains the source of truth if the process stops before this call
|
||||
// returns; a repeated acknowledgement is intentionally harmless.
|
||||
func ApplyEventAck(ctx context.Context, store EventAckStore, ack *rvboxv1.EventAck) error {
|
||||
if store == nil || ack == nil || ack.GetThroughEventSeq() == 0 {
|
||||
return ErrInvalidEventAck
|
||||
}
|
||||
issue, err := domain.ParseUUIDv7(ack.GetIssueUuid())
|
||||
if err != nil {
|
||||
return ErrInvalidEventAck
|
||||
}
|
||||
return store.Ack(ctx, issue, ack.GetThroughEventSeq())
|
||||
}
|
||||
Reference in New Issue
Block a user