actorstore

package
v0.0.0-...-e6a591c Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRequest = errors.New("invalid request")
)

Custom errors

Functions

func RunMigration

func RunMigration(d *sql.DB) error

Types

type ActorStore

type ActorStore struct {
	Dir      string
	ReadOnly bool
}

func (*ActorStore) Create

func (as *ActorStore) Create(did syntax.DID, signingKey crypto.PrivateKeyExportable) error

func (*ActorStore) CreateAsPref

func (as *ActorStore) CreateAsPref(did syntax.DID, key crypto.PrivateKeyExportable) (*PreferenceReader, error)

func (*ActorStore) CreateAsRecord

func (as *ActorStore) CreateAsRecord(did syntax.DID, key crypto.PrivateKeyExportable) (*RecordReader, error)

func (*ActorStore) CreateAsRepo

func (as *ActorStore) CreateAsRepo(did syntax.DID, key crypto.PrivateKeyExportable) (*SQLRepoReader, error)

func (*ActorStore) Destroy

func (as *ActorStore) Destroy(did syntax.DID) error

func (*ActorStore) Pref

func (as *ActorStore) Pref(did syntax.DID) (r *PreferenceReader, err error)

func (*ActorStore) Record

func (as *ActorStore) Record(did syntax.DID) (*RecordReader, error)

func (*ActorStore) Repo

func (*ActorStore) Transact

func (as *ActorStore) Transact(ctx context.Context, did syntax.DID, blobs repo.BlobStore, fn func(ctx context.Context, tx *ActorStoreTransactor) error) error

type ActorStoreTransactor

type ActorStoreTransactor struct {
	Repo   *RepoTransactor
	Record *RecordTransactor
	Pref   *PreferenceReader
}

type BackgroundQueue

type BackgroundQueue any
type Backlink struct {
	URI    string `json:"uri"`
	Path   string `json:"path"`
	LinkTo string `json:"linkTo"`
}

type BlobReader

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

func NewBlobReader

func NewBlobReader(
	db db.DB,
	blobstore repo.BlobStore,
	did syntax.DID,
	key crypto.PrivateKeyExportable,
) *BlobReader

func (*BlobReader) BlobCount

func (br *BlobReader) BlobCount(ctx context.Context) (int64, error)

func (*BlobReader) Close

func (ds *BlobReader) Close() error

func (*BlobReader) GetBlob

func (br *BlobReader) GetBlob(ctx context.Context, cid cid.Cid) (size int64, mimeType *string, stream io.ReadCloser, err error)

func (*BlobReader) GetBlobMetadata

func (br *BlobReader) GetBlobMetadata(ctx context.Context, cid cid.Cid) (size int64, mimeType *string, err error)

func (*BlobReader) GetBlobTakedownStatus

func (br *BlobReader) GetBlobTakedownStatus(ctx context.Context, cid string) (*StatusAttr, error)

func (*BlobReader) GetRecordsForBlob

func (br *BlobReader) GetRecordsForBlob(ctx context.Context, cid string) ([]string, error)

func (*BlobReader) ListBlobs

func (br *BlobReader) ListBlobs(ctx context.Context, limit int, opts *ListBlobsOpts) ([]string, error)

func (*BlobReader) ListMissingBlobs

func (br *BlobReader) ListMissingBlobs(ctx context.Context, cursor *string, limit int) ([]MissingBlob, error)

func (*BlobReader) RecordBlobCount

func (br *BlobReader) RecordBlobCount(ctx context.Context) (int64, error)

type BlobTransactor

type BlobTransactor struct{ *BlobReader }

func NewBlobTransactor

func NewBlobTransactor(db db.DB, br *BlobReader) *BlobTransactor

func (BlobTransactor) Close

func (ds BlobTransactor) Close() error

func (*BlobTransactor) DeleteBlob

func (t *BlobTransactor) DeleteBlob(ctx context.Context, cid cid.Cid) error

func (*BlobTransactor) GetBlobDetails

func (t *BlobTransactor) GetBlobDetails(ctx context.Context, cid string) (map[string]interface{}, error)

func (*BlobTransactor) ListAllBlobs

func (t *BlobTransactor) ListAllBlobs(ctx context.Context, limit int, offset int) ([]map[string]interface{}, error)

func (*BlobTransactor) ProcessWriteBlobs

func (t *BlobTransactor) ProcessWriteBlobs(ctx context.Context, rev string, writes []repo.PreparedWrite) error

func (*BlobTransactor) QuarantineBlob

func (t *BlobTransactor) QuarantineBlob(ctx context.Context, cid cid.Cid) error

func (*BlobTransactor) UnQuarantineBlob

func (t *BlobTransactor) UnQuarantineBlob(ctx context.Context, cid cid.Cid) error

type LinkableRecord

type LinkableRecord interface {
	// Type should return the "$type" field.
	Type() (id string, found bool)
	// Subject should return the record's subject.
	Subject() (subj any, found bool)
}

LinkableRecord is a type that is stored as json and has a "$type" field and a "subject" field.

type ListBlobsOpts

type ListBlobsOpts struct {
	Since, Cursor *string
}

type MissingBlob

type MissingBlob struct {
	CID       string
	RecordURI string
}

type Preference

type Preference struct {
	ID    int
	Name  string
	Value map[string]any
}

func (*Preference) Scan

func (p *Preference) Scan(scanner interface{ Scan(...any) error }) error

type PreferenceReader

type PreferenceReader datastore

func (*PreferenceReader) Get

func (pr *PreferenceReader) Get(ctx context.Context, name string) (*Preference, error)

func (*PreferenceReader) List

func (pr *PreferenceReader) List(ctx context.Context) ([]Preference, error)

type PreparedCreate

type PreparedCreate struct {
	URI    syntax.ATURI
	CID    cid.Cid
	Record interface{}
}

PreparedCreate represents a create operation

type Record

type Record struct {
	URI         syntax.ATURI
	CID         cid.Cid
	Value       any
	Collection  string
	Rkey        string
	RepoRev     string
	TakedownRef sql.NullString
}
type RecordBacklink struct {
	URI         string
	Collection  string
	CID         string
	RKey        string
	RepoRev     string
	IndexedAt   string
	TakedownRef string
}

type RecordReader

type RecordReader datastore

func (*RecordReader) Close

func (rr *RecordReader) Close() error

func (*RecordReader) GetBacklinkConflicts

func (rr *RecordReader) GetBacklinkConflicts(ctx context.Context, uri syntax.ATURI, record LinkableRecord) ([]syntax.ATURI, error)

func (*RecordReader) GetByRev

func (rr *RecordReader) GetByRev(ctx context.Context, rev string) (*Record, error)

func (*RecordReader) GetRecord

func (rr *RecordReader) GetRecord(ctx context.Context, uri syntax.ATURI, cid *cid.Cid, includeSoftDeleted bool) (*Record, error)
func (rr *RecordReader) GetRecordBacklinks(ctx context.Context, collection syntax.NSID, path, linkTo string) ([]RecordBacklink, error)

func (*RecordReader) ListAll

func (rr *RecordReader) ListAll(ctx context.Context) ([]Record, error)

func (*RecordReader) ListCollections

func (rr *RecordReader) ListCollections(ctx context.Context) (iter.Seq2[string, error], error)

func (*RecordReader) ListForCollection

func (*RecordReader) Tx

func (rr *RecordReader) Tx(ctx context.Context, fn func(ctx context.Context, tx *RecordTransactor) error) error

type RecordTransactor

type RecordTransactor struct {
	*RecordReader
}
func (rt *RecordTransactor) AddBacklinks(ctx context.Context, backlinks []Backlink) error

func (*RecordTransactor) DeleteRecord

func (rt *RecordTransactor) DeleteRecord(ctx context.Context, uri syntax.ATURI) error

func (*RecordTransactor) IndexRecord

func (rt *RecordTransactor) IndexRecord(
	ctx context.Context,
	uri syntax.ATURI,
	cid cid.Cid,
	record any,
	action repo.WriteOpAction,
	repoRev string,
	timestamp time.Time,
) error

func (*RecordTransactor) RemoveBacklinksByURI

func (rt *RecordTransactor) RemoveBacklinksByURI(ctx context.Context, uri syntax.ATURI) error

type RepoBlock

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

type RepoRecord

type RepoRecord map[string]any

func (RepoRecord) Subject

func (r RepoRecord) Subject() (any, bool)

func (RepoRecord) Type

func (r RepoRecord) Type() (string, bool)

type RepoTransactor

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

RepoTransactor handles repository operations

func NewRepoTransactor

func NewRepoTransactor(
	db db.DB,
	did syntax.DID,
	signingKey crypto.PrivateKeyExportable,
	blobstore repo.BlobStore,
	backgroundQueue *BackgroundQueue,
	now string,
) *RepoTransactor

NewRepoTransactor creates a new repository transactor

func (*RepoTransactor) Close

func (ds *RepoTransactor) Close() error

func (*RepoTransactor) CreateRepo

func (t *RepoTransactor) CreateRepo(ctx context.Context, writes []repo.PreparedCreate) (*repo.CommitData, error)

CreateRepo creates a new repository with the given writes

func (*RepoTransactor) FormatCommit

func (t *RepoTransactor) FormatCommit(
	ctx context.Context,
	writes []repo.PreparedWrite,
	swapCommit cid.Cid,
) (*repo.CommitData, error)

FormatCommit formats a commit from the given writes

func (*RepoTransactor) GetDuplicateRecordCIDs

func (t *RepoTransactor) GetDuplicateRecordCIDs(ctx context.Context, cids *cid.Set, touchedURIs []syntax.ATURI) ([]cid.Cid, error)

GetDuplicateRecordCIDs finds CIDs that are referenced by other records

func (*RepoTransactor) ProcessWrites

func (t *RepoTransactor) ProcessWrites(ctx context.Context, writes []repo.PreparedWrite, swapCommitCID cid.Cid) (*repo.CommitData, error)

ProcessWrites processes multiple write operations

type SQLRepoReader

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

SQLRepoReader implements the base read operations

func NewSQLRepoReader

func NewSQLRepoReader(db database.DB, did syntax.DID, signingKey crypto.PrivateKeyExportable) *SQLRepoReader

func (*SQLRepoReader) Close

func (s *SQLRepoReader) Close() error

func (*SQLRepoReader) GetBlocks

func (s *SQLRepoReader) GetBlocks(ctx context.Context, cids []cid.Cid) (*repo.BlockResult, error)

func (*SQLRepoReader) GetBytes

func (s *SQLRepoReader) GetBytes(ctx context.Context, c cid.Cid) ([]byte, error)

func (*SQLRepoReader) GetRoot

func (s *SQLRepoReader) GetRoot(ctx context.Context) (cid.Cid, error)

func (*SQLRepoReader) GetRootDetailed

func (s *SQLRepoReader) GetRootDetailed(ctx context.Context) (*repo.RootInfo, error)

func (*SQLRepoReader) Has

func (s *SQLRepoReader) Has(ctx context.Context, cid cid.Cid) (bool, error)

func (*SQLRepoReader) ListAllBlocks

func (s *SQLRepoReader) ListAllBlocks(ctx context.Context) (*repo.BlockMap, error)

func (*SQLRepoReader) Tx

func (s *SQLRepoReader) Tx(ctx context.Context, blob repo.BlobStore, fn func(ctx context.Context, tx *RepoTransactor) error) error

type SQLRepoTransactor

type SQLRepoTransactor struct {
	*SQLRepoReader
	// contains filtered or unexported fields
}

SQLRepoTransactor extends SQLRepoReader with write operations

func NewSQLRepoTransactor

func NewSQLRepoTransactor(tx database.DB, did syntax.DID, key crypto.PrivateKeyExportable) *SQLRepoTransactor

func (*SQLRepoTransactor) ApplyCommit

func (s *SQLRepoTransactor) ApplyCommit(ctx context.Context, commit *repo.CommitData, isCreate bool) error

func (*SQLRepoTransactor) CacheRev

func (s *SQLRepoTransactor) CacheRev(ctx context.Context, rev string) error

func (*SQLRepoTransactor) DeleteMany

func (s *SQLRepoTransactor) DeleteMany(ctx context.Context, cids *cid.Set) error

func (s *SQLRepoTransactor) DeleteMany(ctx context.Context, cids []syntax.CID) error {

func (*SQLRepoTransactor) PutBlock

func (s *SQLRepoTransactor) PutBlock(ctx context.Context, cid cid.Cid, block []byte, rev string) error

func (*SQLRepoTransactor) PutMany

func (s *SQLRepoTransactor) PutMany(ctx context.Context, toPut *repo.BlockMap, rev string) error

func (*SQLRepoTransactor) UpdateRoot

func (s *SQLRepoTransactor) UpdateRoot(ctx context.Context, cid cid.Cid, rev string, isCreate bool) error

type ScannableString

type ScannableString string

func (*ScannableString) Scan

func (s *ScannableString) Scan(scanner db.Scanner) error

type StatusAttr

type StatusAttr struct {
	Applied bool
	Ref     string
}

type StoredCid

type StoredCid struct {
	CID cid.Cid
}

func (*StoredCid) Scan

func (sc *StoredCid) Scan(value any) (err error)

func (*StoredCid) Value

func (sc *StoredCid) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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