Transaction represents a Casbin transaction. It provides methods to perform policy operations within a transaction. and commit or rollback all changes atomically.
| 33 | // It provides methods to perform policy operations within a transaction. |
| 34 | // and commit or rollback all changes atomically. |
| 35 | type 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. |
nothing calls this directly
no outgoing calls
no test coverage detected