Documentation ¶
Overview ¶
Package transactionenv needs to be documented.
TODO: document
Index ¶
- type AuthBackend
- type AuthWrites
- type PFSBackend
- type PPSBackend
- type PfsWrites
- type PpsWrites
- type Transaction
- type TransactionEnv
- func (tnxEnv *TransactionEnv) Initialize(db *sqlx.DB, getAuth func() AuthBackend, getPFS func() PFSBackend, ...)
- func (env *TransactionEnv) PreTxOps(ctx context.Context, reqs []*transaction.TransactionRequest) error
- func (env *TransactionEnv) WithReadContext(ctx context.Context, ...) error
- func (env *TransactionEnv) WithTransaction(ctx context.Context, cb func(Transaction) error) error
- func (env *TransactionEnv) WithWriteContext(ctx context.Context, ...) error
- type TransactionServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthBackend ¶ added in v2.8.0
type AuthBackend interface { ModifyRoleBindingInTransaction(context.Context, *txncontext.TransactionContext, *auth.ModifyRoleBindingRequest) (*auth.ModifyRoleBindingResponse, error) DeleteRoleBindingInTransaction(context.Context, *txncontext.TransactionContext, *auth.Resource) error WhoAmI(context.Context, *auth.WhoAmIRequest) (*auth.WhoAmIResponse, error) }
type AuthWrites ¶
type AuthWrites interface { ModifyRoleBinding(*auth.ModifyRoleBindingRequest) (*auth.ModifyRoleBindingResponse, error) DeleteRoleBinding(*auth.Resource) error }
AuthWrites is an interface providing a wrapper for each operation that may be appended to a transaction through the Auth server. Each call may either directly run the request through Auth or append it to the active transaction, depending on if there is an active transaction in the client context.
type PFSBackend ¶ added in v2.8.0
type PFSBackend interface { NewPropagater(*txncontext.TransactionContext) txncontext.PfsPropagater NewRepoValidator(*txncontext.TransactionContext) txncontext.PfsRepoValidator CreateRepoInTransaction(context.Context, *txncontext.TransactionContext, *pfs.CreateRepoRequest) error DeleteRepoInTransaction(context.Context, *txncontext.TransactionContext, *pfs.DeleteRepoRequest) (bool, error) StartCommitInTransaction(context.Context, *txncontext.TransactionContext, *pfs.StartCommitRequest) (*pfs.Commit, error) FinishCommitInTransaction(context.Context, *txncontext.TransactionContext, *pfs.FinishCommitRequest) error SquashCommitSetInTransaction(context.Context, *txncontext.TransactionContext, *pfs.SquashCommitSetRequest) error CreateBranchInTransaction(context.Context, *txncontext.TransactionContext, *pfs.CreateBranchRequest) error DeleteBranchInTransaction(context.Context, *txncontext.TransactionContext, *pfs.DeleteBranchRequest) error }
type PPSBackend ¶ added in v2.8.0
type PPSBackend interface { NewPropagater(*txncontext.TransactionContext) txncontext.PpsPropagater NewJobStopper(*txncontext.TransactionContext) txncontext.PpsJobStopper NewJobFinisher(*txncontext.TransactionContext) txncontext.PpsJobFinisher StopJobInTransaction(context.Context, *txncontext.TransactionContext, *pps.StopJobRequest) error UpdateJobStateInTransaction(context.Context, *txncontext.TransactionContext, *pps.UpdateJobStateRequest) error CreatePipelineInTransaction(context.Context, *txncontext.TransactionContext, *pps.CreatePipelineTransaction) error CreateDetPipelineSideEffects(context.Context, *pps.Pipeline, []string) error }
type PfsWrites ¶
type PfsWrites interface { CreateRepo(*pfs.CreateRepoRequest) error DeleteRepo(*pfs.DeleteRepoRequest) (bool, error) StartCommit(*pfs.StartCommitRequest) (*pfs.Commit, error) FinishCommit(*pfs.FinishCommitRequest) error SquashCommitSet(*pfs.SquashCommitSetRequest) error CreateBranch(*pfs.CreateBranchRequest) error DeleteBranch(*pfs.DeleteBranchRequest) error }
PfsWrites is an interface providing a wrapper for each operation that may be appended to a transaction through PFS. Each call may either directly run the request through PFS or append it to the active transaction, depending on if there is an active transaction in the client context.
type PpsWrites ¶
type PpsWrites interface { StopJob(*pps.StopJobRequest) error UpdateJobState(*pps.UpdateJobStateRequest) error CreatePipeline(*pps.CreatePipelineTransaction) error }
PpsWrites is an interface providing a wrapper for each operation that may be appended to a transaction through PPS. Each call may either directly run the request through PPS or append it to the active transaction, depending on if there is an active transaction in the client context.
type Transaction ¶
type Transaction interface { PfsWrites PpsWrites AuthWrites }
Transaction is an interface to unify the code that may either perform an action directly or append an action to an existing transaction (depending on if there is an active transaction in the client context metadata). There are two implementations of this interface:
directTransaction: all operations will be run directly through the relevant server, all inside the same STM. appendTransaction: all operations will be appended to the active transaction which will then be dryrun so that the response for the operation can be returned. Each operation that is appended will do a new dryrun, so this isn't as efficient as it could be.
func NewDirectTransaction ¶
func NewDirectTransaction(ctx context.Context, txnEnv *TransactionEnv, txnCtx *txncontext.TransactionContext) Transaction
NewDirectTransaction is a helper function to instantiate a directTransaction object. It is exposed so that the transaction API server can run a direct transaction even though there is an active transaction in the context (which is why it cannot use `WithTransaction`).
type TransactionEnv ¶
type TransactionEnv struct {
// contains filtered or unexported fields
}
TransactionEnv contains the APIServer instances for each subsystem that may be involved in running transactions so that they can make calls to each other without leaving the context of a transaction. This is a separate object because there are cyclic dependencies between APIServer instances.
func New ¶
func New() *TransactionEnv
func (*TransactionEnv) Initialize ¶
func (tnxEnv *TransactionEnv) Initialize( db *sqlx.DB, getAuth func() AuthBackend, getPFS func() PFSBackend, getPPS func() PPSBackend, txnServer TransactionServer, )
Initialize stores the references to APIServer instances in the TransactionEnv
func (*TransactionEnv) PreTxOps ¶ added in v2.7.0
func (env *TransactionEnv) PreTxOps(ctx context.Context, reqs []*transaction.TransactionRequest) error
PreTxOps defines what operations to run related to the transaction, but before the physical database transaction is opened. If doing any I/O as a part of a transaction is necessary, this is the place for it.
NOTES: - PreTxOps may be called multiple times for a Pachyderm Transaction and should therefore be idempotent - in most cases some background job will also be necessary to cleanup resources created here
func (*TransactionEnv) WithReadContext ¶
func (env *TransactionEnv) WithReadContext(ctx context.Context, cb func(ctx context.Context, txnCtx *txncontext.TransactionContext) error) error
WithReadContext will call the given callback with a txncontext.TransactionContext which can be used to perform reads of the current cluster state. If the transaction is used to perform any writes, they will be silently discarded.
func (*TransactionEnv) WithTransaction ¶
func (env *TransactionEnv) WithTransaction(ctx context.Context, cb func(Transaction) error) error
WithTransaction will call the given callback with a txnenv.Transaction object, which is instantiated differently based on if an active transaction is present in the RPC context. If an active transaction is present, any calls into the Transaction are first dry-run then appended to the transaction. If there is no active transaction, the request will be run directly through the selected server.
func (*TransactionEnv) WithWriteContext ¶
func (env *TransactionEnv) WithWriteContext(ctx context.Context, cb func(ctx context.Context, txnCtx *txncontext.TransactionContext) error) error
WithWriteContext will call the given callback with a txncontext.TransactionContext which can be used to perform reads and writes on the current cluster state.
type TransactionServer ¶
type TransactionServer interface { AppendRequest( context.Context, *transaction.Transaction, *transaction.TransactionRequest, ) (*transaction.TransactionResponse, error) }
TransactionServer is an interface used by other servers to append a request to an existing transaction.
Directories ¶
Path | Synopsis |
---|---|
Package txncontext implements a transaction context.
|
Package txncontext implements a transaction context. |