txncontext

package
v2.11.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PfsPropagater

type PfsPropagater interface {
	PropagateBranch(branch *pfs.Branch) error
	DeleteBranch(branch *pfs.Branch)
	Run(context.Context) error
}

PfsPropagater is the interface that PFS implements to propagate commits at the end of a transaction. It is defined here to avoid a circular dependency.

type PfsRepoValidator added in v2.11.0

type PfsRepoValidator interface {
	ValidateRepo(repo *pfs.Repo) error
	Run(context.Context) error
}

PfsRepoValidator is the interface that PFS implements to check branches at the end of a transaction. It is defined here to avoid a circular dependency.

type PpsJobFinisher

type PpsJobFinisher interface {
	FinishJob(commitInfo *pfs.CommitInfo)
	Run(context.Context) error
}

type PpsJobStopper

type PpsJobStopper interface {
	StopJobSet(commitset *pfs.CommitSet)
	StopJob(commit *pfs.Commit)
	Run(context.Context) error
}

PpsJobStopper is the interface that PPS implements to stop jobs of deleted commitsets at the end of a transaction. It is defined here to avoid a circular dependency.

type PpsPropagater

type PpsPropagater interface {
	PropagateJobs()
	Run(context.Context) error
}

PpsPropagater is the interface that PPS implements to start jobs at the end of a transaction. It is defined here to avoid a circular dependency.

type TransactionContext

type TransactionContext struct {

	// SqlTx is the ongoing database transaction.
	SqlTx *pachsql.Tx
	// CommitSetID is the ID of the CommitSet corresponding to PFS changes in this transaction.
	CommitSetID string
	// Timestamp is the canonical timestamp to be used for writes in this transaction.
	Timestamp *timestamppb.Timestamp
	// PfsPropagater applies commits at the end of the transaction.
	PfsPropagater    PfsPropagater
	PfsRepoValidator PfsRepoValidator
	// PpsPropagater starts Jobs in any pipelines that have new output commits at the end of the transaction.
	PpsPropagater PpsPropagater
	// PpsJobStopper stops Jobs in any pipelines that are associated with a removed commitset
	PpsJobStopper  PpsJobStopper
	PpsJobFinisher PpsJobFinisher

	// We rely on listener events to determine whether or not auth is activated, but this is
	// problematic when activating auth in a transaction.  The cache isn't updated because the
	// transaction hasn't committed, but this transaction should assume that auth IS activated,
	// because it will be when the transaction commits.  (If it rolls back, fine; inside the
	// transaction, auth was on!) The reason we rely on caching the listener events is because
	// pretty much every RPC in Pachyderm calls "auth.isActiveInTransaction", and the
	// performance overhead of going to the database to determine this is too high.
	//
	// This variable is set to true when auth is successfully enabled in this transaction, and
	// is checked by isActiveInTransaction.  Other transactions cannot observe this uncommitted
	// state.
	AuthBeingActivated atomic.Bool
	// contains filtered or unexported fields
}

TransactionContext is a helper type to encapsulate the state for a given set of operations being performed in the Pachyderm API. When a new transaction is started, a context will be created for it containing these objects, which will be threaded through to every API call:

func New

func New(ctx context.Context, sqlTx *pachsql.Tx, authServer identifier) (*TransactionContext, error)

func (*TransactionContext) DeleteBranch

func (t *TransactionContext) DeleteBranch(branch *pfs.Branch)

DeleteBranch removes a branch from the list of branches to propagate, if it is present.

func (*TransactionContext) Finish

func (t *TransactionContext) Finish(ctx context.Context) error

Finish applies the deferred logic in the pfsPropagator and ppsPropagator to the transaction

func (*TransactionContext) FinishJob

func (t *TransactionContext) FinishJob(commitInfo *pfs.CommitInfo)

func (*TransactionContext) PropagateBranch

func (t *TransactionContext) PropagateBranch(branch *pfs.Branch) error

PropagateBranch saves a branch to be propagated at the end of the transaction (if all operations complete successfully). This is used to batch together propagations and dedupe downstream commits in PFS.

func (*TransactionContext) PropagateJobs

func (t *TransactionContext) PropagateJobs()

PropagateJobs notifies PPS that there are new commits in the transaction's commitset that need jobs to be created at the end of the transaction transaction (if all operations complete successfully).

func (*TransactionContext) StopJob added in v2.8.0

func (t *TransactionContext) StopJob(commit *pfs.Commit)

StopJob notifies PPS that a commit has been removed and the job associated with it should be stopped.

func (*TransactionContext) StopJobSet added in v2.8.0

func (t *TransactionContext) StopJobSet(commitset *pfs.CommitSet)

StopJobSet notifies PPS that a commitset has been removed and the jobs associated with it should be stopped.

func (*TransactionContext) Username added in v2.11.0

func (t *TransactionContext) Username() string

Username returns the current user, returning the empty string if auth is disabled.

func (*TransactionContext) ValidateRepo added in v2.11.0

func (t *TransactionContext) ValidateRepo(repo *pfs.Repo) error

func (*TransactionContext) WhoAmI

func (t *TransactionContext) WhoAmI() (*auth.WhoAmIResponse, error)

Jump to

Keyboard shortcuts

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