Documentation ¶
Index ¶
- Variables
- type BackfillOptions
- type Backfiller
- type GormDBJob
- type Gormjob
- type Gormstore
- func (s *Gormstore) BufferOp(ctx context.Context, repo, kind, path string, rec *typegen.CBORMarshaler, ...) (bool, error)
- func (s *Gormstore) EnqueueJob(repo string) error
- func (s *Gormstore) GetJob(ctx context.Context, repo string) (Job, error)
- func (s *Gormstore) GetNextEnqueuedJob(ctx context.Context) (Job, error)
- func (s *Gormstore) LoadJobs(ctx context.Context) error
- type Job
- type Memjob
- type Memstore
- func (s *Memstore) BufferOp(ctx context.Context, repo, kind, path string, rec *typegen.CBORMarshaler, ...) (bool, error)
- func (s *Memstore) EnqueueJob(repo string) error
- func (s *Memstore) GetJob(ctx context.Context, repo string) (Job, error)
- func (s *Memstore) GetNextEnqueuedJob(ctx context.Context) (Job, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // StateEnqueued is the state of a backfill job when it is first created StateEnqueued = "enqueued" // StateInProgress is the state of a backfill job when it is being processed StateInProgress = "in_progress" // StateComplete is the state of a backfill job when it has been processed StateComplete = "complete" )
View Source
var ErrJobComplete = errors.New("job is complete")
ErrJobComplete is returned when trying to buffer an op for a job that is complete
View Source
var ErrJobNotFound = errors.New("job not found")
ErrJobNotFound is returned when trying to buffer an op for a job that doesn't exist
Functions ¶
This section is empty.
Types ¶
type BackfillOptions ¶
type BackfillOptions struct { ParallelBackfills int ParallelRecordCreates int NSIDFilter string SyncRequestsPerSecond int CheckoutPath string }
func DefaultBackfillOptions ¶
func DefaultBackfillOptions() *BackfillOptions
type Backfiller ¶
type Backfiller struct { Name string HandleCreateRecord func(ctx context.Context, repo string, path string, rec *typegen.CBORMarshaler, cid *cid.Cid) error HandleUpdateRecord func(ctx context.Context, repo string, path string, rec *typegen.CBORMarshaler, cid *cid.Cid) error HandleDeleteRecord func(ctx context.Context, repo string, path string) error Store Store // Number of backfills to process in parallel ParallelBackfills int // Number of records to process in parallel for each backfill ParallelRecordCreates int // Prefix match for records to backfill i.e. app.bsky.feed.app/ // If empty, all records will be backfilled NSIDFilter string CheckoutPath string // contains filtered or unexported fields }
Backfiller is a struct which handles backfilling a repo
func NewBackfiller ¶
func NewBackfiller( name string, store Store, handleCreate func(ctx context.Context, repo string, path string, rec *typegen.CBORMarshaler, cid *cid.Cid) error, handleUpdate func(ctx context.Context, repo string, path string, rec *typegen.CBORMarshaler, cid *cid.Cid) error, handleDelete func(ctx context.Context, repo string, path string) error, opts *BackfillOptions, ) *Backfiller
NewBackfiller creates a new Backfiller
func (*Backfiller) BackfillRepo ¶
func (b *Backfiller) BackfillRepo(ctx context.Context, job Job)
BackfillRepo backfills a repo
func (*Backfiller) FlushBuffer ¶
func (b *Backfiller) FlushBuffer(ctx context.Context, job Job) int
FlushBuffer processes buffered operations for a job
type Gormjob ¶
type Gormjob struct {
// contains filtered or unexported fields
}
func (*Gormjob) FlushBufferedOps ¶
type Gormstore ¶
type Gormstore struct {
// contains filtered or unexported fields
}
Gormstore is a gorm-backed implementation of the Backfill Store interface
func NewGormstore ¶
func (*Gormstore) EnqueueJob ¶
func (*Gormstore) GetNextEnqueuedJob ¶
type Job ¶
type Job interface { Repo() string State() string SetState(ctx context.Context, state string) error // FlushBufferedOps calls the given callback for each buffered operation // Once done it clears the buffer and marks the job as "complete" // Allowing the Job interface to abstract away the details of how buffered // operations are stored and/or locked FlushBufferedOps(ctx context.Context, cb func(kind, path string, rec *typegen.CBORMarshaler, cid *cid.Cid) error) error ClearBufferedOps(ctx context.Context) error }
Job is an interface for a backfill job
type Memjob ¶
type Memjob struct {
// contains filtered or unexported fields
}
func (*Memjob) FlushBufferedOps ¶
type Memstore ¶
type Memstore struct {
// contains filtered or unexported fields
}
Memstore is a simple in-memory implementation of the Backfill Store interface
func NewMemstore ¶
func NewMemstore() *Memstore
func (*Memstore) EnqueueJob ¶
type Store ¶
type Store interface { // BufferOp buffers an operation for a job and returns true if the operation was buffered // If the operation was not buffered, it returns false and an error (ErrJobNotFound or ErrJobComplete) BufferOp(ctx context.Context, repo string, kind, path string, rec *typegen.CBORMarshaler, cid *cid.Cid) (bool, error) GetJob(ctx context.Context, repo string) (Job, error) GetNextEnqueuedJob(ctx context.Context) (Job, error) }
Store is an interface for a backfill store which holds Jobs
Click to show internal directories.
Click to hide internal directories.