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

Thread through the transaction #50

Merged
merged 1 commit into from
Feb 27, 2019

Conversation

SimonRichardson
Copy link
Member

The following changes are formalising a discussion[1] from a previous
PR #48, where it might make more sense to pass the ObservedTransaction
through.

There are a couple of things to note:

  1. I renamed ObservedTransaction to Transaction, as it no longer
    observes the transaction, it's actually used when calling the
    runner. With this in mind I renamed it as it made more sense.
  2. I left the ObservedTransaction as value object rather than a
    pointer when it is passed to runTransactionObserver so that it
    implies immutability (even though you can modify the Ops etc).

Copy link
Member

@jameinel jameinel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's pull in the test change from https://github.com/juju/txn/pull/53/files

@achilleasa achilleasa force-pushed the interface-transaction-change branch from 742c084 to ede9ccc Compare February 27, 2019 13:49
txn.go Outdated
// Treat this the same as ErrNoOperations but don't suppress other errors.
return nil
}
if err := tr.RunTransaction(ops); err == nil {
t.Attempt = i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this might be easier to read, and harder to make a mistake if the Transaction wasn't created until here, as just:
t := Transaction{
Ops: ops,
Attempt: i,
}

And we leave the local vars 'ops' and 'err'.

That way there isn't any chance to accidentally still refer to the old ops in the next trip around the loop.

The following changes are formalising a discussion[1] from a previous
PR juju#48, where it might make more sense to pass the ObservedTransaction
through.

There are a couple of things to note:

 1. I renamed ObservedTransaction to Transaction, as it no longer
 observes the transaction, it's actually used when calling the
 runner. With this in mind I renamed it as it made more sense.
 2. I left the ObservedTransaction as value object rather than a
 pointer when it is passed to runTransactionObserver so that it
 implies immutability (even though you can modify the Ops etc).

 - 1 juju#48 (comment)
@achilleasa achilleasa force-pushed the interface-transaction-change branch from ede9ccc to 3575e81 Compare February 27, 2019 14:25
@achilleasa achilleasa force-pushed the interface-transaction-change branch from 3575e81 to 805c94f Compare February 27, 2019 14:29
@achilleasa
Copy link

$$merge$$

@jujubot jujubot merged commit 90cbb53 into juju:master Feb 27, 2019
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.

4 participants