Documentation
¶
Overview ¶
Package pfsdb contains the database schema that PFS uses.
Index ¶
- Constants
- Variables
- func AddCommit(tx *pachsql.Tx, commit *pfs.Commit) error
- func AddCommitProvenance(tx *pachsql.Tx, from, to *pfs.Commit) error
- func BranchKey(branch *pfs.Branch) string
- func Branches(db *pachsql.DB, listener col.PostgresListener) col.PostgresCollection
- func CommitKey(commit *pfs.Commit) string
- func CommitSetProvenance(tx *pachsql.Tx, id string) (_ []*pfs.Commit, retErr error)
- func CommitSetSubvenance(tx *pachsql.Tx, id string) (_ []*pfs.Commit, retErr error)
- func Commits(db *pachsql.DB, listener col.PostgresListener) col.PostgresCollection
- func CreateRepo(ctx context.Context, tx *pachsql.Tx, repo *pfs.RepoInfo) error
- func DeleteRepo(ctx context.Context, tx *pachsql.Tx, repoProject, repoName, repoType string) error
- func GetBranch(ctx context.Context, tx *pachsql.Tx, id BranchID) (*pfs.BranchInfo, error)
- func GetRepo(ctx context.Context, tx *pachsql.Tx, id RepoID) (*pfs.RepoInfo, error)
- func GetRepoByName(ctx context.Context, tx *pachsql.Tx, repoProject, repoName, repoType string) (*pfs.RepoInfo, error)
- func IsDuplicateKeyErr(err error) bool
- func IsErrRepoNotFound(err error) bool
- func ParseBranch(key string) *pfs.Branch
- func ParseCommit(key string) *pfs.Commit
- func ParseRepo(key string) *pfs.Repo
- func ProjectKey(project *pfs.Project) string
- func RepoKey(repo *pfs.Repo) string
- func ResolveCommitProvenance(tx *pachsql.Tx, repo *pfs.Repo, commitSet string) (*pfs.Commit, error)
- func UpdateRepo(ctx context.Context, tx *pachsql.Tx, id RepoID, repo *pfs.RepoInfo) error
- func UpsertRepo(ctx context.Context, tx *pachsql.Tx, repo *pfs.RepoInfo) error
- type Branch
- type BranchID
- type Commit
- type CommitID
- type CreatedAtUpdatedAt
- type ErrRepoAlreadyExists
- type ErrRepoNotFound
- type Repo
- type RepoFields
- type RepoID
- type RepoIterator
- type RepoListFilter
- type RepoPair
Constants ¶
const (
// ReposChannelName is used to watch events for the repos table.
ReposChannelName = "pfs_repos"
)
Variables ¶
var ( RepoTypes = RepoFields("type") RepoProjects = RepoFields("project_id") RepoNames = RepoFields("name") )
var BranchesRepoIndex = &col.Index{ Name: "repo", Extract: func(val proto.Message) string { return RepoKey(val.(*pfs.BranchInfo).Branch.Repo) }, }
var CommitsBranchlessIndex = &col.Index{ Name: "branchless", Extract: func(val proto.Message) string { return CommitKey(val.(*pfs.CommitInfo).Commit) }, }
var CommitsCommitSetIndex = &col.Index{ Name: "commitset", Extract: func(val proto.Message) string { return val.(*pfs.CommitInfo).Commit.Id }, }
var CommitsRepoIndex = &col.Index{ Name: "repo", Extract: func(val proto.Message) string { return RepoKey(val.(*pfs.CommitInfo).Commit.Repo) }, }
Functions ¶
func Branches ¶
func Branches(db *pachsql.DB, listener col.PostgresListener) col.PostgresCollection
Branches returns a collection of branches
func CommitSetProvenance ¶
CommitSetProvenance returns all the commit IDs that are in the provenance of all the commits in this commit set.
TODO(provenance): is 'SELECT DISTINCT commit_id' a performance concern?
func CommitSetSubvenance ¶
CommitSetSubvenance returns all the commit IDs that contain commits in this commit set in their full (transitive) provenance
func Commits ¶
func Commits(db *pachsql.DB, listener col.PostgresListener) col.PostgresCollection
Commits returns a collection of commits
func CreateRepo ¶
CreateRepo creates an entry in the pfs.repos table.
func DeleteRepo ¶ added in v2.8.0
DeleteRepo deletes an entry in the pfs.repos table.
func GetRepo ¶ added in v2.8.0
todo(fahad): rewrite branch related code during the branches migration. GetRepo retrieves an entry from the pfs.repos table by using the row id.
func GetRepoByName ¶ added in v2.8.0
func GetRepoByName(ctx context.Context, tx *pachsql.Tx, repoProject, repoName, repoType string) (*pfs.RepoInfo, error)
GetRepoByName retrieves an entry from the pfs.repos table by project, repo name, and type.
func IsDuplicateKeyErr ¶ added in v2.8.0
func IsErrRepoNotFound ¶ added in v2.8.0
func ParseBranch ¶ added in v2.6.6
func ParseCommit ¶
func ProjectKey ¶
func ResolveCommitProvenance ¶
returns the commit of a certain repo in a commit set.
func UpdateRepo ¶
UpdateRepo overwrites an existing repo entry by RepoID.
Types ¶
type Branch ¶ added in v2.8.0
type Branch struct { ID BranchID `db:"id"` Head Commit `db:"head"` Repo Repo `db:"repo"` Name string `db:"name"` CreatedAtUpdatedAt }
Branch is a row in the pfs.branches table.
type BranchID ¶ added in v2.8.0
type BranchID uint64
BranchID is the row id for a branch entry in postgres.
func UpsertBranch ¶ added in v2.8.0
func UpsertBranch(ctx context.Context, tx *pachsql.Tx, branchInfo *pfs.BranchInfo) (BranchID, error)
UpsertBranch creates a branch if it does not exist, or updates the head commit if it does.
type Commit ¶ added in v2.8.0
type Commit struct { ID CommitID `db:"id"` Repo Repo `db:"repo"` CommitSetID string `db:"commit_set_id"` CreatedAtUpdatedAt }
Commit is a row in the pfs.commits table.
type CommitID ¶ added in v2.8.0
type CommitID uint64
CommitID is the row id for a commit entry in postgres.
type CreatedAtUpdatedAt ¶ added in v2.8.0
type ErrRepoAlreadyExists ¶
ErrRepoAlreadyExists is returned by CreateRepo() when a repo with the same name already exists in postgres.
func (ErrRepoAlreadyExists) Error ¶
func (err ErrRepoAlreadyExists) Error() string
Error satisfies the error interface.
func (ErrRepoAlreadyExists) GRPCStatus ¶
func (err ErrRepoAlreadyExists) GRPCStatus() *status.Status
type ErrRepoNotFound ¶
ErrRepoNotFound is returned by GetRepo() when a repo is not found in postgres.
func (ErrRepoNotFound) Error ¶
func (err ErrRepoNotFound) Error() string
Error satisfies the error interface.
func (ErrRepoNotFound) GRPCStatus ¶
func (err ErrRepoNotFound) GRPCStatus() *status.Status
type Repo ¶ added in v2.8.0
type Repo struct { ID RepoID `db:"id"` Project coredb.Project `db:"project"` Name string `db:"name"` Description string `db:"description"` Type string `db:"type"` CreatedAtUpdatedAt }
Repo is a row in the pfs.repos table.
type RepoFields ¶
type RepoFields string
RepoFields is used in the ListRepoFilter and defines specific field names for type safety. This should hopefully prevent a library user from misconfiguring the filter.
type RepoID ¶ added in v2.8.0
type RepoID uint64
RepoID is the row id for a repo entry in postgres. A separate type is defined for safety so row ids must be explicitly cast for use in another table.
type RepoIterator ¶ added in v2.8.0
type RepoIterator struct {
// contains filtered or unexported fields
}
RepoIterator batches a page of repoRow entries. Entries can be retrieved using iter.Next().
func ListRepo ¶ added in v2.8.0
func ListRepo(ctx context.Context, tx *pachsql.Tx, filter RepoListFilter) (*RepoIterator, error)
ListRepo returns a RepoIterator that exposes a Next() function for retrieving *pfs.RepoInfo references.
type RepoListFilter ¶
type RepoListFilter map[RepoFields][]string
RepoListFilter is a filter for listing repos. It ANDs together separate keys, but ORs together the key values: where repo.<key_1> IN (<key_1:value_1>, <key_2:value_2>, ...) AND repo.<key_2> IN (<key_2:value_1>,<key_2:value_2>,...)