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

Named rollbacks #197

Closed
Enchufa2 opened this issue Jul 18, 2019 · 7 comments · Fixed by #287
Closed

Named rollbacks #197

Enchufa2 opened this issue Jul 18, 2019 · 7 comments · Fixed by #287

Comments

@Enchufa2
Copy link
Member

Enchufa2 commented Jul 18, 2019

Current rollbacks (based on number of activities) are not ideal for prototyping, because they require an adjustment every time the user adds or removes an activity. This is even trickier when the trajectory is split into several pieces, or there are branches, etc.

It would be convenient to have some mechanism to label a point in a trajectory and then reference it by name. E.g.,

trajectory() %>%
  timeout(1) %>%
  rollback_point("foo") %>%
  timeout(2) %>%
  timeout(3) %>%
  rollback("foo")

would be equivalent to

trajectory() %>%
  timeout(1) %>%
  timeout(2) %>%
  timeout(3) %>%
  rollback(2)
@Enchufa2
Copy link
Member Author

@Enchufa2
Copy link
Member Author

Hi, @bart6114, I would like your input here. I think that the best way to implement this feature at a low level is to add an optional tag or label to activities that the rollback can read to set the target, and I wonder what's the best way to expose this. The one above is clear enough, but invites to think that rollback_point is yet another activity, and thus that the trajectories above are not exactly equivalent (length 5 and 4 respectively, which e.g. has implications for length-based rollbacks).

I'm considering other options such as

trajectory() %>%
  timeout(1) %>%
  tag(timeout, "foo")(2) %>%
  timeout(3) %>%
  rollback("foo")

i.e. a labelling function that takes the generic and the tag and returns a closure that does the job, and its possible variations: maybe tag("foo", timeout) instead, or a shorter function name such as .(timeout, "foo"), etc.

Another option would be to extend the signature of all activities to include an optional tag. For example, now we have timeout(.trj, task), which could become timeout(.trj, task, ..., tag), and then we could do the following:

trajectory() %>%
  timeout(1) %>%
  timeout(2, tag="foo") %>%
  timeout(3) %>%
  rollback("foo")

What do you think? Any other options?

@Enchufa2
Copy link
Member Author

Another idea:

trajectory() %>%
  timeout(1) %>%
  tag("foo")$timeout(2) %>%
  timeout(3) %>%
  rollback("foo")

which is easier to add to an existing trajectory and to move it around. @thigger your feedback is welcome too. :)

@Enchufa2
Copy link
Member Author

This last idea can be tested in the feature/rollback_tag branch.

@Enchufa2
Copy link
Member Author

Another option would be to extend the signature of all activities to include an optional tag. For example, now we have timeout(.trj, task), which could become timeout(.trj, task, ..., tag), and then we could do the following:

trajectory() %>%
  timeout(1) %>%
  timeout(2, tag="foo") %>%
  timeout(3) %>%
  rollback("foo")

This can be tested in the feature/rollback_tag_arg branch.

@Enchufa2
Copy link
Member Author

I think I'm gonna go with this last option.

@thigger
Copy link

thigger commented Aug 2, 2022

Apologies, been clinical and not keeping an eye - yes this is brilliant, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants