Git Product home page Git Product logo

Comments (1)

AliasAPI avatar AliasAPI commented on July 16, 2024

// This is one way to check for errors and skip to the end of a pipeline during processing . . .

// Create the Pipeline
$pipeline = (new Pipeline(
// Set the processor to InterruptibleProcessor (instead of FingersCrossed)
new InterruptibleProcessor(
// Create a class GetOkay->__invoke() that calls $payload->getOkay()
// Pass GetOkay into InterruptibleProcessor so it knows where to check.
new GetOkay
)
))
// Create a Payload class with setOkay(), getOkay(), and a private property $okay
// Note: Line 25 InterruptibleProcessor is " if (true !== $check($payload)) { "
->pipe(new CreatePayload)
// Create a CheckBeforeFirstAction class to update $payload->setOkay() as needed.
// This class can check to make sure all requirements are OK to run FirstAction.
// Tip: Every class in the pipeline should (modify and) return the $payload object.
->pipe(new CheckBeforeFirstAction)
// CheckBeforeFirstAction(Payload $payload) returns the $payload object.
// The InterruptibleProcessor will check for an error using GetOkay->_invoke()
// If $payload->okay is still set to true the FirstAction will run
->pipe(new FirstAction)
// Create a CheckBeforeSecondAction class to $payload->setOkay() as needed.
->pipe(new CheckBeforeSecondAction)
// Set $payload->setOkay('false') inside CheckBeforeSecondAction as a test.
// The InterruptibleProcessor will check for an error using GetOkay->_invoke()
// The SecondAction will NOT be run since $payload->okay = false.
->pipe(new SecondAction);
// The $payload will be returned from InterruptibleProcessor.

// wowcut: Set a property in the $payload to specify which stages should run.
// I don't think you will reduce the if-then-else, but you can hide them in Check classes

Thanks to creator and maintainer of the Pipeline!

Drew

from pipeline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.