Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transaction-is-ended): add IsEnded() method (#995) #998

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

frknikiz
Copy link

@frknikiz frknikiz commented Feb 1, 2025

Links

Details

This pull request introduces a new IsEnded() method for the Transaction type. It addresses the issue raised in #995 where there was no straightforward way to determine if a transaction has ended.

Changes include:

  • New Method Implementation:
    The IsEnded() method has been added to check the internal transaction state. It ensures that a transaction is considered ended if it is nil, if its thread is nil, or if the underlying transaction's finished flag is set.

    func (t *Transaction) IsEnded() bool {
        if t == nil || t.thread == nil || t.thread.txn == nil {
            return true
        }
        return t.thread.txn.finished
    }
    
  • Unit Tests:

    Unit tests have been added to verify that:

    • A nil Transaction returns true for IsEnded().
    • A Transaction with a nil thread or nil txn returns true.
    • An active transaction returns false.
    • A finished transaction returns true.

These changes ensure robust transaction state checking across different scenarios.
Closes #995.

@CLAassistant
Copy link

CLAassistant commented Feb 1, 2025

CLA assistant check
All committers have signed the CLA.

@frknikiz frknikiz changed the base branch from master to develop February 1, 2025 19:34
@frknikiz frknikiz force-pushed the transaction-is-ended branch from 49b889a to 544fb31 Compare February 1, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to check if a transaction has ended
2 participants