Documentation ¶
Index ¶
- Constants
- Variables
- func IsNonEmptyString(s string) bool
- func IsValidBranchName(branch string) bool
- func IsValidReference(reference string) bool
- func IsValidRepositoryName(repository string) bool
- func MakeReference(branch string, commitID CommitID) string
- func Validate(validators ValidateFields) error
- type Branch
- type BranchCataloger
- type Cache
- type CacheConfig
- type Cataloger
- type CatalogerHooks
- type CatalogerOption
- type CommitID
- type CommitLog
- type Committer
- type CreateEntryParams
- type DBBranchScanner
- type DBLineageScanner
- type DBScanner
- type DBScannerEntry
- type DBScannerOptions
- type DedupParams
- type DedupReport
- type DiffParams
- type Differ
- type Difference
- type DifferenceType
- type Differences
- type DummyCache
- type Entry
- type EntryCataloger
- type Expiration
- type ExpireResult
- type ExpiryRows
- type ExportConfiguration
- type ExportConfigurationForBranch
- type ExportConfigurator
- type GetBranchIDFn
- type GetEntryParams
- type GetRepositoryFn
- type GetRepositoryIDFn
- type Hookser
- type InternalObjectRef
- type LRUCache
- type LockType
- type MergeResult
- type Merger
- type Metadata
- type MinMaxCommit
- type MultipartUpdateCataloger
- type MultipartUpload
- type Policy
- type PolicyWithCreationTime
- type Ref
- type RelationType
- type Repository
- type RepositoryCataloger
- type Rule
- type Rules
- type RulesHolder
- type StringRows
- type TimePeriodHours
- type ValidateField
- type ValidateFields
- type ValidateFunc
- func ValidateBranchName(branch string) ValidateFunc
- func ValidateCommitMessage(message string) ValidateFunc
- func ValidateCommitter(name string) ValidateFunc
- func ValidateOptionalString(s string, validator func(string) bool) ValidateFunc
- func ValidatePath(name string) ValidateFunc
- func ValidatePhysicalAddress(addr string) ValidateFunc
- func ValidateReference(reference string) ValidateFunc
- func ValidateRepositoryName(repository string) ValidateFunc
- func ValidateStorageNamespace(storageNamespace string) ValidateFunc
- func ValidateUploadID(uploadID string) ValidateFunc
Constants ¶
const ( CatalogerCommitter = "" DefaultBranchName = "master" DefaultImportBranchName = "import-from-inventory" DefaultPathDelimiter = "/" MaxReadQueue = 10 )
const ( ListEntriesMaxLimit = 1000 ListEntriesBranchBatchSize = 32 )
const ( DBEntryFieldChecksum = "checksum" DBEntryFieldPhysicalAddress = "physical_address" )
const ( CommittedID CommitID = -1 UncommittedID CommitID = 0 MaxCommitID CommitID = 1_000_000_000_000_000_000 MinCommitUncommittedIndicator = MaxCommitID TombstoneCommitID CommitID = 0 CommittedSuffix = ":HEAD" CommitPrefix = "~" InternalObjectRefSeparator = "$" InternalObjectRefFormat = "int:pbm:%s" InternalObjectRefParts = 3 )
const ( DirectoryTerminationValue = utf8.MaxRune DirectoryTermination = string(rune(DirectoryTerminationValue)) )
const DBScannerDefaultBufferSize = 1024
const (
DiffMaxLimit = 1000
)
const ListBranchesMaxLimit = 10000
const ListCommitsMaxLimit = 10000
const ListRepositoriesMaxLimit = 10000
Variables ¶
var ( ErrFeatureNotSupported = errors.New("feature not supported") ErrOperationNotPermitted = errors.New("operation not permitted") ErrInvalidLockValue = errors.New("invalid lock value") ErrNothingToCommit = errors.New("nothing to commit") ErrNoDifferenceWasFound = errors.New("no difference was found") ErrConflictFound = errors.New("conflict found") ErrUnsupportedRelation = errors.New("unsupported relation") ErrUnsupportedDelimiter = errors.New("unsupported delimiter") ErrInvalidReference = errors.New("invalid reference") ErrBranchNotFound = fmt.Errorf("branch %w", db.ErrNotFound) ErrCommitNotFound = fmt.Errorf("commit %w", db.ErrNotFound) ErrRepositoryNotFound = fmt.Errorf("repository %w", db.ErrNotFound) ErrMultipartUploadNotFound = fmt.Errorf("multipart upload %w", db.ErrNotFound) ErrEntryNotFound = fmt.Errorf("entry %w", db.ErrNotFound) ErrByteSliceTypeAssertion = errors.New("type assertion to []byte failed") ErrInvalidMetadataSrcFormat = errors.New("invalid metadata src format") ErrUnexpected = errors.New("unexpected error") ErrReadEntryTimeout = errors.New("read entry timeout") ErrMissingDiffResultsIDInContext = errors.New("missing diff results id in context") ErrInvalidValue = errors.New("invalid value") )
var ErrExpired = errors.New("expired from storage")
Functions ¶
func IsNonEmptyString ¶
func IsValidBranchName ¶
func IsValidReference ¶
func IsValidRepositoryName ¶
func MakeReference ¶
func Validate ¶
func Validate(validators ValidateFields) error
Types ¶
type BranchCataloger ¶
type BranchCataloger interface { CreateBranch(ctx context.Context, repository, branch string, sourceBranch string) (*CommitLog, error) DeleteBranch(ctx context.Context, repository, branch string) error ListBranches(ctx context.Context, repository string, prefix string, limit int, after string) ([]*Branch, bool, error) BranchExists(ctx context.Context, repository string, branch string) (bool, error) GetBranchReference(ctx context.Context, repository, branch string) (string, error) ResetBranch(ctx context.Context, repository, branch string) error }
type Cache ¶
type Cache interface { Repository(repository string, setFn GetRepositoryFn) (*Repository, error) RepositoryID(repository string, setFn GetRepositoryIDFn) (int, error) BranchID(repository string, branch string, setFn GetBranchIDFn) (int64, error) }
type CacheConfig ¶
type Cataloger ¶
type Cataloger interface { RepositoryCataloger BranchCataloger EntryCataloger Committer MultipartUpdateCataloger Differ Merger Hookser ExportConfigurator io.Closer }
func NewCataloger ¶
func NewCataloger(db db.Database, options ...CatalogerOption) Cataloger
type CatalogerHooks ¶ added in v0.15.0
type CatalogerHooks struct { // PostCommit hooks are called at the end of a commit. PostCommit []func(ctx context.Context, tx db.Tx, commitLog *CommitLog) error // PostMerge hooks are called at the end of a merge. PostMerge []func(ctx context.Context, tx db.Tx, mergeResult *MergeResult) error }
CatalogerHooks describes the hooks available for some operations on the catalog. Hooks are called in a current transaction context; if they return an error the transaction is rolled back. Because these transactions are current, the hook can see the effect the operation only on the passed transaction.
func (*CatalogerHooks) AddPostCommit ¶ added in v0.15.0
func (h *CatalogerHooks) AddPostCommit(f func(context.Context, db.Tx, *CommitLog) error) *CatalogerHooks
func (*CatalogerHooks) AddPostMerge ¶ added in v0.15.0
func (h *CatalogerHooks) AddPostMerge(f func(context.Context, db.Tx, *MergeResult) error) *CatalogerHooks
type CatalogerOption ¶
type CatalogerOption func(*cataloger)
func WithCacheEnabled ¶ added in v0.10.0
func WithCacheEnabled(b bool) CatalogerOption
func WithDedupReportChannel ¶
func WithDedupReportChannel(b bool) CatalogerOption
func WithParams ¶ added in v0.10.0
func WithParams(p params.Catalog) CatalogerOption
type Committer ¶
type Committer interface { Commit(ctx context.Context, repository, branch string, message string, committer string, metadata Metadata) (*CommitLog, error) GetCommit(ctx context.Context, repository, reference string) (*CommitLog, error) ListCommits(ctx context.Context, repository, branch string, fromReference string, limit int) ([]*CommitLog, bool, error) RollbackCommit(ctx context.Context, repository, reference string) error }
type CreateEntryParams ¶
type CreateEntryParams struct {
Dedup DedupParams
}
type DBBranchScanner ¶ added in v0.15.0
type DBBranchScanner struct {
// contains filtered or unexported fields
}
func NewDBBranchScanner ¶ added in v0.15.0
func NewDBBranchScanner(tx db.Tx, branchID int64, commitID CommitID, opts *DBScannerOptions) *DBBranchScanner
func (*DBBranchScanner) Err ¶ added in v0.15.0
func (s *DBBranchScanner) Err() error
func (*DBBranchScanner) Next ¶ added in v0.15.0
func (s *DBBranchScanner) Next() bool
func (*DBBranchScanner) Value ¶ added in v0.15.0
func (s *DBBranchScanner) Value() *DBScannerEntry
type DBLineageScanner ¶ added in v0.15.0
type DBLineageScanner struct {
// contains filtered or unexported fields
}
func NewDBLineageScanner ¶ added in v0.15.0
func NewDBLineageScanner(tx db.Tx, branchID int64, commitID CommitID, opts *DBScannerOptions) *DBLineageScanner
func (*DBLineageScanner) Err ¶ added in v0.15.0
func (s *DBLineageScanner) Err() error
func (*DBLineageScanner) Next ¶ added in v0.15.0
func (s *DBLineageScanner) Next() bool
func (*DBLineageScanner) ReadLineage ¶ added in v0.15.0
func (s *DBLineageScanner) ReadLineage() ([]lineageCommit, error)
func (*DBLineageScanner) Value ¶ added in v0.15.0
func (s *DBLineageScanner) Value() *DBScannerEntry
type DBScanner ¶ added in v0.15.0
type DBScanner interface { Next() bool Value() *DBScannerEntry Err() error }
type DBScannerEntry ¶ added in v0.15.0
type DBScannerEntry struct { BranchID int64 `db:"branch_id"` RowCtid string `db:"ctid"` MinMaxCommit Entry }
func ScanDBEntryUntil ¶ added in v0.15.0
func ScanDBEntryUntil(s DBScanner, ent *DBScannerEntry, p string) (*DBScannerEntry, error)
type DBScannerOptions ¶ added in v0.15.0
type DedupParams ¶
type DedupReport ¶
type DiffParams ¶ added in v0.15.0
type Difference ¶
type Difference struct { Entry // Partially filled. Type DifferenceType `db:"diff_type"` }
func (Difference) String ¶
func (d Difference) String() string
type DifferenceType ¶
type DifferenceType int
const ( DifferenceTypeAdded DifferenceType = iota DifferenceTypeRemoved DifferenceTypeChanged DifferenceTypeConflict DifferenceTypeNone )
type Differences ¶
type Differences []Difference
func (Differences) CountByType ¶
func (d Differences) CountByType() map[DifferenceType]int
func (Differences) Equal ¶
func (d Differences) Equal(other Differences) bool
type DummyCache ¶
type DummyCache struct{}
func (*DummyCache) BranchID ¶
func (c *DummyCache) BranchID(repository string, branch string, setFn GetBranchIDFn) (int64, error)
func (*DummyCache) Repository ¶
func (c *DummyCache) Repository(repository string, setFn GetRepositoryFn) (*Repository, error)
func (*DummyCache) RepositoryID ¶
func (c *DummyCache) RepositoryID(repository string, setFn GetRepositoryIDFn) (int, error)
type EntryCataloger ¶
type EntryCataloger interface { // GetEntry returns the current entry for path in repository branch reference. Returns // the entry with ExpiredError if it has expired from underlying storage. GetEntry(ctx context.Context, repository, reference string, path string, params GetEntryParams) (*Entry, error) CreateEntry(ctx context.Context, repository, branch string, entry Entry, params CreateEntryParams) error CreateEntries(ctx context.Context, repository, branch string, entries []Entry) error DeleteEntry(ctx context.Context, repository, branch string, path string) error ListEntries(ctx context.Context, repository, reference string, prefix, after string, delimiter string, limit int) ([]*Entry, bool, error) ResetEntry(ctx context.Context, repository, branch string, path string) error ResetEntries(ctx context.Context, repository, branch string, prefix string) error // QueryEntriesToExpire returns ExpiryRows iterating over all objects to expire on // repositoryName according to policy. QueryEntriesToExpire(ctx context.Context, repositoryName string, policy *Policy) (ExpiryRows, error) // MarkEntriesExpired marks all entries identified by expire as expired. It is a batch operation. MarkEntriesExpired(ctx context.Context, repositoryName string, expireResults []*ExpireResult) error // MarkObjectsForDeletion marks objects in catalog_object_dedup as "deleting" if all // their entries are expired, and returns the new total number of objects marked (or an // error). These objects are not yet safe to delete: there could be a race between // marking objects as expired deduping newly-uploaded objects. See // DeleteOrUnmarkObjectsForDeletion for that actual deletion. MarkObjectsForDeletion(ctx context.Context, repositoryName string) (int64, error) // DeleteOrUnmarkObjectsForDeletion scans objects in catalog_object_dedup for objects // marked "deleting" and returns an iterator over physical addresses of those objects // all of whose referring entries are still expired. If called after MarkEntriesExpired // and MarkObjectsForDeletion this is safe, because no further entries can refer to // expired objects. It also removes the "deleting" mark from those objects that have an // entry _not_ marked as expiring and therefore were not on the returned rows. DeleteOrUnmarkObjectsForDeletion(ctx context.Context, repositoryName string) (StringRows, error) DedupReportChannel() chan *DedupReport }
type Expiration ¶
type Expiration struct { All *TimePeriodHours `json:",omitempty"` Uncommitted *TimePeriodHours `json:",omitempty"` Noncurrent *TimePeriodHours `json:",omitempty"` }
type ExpireResult ¶
type ExpiryRows ¶
type ExpiryRows interface { io.Closer Next() bool Err() error // Read returns the current from ExpiryRows, or an error on failure. Call it only after // successfully calling Next. Read() (*ExpireResult, error) }
ExpiryRows is a database iterator over ExpiryResults. Use Next to advance from row to row.
type ExportConfiguration ¶ added in v0.15.0
type ExportConfiguration struct { Path string `db:"export_path"` StatusPath string `db:"export_status_path"` LastKeysInPrefixRegexp pq.StringArray `db:"last_keys_in_prefix_regexp"` }
ExportConfiguration describes the export configuration of a branch, as passed on wire, used internally, and stored in DB.
type ExportConfigurationForBranch ¶ added in v0.15.0
type ExportConfigurationForBranch struct { Repository string `db:"repository"` Branch string `db:"branch"` Path string `db:"export_path"` StatusPath string `db:"export_status_path"` LastKeysInPrefixRegexp pq.StringArray `db:"last_keys_in_prefix_regexp"` }
ExportConfigurationForBranch describes how to export BranchID. It is stored in the database. Unfortunately golang sql doesn't know about embedded structs, so you get a useless copy of ExportConfiguration embedded here.
type ExportConfigurator ¶ added in v0.15.0
type ExportConfigurator interface { GetExportConfigurationForBranch(repository string, branch string) (ExportConfiguration, error) GetExportConfigurations() ([]ExportConfigurationForBranch, error) PutExportConfiguration(repository string, branch string, conf *ExportConfiguration) error }
type GetEntryParams ¶
type GetEntryParams struct { // For entries to expired objects the Expired bit is set. If true, GetEntry returns // successfully for expired entries, otherwise it returns the entry with ErrExpired. ReturnExpired bool }
GetEntryParams configures what entries GetEntry returns.
type GetRepositoryFn ¶
type GetRepositoryFn func(repository string) (*Repository, error)
type GetRepositoryIDFn ¶
type Hookser ¶ added in v0.15.0
type Hookser interface {
Hooks() *CatalogerHooks
}
type InternalObjectRef ¶
InternalObjectRef provides information that uniquely identifies an object between transactions. It might be invalidated by some database changes.
func ParseInternalObjectRef ¶
func ParseInternalObjectRef(refString string) (InternalObjectRef, error)
func (*InternalObjectRef) String ¶
func (sor *InternalObjectRef) String() string
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
func (*LRUCache) Repository ¶
func (c *LRUCache) Repository(repository string, setFn GetRepositoryFn) (*Repository, error)
func (*LRUCache) RepositoryID ¶
func (c *LRUCache) RepositoryID(repository string, setFn GetRepositoryIDFn) (int, error)
type MergeResult ¶
type MergeResult struct { Summary map[DifferenceType]int Reference string }
type MinMaxCommit ¶ added in v0.13.0
type MinMaxCommit struct { MinCommit CommitID `db:"min_commit"` MaxCommit CommitID `db:"max_commit"` }
func (MinMaxCommit) ChangedAfterCommit ¶ added in v0.13.0
func (m MinMaxCommit) ChangedAfterCommit(commitID CommitID) bool
func (MinMaxCommit) IsCommitted ¶ added in v0.13.0
func (m MinMaxCommit) IsCommitted() bool
func (MinMaxCommit) IsDeleted ¶ added in v0.13.0
func (m MinMaxCommit) IsDeleted() bool
func (MinMaxCommit) IsTombstone ¶ added in v0.13.0
func (m MinMaxCommit) IsTombstone() bool
type MultipartUpdateCataloger ¶
type MultipartUpdateCataloger interface { CreateMultipartUpload(ctx context.Context, repository, uploadID, path, physicalAddress string, creationTime time.Time) error GetMultipartUpload(ctx context.Context, repository, uploadID string) (*MultipartUpload, error) DeleteMultipartUpload(ctx context.Context, repository, uploadID string) error }
type MultipartUpload ¶
type PolicyWithCreationTime ¶
type RelationType ¶
type RelationType string
const ( RelationTypeNone RelationType = "none" RelationTypeFromParent RelationType = "from_parent" RelationTypeFromChild RelationType = "from_child" RelationTypeNotDirect RelationType = "non_direct" RelationTypeSame RelationType = "same" )
type Repository ¶
type RepositoryCataloger ¶
type RepositoryCataloger interface { CreateRepository(ctx context.Context, repository string, storageNamespace string, branch string) (*Repository, error) GetRepository(ctx context.Context, repository string) (*Repository, error) DeleteRepository(ctx context.Context, repository string) error ListRepositories(ctx context.Context, limit int, after string) ([]*Repository, bool, error) }
type Rule ¶
type Rule struct { Enabled bool FilterPrefix string `json:",omitempty"` Expiration Expiration }
type RulesHolder ¶
type RulesHolder struct {
Rules Rules
}
RulesHolder is a dummy struct for helping pg serialization: it has poor support for passing an array-valued parameter.
type StringRows ¶ added in v0.9.0
type StringRows struct {
// contains filtered or unexported fields
}
func (*StringRows) Close ¶ added in v0.9.0
func (s *StringRows) Close() error
func (*StringRows) Err ¶ added in v0.9.0
func (s *StringRows) Err() error
func (*StringRows) Next ¶ added in v0.9.0
func (s *StringRows) Next() bool
func (*StringRows) Read ¶ added in v0.9.0
func (s *StringRows) Read() (string, error)
type TimePeriodHours ¶
type TimePeriodHours int
Avoid rounding by keeping whole hours (not Durations)
type ValidateField ¶
type ValidateField struct { Name string IsValid ValidateFunc }
type ValidateFields ¶
type ValidateFields []ValidateField
type ValidateFunc ¶
type ValidateFunc func() bool
func ValidateBranchName ¶
func ValidateBranchName(branch string) ValidateFunc
func ValidateCommitMessage ¶
func ValidateCommitMessage(message string) ValidateFunc
func ValidateCommitter ¶
func ValidateCommitter(name string) ValidateFunc
func ValidateOptionalString ¶
func ValidateOptionalString(s string, validator func(string) bool) ValidateFunc
func ValidatePath ¶
func ValidatePath(name string) ValidateFunc
func ValidatePhysicalAddress ¶
func ValidatePhysicalAddress(addr string) ValidateFunc
func ValidateReference ¶
func ValidateReference(reference string) ValidateFunc
func ValidateRepositoryName ¶
func ValidateRepositoryName(repository string) ValidateFunc
func ValidateStorageNamespace ¶
func ValidateStorageNamespace(storageNamespace string) ValidateFunc
func ValidateUploadID ¶
func ValidateUploadID(uploadID string) ValidateFunc
Source Files ¶
- cache.go
- cataloger.go
- cataloger_cache.go
- cataloger_commit.go
- cataloger_create_branch.go
- cataloger_create_entries.go
- cataloger_create_entry.go
- cataloger_create_multipart_upload.go
- cataloger_create_repository.go
- cataloger_delete_branch.go
- cataloger_delete_entry.go
- cataloger_delete_multipart_upload.go
- cataloger_delete_repository.go
- cataloger_diff.go
- cataloger_diff_uncommitted.go
- cataloger_export.go
- cataloger_get_branch_reference.go
- cataloger_get_commit.go
- cataloger_get_entry.go
- cataloger_get_multipart_upload.go
- cataloger_get_repository.go
- cataloger_is_branch_exists.go
- cataloger_list_branches.go
- cataloger_list_commits.go
- cataloger_list_entries.go
- cataloger_list_repositories.go
- cataloger_merge.go
- cataloger_reset_branch.go
- cataloger_reset_entries.go
- cataloger_reset_entry.go
- cataloger_retention.go
- cataloger_rollback_commit.go
- db.go
- db_batch_entry_read.go
- db_branch_scanner.go
- db_lineage_scanner.go
- db_read_entry.go
- db_scanner.go
- diff.go
- errors.go
- model.go
- ref.go
- relation_type.go
- stats.go
- validate.go
- views.go