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 CatalogerOption
- type CommitID
- type CommitLog
- type Committer
- type CreateEntryParams
- type DedupParams
- type DedupReport
- type Differ
- type Difference
- type DifferenceType
- type Differences
- type DummyCache
- type Entry
- type EntryCataloger
- type Expiration
- type ExpireResult
- type ExpiryRows
- type GetBranchIDFn
- type GetEntryParams
- type GetRepositoryFn
- type GetRepositoryIDFn
- type InternalObjectRef
- type LRUCache
- type LockType
- type MergeResult
- type Merger
- type Metadata
- 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 ¶
View Source
const ( CatalogerCommitter = "" DefaultPathDelimiter = "/" MaxReadQueue = 10 )
View Source
const ( ListEntriesMaxLimit = 1000 ListEntriesBranchBatchSize = 32 )
View Source
const ( CommittedID CommitID = -1 UncommittedID CommitID = 0 MaxCommitID CommitID = 1_000_000_000_000_000_000 CommittedSuffix = ":HEAD" CommitPrefix = "~" InternalObjectRefSeparator = "$" InternalObjectRefFormat = "int:pbm:%s" InternalObjectRefParts = 3 )
View Source
const ( DirectoryTerminationValue = utf8.MaxRune DirectoryTermination = string(rune(DirectoryTerminationValue)) )
View Source
const (
DiffMaxLimit = 1000
)
View Source
const ListBranchesMaxLimit = 10000
View Source
const ListCommitsMaxLimit = 10000
View Source
const ListRepositoriesMaxLimit = 10000
Variables ¶
View Source
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") )
View Source
var ErrExpired = errors.New("expired from storage")
View Source
var (
ErrInvalidValue = errors.New("invalid value")
)
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 io.Closer }
func NewCataloger ¶
func NewCataloger(db db.Database, options ...CatalogerOption) Cataloger
type CatalogerOption ¶
type CatalogerOption func(*cataloger)
func WithCacheEnabled ¶ added in v0.10.0
func WithCacheEnabled(b bool) CatalogerOption
func WithClock ¶
func WithClock(newClock clock.Clock) 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 DedupParams ¶
type DedupReport ¶
type Difference ¶
type Difference struct { Type DifferenceType `db:"diff_type"` Path string `db:"path"` }
func (Difference) String ¶
func (d Difference) String() string
type DifferenceType ¶
type DifferenceType int
const ( DifferenceTypeAdded DifferenceType = iota DifferenceTypeRemoved DifferenceTypeChanged DifferenceTypeConflict )
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 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 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 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" )
type Repository ¶
type RepositoryCataloger ¶
type RepositoryCataloger interface { CreateRepository(ctx context.Context, repository string, storageNamespace string, branch string) 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_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
- diff.go
- errors.go
- model.go
- ref.go
- relation_type.go
- stats.go
- validate.go
- views.go
Click to show internal directories.
Click to hide internal directories.