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

Track pipeline flow progress #160

Open
mensfeld opened this issue Jan 5, 2017 · 12 comments
Open

Track pipeline flow progress #160

mensfeld opened this issue Jan 5, 2017 · 12 comments
Milestone

Comments

@mensfeld
Copy link

mensfeld commented Jan 5, 2017

Case: I have a really simple policy: if anything goes wrong - raise an exception. I know I could handle this in the endpoint but for my case it is way more sufficient to do that here. The only thing that is missing is the information on the position: which step failed which means that to obtain that, I would have to put separate failure before each step.

Could we maybe track the position in the pipe, so in case of failure we know when the track was switched? I believe it would help a lot.

module Repositories
  class Update < Create
    contract Contracts::Create

    step Containers::Model::Find(Repository)
    step Containers::Contract::Build()
    step Containers::Contract::Validate(key: :repository)
    step Containers::Contract::Persist()

    failure Containers::Error::Raise()
  end
end
@apotonick
Copy link
Member

This is planned, yes.

Why do you use exceptions? They are very hard to handle and take away flexibility you get from the pipe?

@mensfeld
Copy link
Author

mensfeld commented Jan 6, 2017

@apotonick I use exceptions because I don't want to handle them. I have a mission critical system that expects always to have a happy path and if anything goes wrong, it should raise an error.

@dnd
Copy link

dnd commented Jan 7, 2017

What does the structure of this data look like? Is it just the name of the step that switched from right to left results.failed_step?

Maybe the path that was taken as an array of arrays?

results.path =>
[
  [:right, 'operation.new'],
  [:right, 'contract.build'],
  [:right, 'validate'],
  [:left, 'model.save'],
  [:left, 'handle_failure']
]

@mensfeld
Copy link
Author

mensfeld commented Jan 7, 2017

@dnd that would be awesome :) - looks great!

@apotonick
Copy link
Member

Yeah, that looks good to me, even though we will have an unlimited number of tracks in the next version, so we might have to use something like

[
  Flow::Left, "contract.build",
...]

@apotonick
Copy link
Member

BTW, can I see some pseudo-code of how you'd use this on the outside, pleeheease?

@dnd
Copy link

dnd commented Jan 8, 2017

Technically Pipetree::Flow::Left I assume? What do you mean/foresee having unlimited tracks doing to this?

[
  [Pipetree::Flow::Left, ["contract.build", [
    [Pipetree::Flow::Right, "operation.new"],
    [Pipetree::Flow::Left, "contract.validate"]
  ]]]
]

This would fit it similarly with what I was proposing in the gitter chat about returning a pair, or a triple with the failed return. This could then ultimately return the value as well at the end of the failed track?

@mensfeld
Copy link
Author

mensfeld commented Jan 8, 2017

The question with multiple pipelines is: how then trbr is going to resolve that is success and what is not? 1 successful (right) and multiple left? How to switch them?

@apotonick
Copy link
Member

@mensfeld Very simple, Left subclasses are always not successful and vice-versa for Rights, which means they are good.

For now, I would suggest we only support an invisible third left track for the fail_early: true option, but in later versions we could document that, once we played with that a bit more?

@dnd
Copy link

dnd commented Jan 8, 2017

How does trailblazer/trailblazer-operation#6 play into the multiple tracks then? It's definitely not fail early, as it is supposed to leave the operation as a success. I suppose it could also apply to that issue for a desire to immediately fail an operation and do nothing else as well.

The distinction we need to make is, is early exit a special case, or is it a separate track(s)? That specific conversation is probably more relevant on the issue I posted above though.

@apotonick
Copy link
Member

"Fail early" is basically a hidden additional left track. "Early success" is the pendant on the right side! 😬

@apotonick apotonick added this to the 2.0.2 milestone Jan 20, 2017
@aldesantis
Copy link

aldesantis commented Jul 5, 2018

@mensfeld @apotonick I'm also very much interested in this, for pragmarb/pragma#24. Any updates or hints about how this could be accomplished? I feel like I'm not versed in the internals of TRB well enough to do this myself in a performant and idiomatic way.

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

No branches or pull requests

4 participants