fix: sync scoped connection and outbox exclusion updates
This commit is contained in:
parent
aa21bd04e1
commit
cbccd6a8d9
58 changed files with 919 additions and 1435 deletions
|
|
@ -2,6 +2,7 @@ package postgres
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
|
@ -18,6 +19,21 @@ const (
|
|||
maxDispatchPoisonCleanupBatch = 1000
|
||||
)
|
||||
|
||||
var errInvalidDispatchOutboxExclusionPair = errors.New("dispatch outbox exclusion requires both raw auth key and session id")
|
||||
|
||||
// enqueueDispatch is the only production write boundary for dispatch_outbox.
|
||||
// A zero pair means no originating session is excluded; a non-zero pair identifies
|
||||
// one exact physical raw-auth/session tuple. A half pair is never meaningful because
|
||||
// session IDs are not globally unique and must fail the surrounding transaction.
|
||||
func enqueueDispatch(ctx context.Context, q *sqlcgen.Queries, arg sqlcgen.EnqueueDispatchParams) error {
|
||||
hasAuthKey := arg.ExcludeAuthKeyID != 0
|
||||
hasSession := arg.ExcludeSessionID != 0
|
||||
if hasAuthKey != hasSession {
|
||||
return errInvalidDispatchOutboxExclusionPair
|
||||
}
|
||||
return q.EnqueueDispatch(ctx, arg)
|
||||
}
|
||||
|
||||
// DispatchOutboxStore 用 PostgreSQL 实现 transactional outbox。
|
||||
type DispatchOutboxStore struct {
|
||||
q *sqlcgen.Queries
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue