dbpersist

package
v0.0.0-...-aa8c2ee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2025 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbPersistence

type DbPersistence struct {
	// contains filtered or unexported fields
}

func NewDbPersistence

func NewDbPersistence(db *gorm.DB, cs carstore.CarStore, options *Options) (*DbPersistence, error)

func (*DbPersistence) AddItemToBatch

func (p *DbPersistence) AddItemToBatch(ctx context.Context, rec *RepoEventRecord, evt *events.XRPCStreamEvent) error

func (*DbPersistence) Flush

func (p *DbPersistence) Flush(ctx context.Context) error

func (*DbPersistence) Persist

func (*DbPersistence) Playback

func (p *DbPersistence) Playback(ctx context.Context, since int64, cb func(*events.XRPCStreamEvent) error) error

func (*DbPersistence) RecordFromHandleChange

func (p *DbPersistence) RecordFromHandleChange(ctx context.Context, evt *comatproto.SyncSubscribeRepos_Handle) (*RepoEventRecord, error)

func (*DbPersistence) RecordFromRepoAccount

func (*DbPersistence) RecordFromRepoCommit

func (*DbPersistence) RecordFromRepoIdentity

func (p *DbPersistence) RecordFromRepoIdentity(ctx context.Context, evt *comatproto.SyncSubscribeRepos_Identity) (*RepoEventRecord, error)

func (*DbPersistence) RecordFromTombstone

func (*DbPersistence) SetEventBroadcaster

func (p *DbPersistence) SetEventBroadcaster(brc func(*events.XRPCStreamEvent))

func (*DbPersistence) Shutdown

func (p *DbPersistence) Shutdown(context.Context) error

func (*DbPersistence) TakeDownRepo

func (p *DbPersistence) TakeDownRepo(ctx context.Context, usr models.Uid) error

type Options

type Options struct {
	MaxBatchSize         int
	MinBatchSize         int
	MaxTimeBetweenFlush  time.Duration
	CheckBatchInterval   time.Duration
	UIDCacheSize         int
	DIDCacheSize         int
	PlaybackBatchSize    int
	HydrationConcurrency int
}

func DefaultOptions

func DefaultOptions() *Options

type PersistenceBatchItem

type PersistenceBatchItem struct {
	Record *RepoEventRecord
	Event  *events.XRPCStreamEvent
}

type RepoEventRecord

type RepoEventRecord struct {
	Seq       uint `gorm:"primarykey"`
	Rev       string
	Since     *string
	Commit    *models.DbCID
	Prev      *models.DbCID
	NewHandle *string // NewHandle is only set if this is a handle change event

	Time   time.Time
	Blobs  []byte
	Repo   models.Uid
	Type   string
	Rebase bool

	// Active and Status are only set on RepoAccount events
	Active bool
	Status *string

	Ops []byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL