internal/infra/pg/chunkrecovery.go
internal/infra/pg · 157 lines · 6 declarations · source
Declarations
const MaxChunkRecoveryBytes
const MaxChunkRecoveryBytes = 16 << 20
var ErrChunkRecoveryLimit
var ErrChunkRecoveryLimit = errors.New("chunk recovery page exceeds 16 MiB of source text; reduce the page limit")
type ChunkRecoveryCursor
type ChunkRecoveryCursor struct {
Offset int64 `json:"log_offset"`
Ordinal int `json:"ordinal"`
}
type ChunkRecoveryPage
type ChunkRecoveryPage struct {
Examined int `json:"examined"`
Restored int `json:"restored"`
Repaired int `json:"repaired"`
Next *ChunkRecoveryCursor `json:"next,omitempty"`
}
method ObservationStore.RecoverChunks
func (s *ObservationStore) RecoverChunks(ctx context.Context, schema Schema, scope, source, actor string, after ChunkRecoveryCursor, limit int) (ChunkRecoveryPage, error)
Source offsets are monotonic within the project. Each page locks surviving source material before restoring derived rows; erasure wins cleanly if a selected message disappears before that lock.
func recoverMessageChunkTx
func recoverMessageChunkTx(ctx context.Context, tx pgx.Tx, schema Schema, scope, source string, ordinal int) (bool, bool, error)