MCPcopy
hub / github.com/apache/casbin / Transaction

Struct Transaction

transaction.go:35–46  ·  view source on GitHub ↗

Transaction represents a Casbin transaction. It provides methods to perform policy operations within a transaction. and commit or rollback all changes atomically.

Source from the content-addressed store, hash-verified

33// It provides methods to perform policy operations within a transaction.
34// and commit or rollback all changes atomically.
35type Transaction struct {
36 id string // Unique transaction identifier.
37 enforcer *TransactionalEnforcer // Reference to the transactional enforcer.
38 buffer *TransactionBuffer // Buffer for policy operations.
39 txContext persist.TransactionContext // Database transaction context.
40 ctx context.Context // Context for the transaction.
41 baseVersion int64 // Model version at transaction start.
42 committed bool // Whether the transaction has been committed.
43 rolledBack bool // Whether the transaction has been rolled back.
44 startTime time.Time // Transaction start timestamp.
45 mutex sync.RWMutex // Protects transaction state.
46}
47
48// AddPolicy adds a policy within the transaction.
49// The policy is buffered and will be applied when the transaction is committed.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected