Versions in this module Expand all Collapse all v0 v0.3.0 Nov 29, 2026 v0.2.0 Nov 29, 2026 Changes in this version + const DefaultBatchSize + const DefaultMaxLineBytes + const DefaultMaxObjects + const DefaultScanLimit + const DefaultSyncInterval + const DefaultTempTTL + const DelWarnMembers + const MaxBatchSize + const MaxSyncInterval + const MinSyncInterval + var ErrBadOptions = errors.New("invalid options") + var ErrEmptyInput = errors.New(...) + var ErrImportRunning = errors.New(...) + var ErrIncomplete = errors.New(...) + var ErrKeyOverlap = errors.New("the keys of the segments overlap") + var ErrKeysLayout = errors.New(...) + var ErrLockLost = errors.New("the import lock is held by another run: nothing was swapped") + var ErrNoETag = errors.New("the store returned no ETag; change detection needs it") + var ErrNoSlotTag = errors.New("the key has a hash tag that cannot be shared by a temporary key") + var ErrNotBumped = errors.New(...) + var ErrObjectChanged = errors.New("the source object changed while it was read") + var ErrObjectMissing = errors.New("the source object does not exist") + var ErrObjectURL = errors.New(...) + var ErrPartial = errors.New("partially or possibly applied") + var ErrSourceChanged = errors.New("the source changed while it was read: nothing was swapped") + var ErrStore = errors.New("segment store") + var ErrSwapUnknown = errors.New("swap state unknown: run `semaphore-cli segment stat`, then import again") + var ErrSwapped = errors.New("the change is in the store, but a later step failed") + var ErrTempGone = errors.New("the temporary key is gone before the swap: raise --temp-ttl") + var ErrTooManyObjects = errors.New("the prefix holds more objects than --max-objects") + var ErrUnsupportedClient = errors.New("the client cannot be scanned") + func Bump(ctx context.Context, store Store, target *Target, rep *Report) error + func BumpWithRetry(ctx context.Context, store Store, target *Target, rep *Report, ...) error + func CheckKeys(target, other *Target) error + func IsNoSuchKey(err error) bool + func IsUnknownCommand(err error) bool + func ScanPattern(prefix string) string + func Slot(key string) int + func Sync(ctx context.Context, store Store, target *Target, src *ObjectSource, ...) error + func WithContext(ctx context.Context, src io.Reader) io.Reader + type Commit struct + Committed string + Empty bool + Fingerprint string + Live string + Lock string + Old string + OldTTL time.Duration + Source string + Tmp string + Token string + Want int64 + type CommitResult int + const AlreadyCommitted + const Committed + const CountMismatch + const LockLost + const TempGone + type EditOptions struct + BatchSize int + Wait func(ctx context.Context, delay time.Duration) error + type Format string + const FormatCSV + const FormatLines + type ImportOptions struct + AllowEmpty bool + BatchSize int + DryRun bool + Fingerprint string + TempTTL time.Duration + Token string + Wait func(ctx context.Context, delay time.Duration) error + type Inspector interface + CountKeys func(ctx context.Context, prefix string, limit int) (count int, more bool, err error) + KeyTTL func(ctx context.Context, key string) (exists bool, ttl time.Duration, err error) + SCard func(ctx context.Context, key string) (int64, error) + Value func(ctx context.Context, key string) (value string, ok bool, err error) + type KeyCounter struct + func NewKeyCounter(limit int) *KeyCounter + func (c *KeyCounter) Add(keys []string) bool + func (c *KeyCounter) Count() int + func (c *KeyCounter) More() bool + type Locker interface + Claim func(ctx context.Context, lock, last, stale, tmp, token string) (bool, error) + Commit func(ctx context.Context, commit *Commit) (result CommitResult, fellBack bool, err error) + EditSet func(ctx context.Context, lock, key string, members []string, remove bool) (changed int64, locked bool, err error) + Lock func(ctx context.Context, key, token string, ttl time.Duration) (bool, error) + StageAdd func(ctx context.Context, lock, tmp, token string, members []string, ...) (added int64, result StageResult, err error) + Unlock func(ctx context.Context, lock, last, committed, token string) error + type Mutator interface + SAdd func(ctx context.Context, key string, members []string, ttl time.Duration) (int64, error) + SRem func(ctx context.Context, key string, members []string) (int64, error) + SetKeys func(ctx context.Context, keys []string) (int64, error) + SetValue func(ctx context.Context, key, value string) error + Unlink func(ctx context.Context, keys ...string) (removed int64, fellBack bool, err error) + type Object struct + Body io.ReadCloser + Gzip bool + Size int64 + type ObjectAPI interface + Get func(ctx context.Context, key, etag string) (Object, error) + Head func(ctx context.Context, key string) (ObjectInfo, error) + List func(ctx context.Context, prefix, token string) (ObjectPage, error) + type ObjectInfo struct + ETag string + Key string + Size int64 + type ObjectPage struct + Next string + Objects []ObjectInfo + type ObjectRef struct + Bucket string + Key string + Prefix bool + func ParseObjectURL(raw string) (ObjectRef, error) + type ObjectSource struct + func NewObjectSource(api ObjectAPI, ref ObjectRef, maxObjects int) *ObjectSource + func (s *ObjectSource) Fingerprint(ctx context.Context) (string, error) + func (s *ObjectSource) Open(ctx context.Context, want string, opts ReaderOptions) (*ObjectStream, error) + type ObjectStream struct + func (s *ObjectStream) Close() error + func (s *ObjectStream) Fingerprint() string + func (s *ObjectStream) Next() (Record, error) + func (s *ObjectStream) Objects() int + type Outcome string + const OutcomeChanged + const OutcomeFailed + const OutcomeSkipped + const OutcomeStopped + const OutcomeUnchanged + type Reader struct + func NewReader(src io.Reader, opts ReaderOptions) (*Reader, error) + func (r *Reader) Next() (Record, error) + type ReaderOptions struct + Column int + Format Format + MaxLineBytes int + type Reason string + const ReasonColumn + const ReasonEmpty + const ReasonInvalid + const ReasonTooLong + type Record struct + ID string + Line int + Reason Reason + type RedisStore struct + func NewRedis(client redis.UniversalClient) *RedisStore + func (s *RedisStore) Claim(ctx context.Context, lock, last, stale, tmp, token string) (bool, error) + func (s *RedisStore) Close() + func (s *RedisStore) Commit(ctx context.Context, commit *Commit) (CommitResult, bool, error) + func (s *RedisStore) CountKeys(ctx context.Context, prefix string, limit int) (int, bool, error) + func (s *RedisStore) EditSet(ctx context.Context, lock, key string, members []string, remove bool) (int64, bool, error) + func (s *RedisStore) KeyTTL(ctx context.Context, key string) (bool, time.Duration, error) + func (s *RedisStore) Lock(ctx context.Context, key, token string, ttl time.Duration) (bool, error) + func (s *RedisStore) Ping(ctx context.Context) error + func (s *RedisStore) SAdd(ctx context.Context, key string, members []string, ttl time.Duration) (int64, error) + func (s *RedisStore) SCard(ctx context.Context, key string) (int64, error) + func (s *RedisStore) SRem(ctx context.Context, key string, members []string) (int64, error) + func (s *RedisStore) SetKeys(ctx context.Context, keys []string) (int64, error) + func (s *RedisStore) SetValue(ctx context.Context, key, value string) error + func (s *RedisStore) StageAdd(ctx context.Context, lock, tmp, token string, members []string, ...) (int64, StageResult, error) + func (s *RedisStore) Unlink(ctx context.Context, keys ...string) (int64, bool, error) + func (s *RedisStore) Unlock(ctx context.Context, lock, last, committed, token string) error + func (s *RedisStore) Value(ctx context.Context, key string) (string, bool, error) + type Rejections struct + Column int64 + Empty int64 + Invalid int64 + TooLong int64 + func (r *Rejections) Add(reason Reason) + type Report struct + Accepted int64 + Added int64 + Applied int64 + CleanupFailed bool + DryRun bool + Duplicates int64 + DuplicatesUnknown bool + FallbackLarge bool + FellBackToDel bool + Read int64 + Rejected Rejections + Removed int64 + Swapped bool + Version string + func Edit(ctx context.Context, store Store, target *Target, src Source, remove bool, ...) (*Report, error) + func Import(ctx context.Context, store Store, target *Target, src Source, ...) (*Report, error) + type Round struct + Err error + Outcome Outcome + Report *Report + func SyncRound(ctx context.Context, store Store, target *Target, src *ObjectSource, ...) Round + type RunKeys struct + Committed string + Last string + Lock string + Old string + Source string + Tmp string + func ImportKeys(live, token string) (RunKeys, error) + func (k *RunKeys) Owns(key string) bool + type SliceSource struct + func NewSliceSource(ids []string) *SliceSource + func (s *SliceSource) Next() (Record, error) + type Source interface + Next func() (Record, error) + type StageResult int + const StageLockLost + const StageTempGone + const Staged + type Stats struct + AtLeast bool + Count int64 + Exists bool + HasVersion bool + LockHeld bool + LockTTL time.Duration + TTL time.Duration + Version string + func Stat(ctx context.Context, store Store, target *Target, scanLimit int) (*Stats, error) + type Store interface + Close func() + Ping func(ctx context.Context) error + type SyncOptions struct + Import ImportOptions + Interval time.Duration + Log *slog.Logger + Reader ReaderOptions + Wait func(ctx context.Context, delay time.Duration) error + func (o *SyncOptions) Validate() error + type Target struct + Key string + Layout redissegment.Layout + MaxIDBytes int + Name string + Normalize resolver.Normalization + VersionKey string + type ValkeyStore struct + func NewValkey(client valkey.Client) *ValkeyStore + func (s *ValkeyStore) Claim(ctx context.Context, lock, last, stale, tmp, token string) (bool, error) + func (s *ValkeyStore) Close() + func (s *ValkeyStore) Commit(ctx context.Context, commit *Commit) (CommitResult, bool, error) + func (s *ValkeyStore) CountKeys(ctx context.Context, prefix string, limit int) (int, bool, error) + func (s *ValkeyStore) EditSet(ctx context.Context, lock, key string, members []string, remove bool) (int64, bool, error) + func (s *ValkeyStore) KeyTTL(ctx context.Context, key string) (bool, time.Duration, error) + func (s *ValkeyStore) Lock(ctx context.Context, key, token string, ttl time.Duration) (bool, error) + func (s *ValkeyStore) Ping(ctx context.Context) error + func (s *ValkeyStore) SAdd(ctx context.Context, key string, members []string, ttl time.Duration) (int64, error) + func (s *ValkeyStore) SCard(ctx context.Context, key string) (int64, error) + func (s *ValkeyStore) SRem(ctx context.Context, key string, members []string) (int64, error) + func (s *ValkeyStore) SetKeys(ctx context.Context, keys []string) (int64, error) + func (s *ValkeyStore) SetValue(ctx context.Context, key, value string) error + func (s *ValkeyStore) StageAdd(ctx context.Context, lock, tmp, token string, members []string, ...) (int64, StageResult, error) + func (s *ValkeyStore) Unlink(ctx context.Context, keys ...string) (int64, bool, error) + func (s *ValkeyStore) Unlock(ctx context.Context, lock, last, committed, token string) error + func (s *ValkeyStore) Value(ctx context.Context, key string) (string, bool, error)