diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 130cab05..d3a397ba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ GitHub. Then clone your fork: ```bash -$ git clone git@github.com:darkwood-fr/railway-fbp.git +$ git clone git@github.com:darkwood-fr/flow.git $ git checkout -b bug-or-feature-description ``` diff --git a/LICENSE b/LICENSE index 2d1a4f3b..52ca9e78 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 Mathieu Ledru +Copyright (c) 2022 Mathieu Ledru Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 4073a507..9314f487 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@

- - Railway Flow Based Programming + + Flow

## Why ? -Railway Flow Based Programming concept aims to solve +Flow concept aims to solve - Adopt asynchronous as native implementation - Build your code with functional programming and monads @@ -14,19 +14,18 @@ Railway Flow Based Programming concept aims to solve ## Installation -PHP 8.1 is the minimal version to use _Railway Flow Based Programming_ is 8.1 +PHP 8.1 is the minimal version to use _Flow_ is 8.1 The recommended way to install it through [Composer](http://getcomposer.org/) and execute ```bash -composer require darkwood/railway-fbp +composer require darkwood/flow ``` ## Usage -A working script is available in the bundled `examples` directory +A working script is available in the bundled `examples` directory in `packages/php` -- in `packages/php` - Run Rail : `php examples/rail.php` +- Run Flow : `php examples/flow.php` - Start Server : `php examples/server.php` Start Client(s) : `php examples/client.php` @@ -34,8 +33,8 @@ Messaging part require to install [Docker](https://www.docker.com) and execute ` ## Documentation -[https://darkwood-fr.github.io/railway-fbp](https://darkwood-fr.github.io/railway-fbp) +[https://darkwood-fr.github.io/flow](https://darkwood-fr.github.io/flow) ## License -_Railway Flow Based Programming_ is released under the MIT License. +_Flow_ is released under the MIT License. diff --git a/bin/splitsh-deploy b/bin/splitsh-deploy index 8bc1524e..9d28b77b 100755 --- a/bin/splitsh-deploy +++ b/bin/splitsh-deploy @@ -18,8 +18,6 @@ function remote() git pull origin $CURRENT_BRANCH -remote php git@github.com:darkwood-fr/railway-fbp-php.git -remote symfony git@github.com:darkwood-fr/railway-fbp-symfony.git +remote php git@github.com:darkwood-fr/flow-php.git split 'packages/php' php -split 'packages/symfony' symfony diff --git a/bin/splitsh-release b/bin/splitsh-release index 18a04a82..a4ff850b 100755 --- a/bin/splitsh-release +++ b/bin/splitsh-release @@ -54,14 +54,14 @@ git push origin --tags bash bin/splitsh-deploy # Tag Components -for REMOTE in php symfony +for REMOTE in php do echo "" echo "" echo "Releasing $REMOTE"; - TMP_DIR="../railway-fbp-split" - REMOTE_URL="git@github.com:darkwood-fr/railway-fbp-$REMOTE.git" + TMP_DIR="../flow-split" + REMOTE_URL="git@github.com:darkwood-fr/flow-$REMOTE.git" rm -rf $TMP_DIR; mkdir $TMP_DIR; diff --git a/docs/config/_default/config.toml b/docs/config/_default/config.toml index 8600aa84..57a2037b 100644 --- a/docs/config/_default/config.toml +++ b/docs/config/_default/config.toml @@ -1,4 +1,4 @@ -baseurl = "https://darkwood-fr.github.io/railway-fbp/" +baseurl = "https://darkwood-fr.github.io/flow/" canonifyURLs = false disableAliases = true disableHugoGeneratorInject = true diff --git a/docs/config/_default/menus/menus.en.toml b/docs/config/_default/menus/menus.en.toml index 1613bac2..11ba580c 100644 --- a/docs/config/_default/menus/menus.en.toml +++ b/docs/config/_default/menus/menus.en.toml @@ -23,7 +23,7 @@ [[social]] name = "GitHub" pre = "" - url = "https://github.com/darkwood-fr/railway-fbp" + url = "https://github.com/darkwood-fr/flow" post = "v0.1.0" weight = 10 diff --git a/docs/config/_default/params.toml b/docs/config/_default/params.toml index 950400d8..2d80243e 100644 --- a/docs/config/_default/params.toml +++ b/docs/config/_default/params.toml @@ -1,13 +1,13 @@ # Meta Data for SEO ## Homepage -title = "Railway-FBP" +title = "Flow" titleSeparator = "-" -titleAddition = "Railway Flow Based Programming" +titleAddition = "Flow" description = "Assemble your code by adopting asynchronous as native implementation and build with functional programming and monads." ## Open Graph -images = ["railway-fbp.png"] +images = ["flow.png"] ogLocale = "en_US" domainTLD = "darkwood-fr.github.io" titleHome = "Doks Theme" @@ -25,15 +25,15 @@ schemaAuthorTwitter = "https://twitter.com/matyo91" schemaAuthorLinkedIn = "https://www.linkedin.com/in/mathieu-ledru/" schemaAuthorGitHub = "https://github.com/matyo91" schemaLocale = "en-US" -schemaLogo = "logo-railway-fbp.png" +schemaLogo = "logo-flow.png" schemaLogoWidth = 512 schemaLogoHeight = 512 -schemaImage = "railway-fbp.png" +schemaImage = "flow.png" schemaImageWidth = 1280 schemaImageHeight = 640 schemaTwitter = "https://twitter.com/darkwood_fr" schemaLinkedIn = "" -schemaGitHub = "https://github.com/darkwood-fr/railway-fbp" +schemaGitHub = "https://github.com/darkwood-fr/flow" schemaSection = "blog" ## Sitelinks Search Box @@ -62,7 +62,7 @@ alertDismissable = true alertText = "Introducing the Doks child theme, several DX + UX updates, and more! Check out Doks v0.2" # Edit Page -docsRepo = "https://github.com/darkwood-fr/railway-fbp" +docsRepo = "https://github.com/darkwood-fr/flow" editPage = true [options] diff --git a/docs/content/en/_index.md b/docs/content/en/_index.md index 0ed69bc8..068c4963 100644 --- a/docs/content/en/_index.md +++ b/docs/content/en/_index.md @@ -1,5 +1,5 @@ --- -title : "Railway Flow Based Programming" +title : "Flow" description: "Assemble your code by adopting asynchronous as native implementation and build with functional programming and monads." lead: "Assemble your code by adopting asynchronous as native implementation and build with functional programming and monads." date: 2020-10-06T08:47:36+00:00 diff --git a/docs/content/en/blog/_index.md b/docs/content/en/blog/_index.md index 6f2ef058..0241adfa 100644 --- a/docs/content/en/blog/_index.md +++ b/docs/content/en/blog/_index.md @@ -1,6 +1,6 @@ --- title: "Blog" -description: "The Railway FBP Blog." +description: "The Flow Blog." date: 2020-10-06T08:49:55+00:00 lastmod: 2020-10-06T08:49:55+00:00 draft: false diff --git a/docs/content/en/docs/_index.md b/docs/content/en/docs/_index.md index a9295e3c..8873d464 100644 --- a/docs/content/en/docs/_index.md +++ b/docs/content/en/docs/_index.md @@ -1,6 +1,6 @@ --- title : "Docs" -description: "Docs Railway FBP." +description: "Docs Flow." lead: "" date: 2020-10-06T08:48:23+00:00 lastmod: 2020-10-06T08:48:23+00:00 diff --git a/docs/content/en/docs/getting-started/_index.md b/docs/content/en/docs/getting-started/_index.md index 55d7f860..3a7dc5e0 100644 --- a/docs/content/en/docs/getting-started/_index.md +++ b/docs/content/en/docs/getting-started/_index.md @@ -1,6 +1,6 @@ --- title: "Getting Started" -description: "Getting Started Railway FBP." +description: "Getting Started Flow." lead: "" date: 2020-10-06T08:49:15+00:00 lastmod: 2020-10-06T08:49:15+00:00 diff --git a/docs/content/en/docs/getting-started/changelog.md b/docs/content/en/docs/getting-started/changelog.md index b810a9ec..2f051ae2 100644 --- a/docs/content/en/docs/getting-started/changelog.md +++ b/docs/content/en/docs/getting-started/changelog.md @@ -13,6 +13,19 @@ weight: 60 toc: true --- +### 1.1.1 + +- Rename entire project from `Railway FBP` to `Flow` +- Merge from `packages/symfony` to `packages/php` and make Flow [Symfony](https://symfony.com) friendly +- New DX interface `Flow\FlowInterface` +- Error managment is now integrated to Flow +- Remove context associated with processing IP +- Deprecate `Flow\Flow\SequenceFlow` in favor for `Flow\Flow\Flow` +- Deprecate `Flow\Flow\ErrorFlow` in favor for `Flow\Flow\Flow` +- Update `Flow\Flow\YFlow` and make it plain native +- Update `Flow\IP` that use readonly object +- New Flow logo + ### 1.1.0 - Release MIT License @@ -20,7 +33,7 @@ toc: true ### 1.0.9 -- Add RFBP\Rail\LambdaRail that allows introduce recursivity into Railway-FBP language approach. +- Add `Flow\Flow\YFlow` that allows introduce recursivity into Flow language approach ### 1.0.8 @@ -32,8 +45,8 @@ toc: true ### 1.0.6 -- Add TransportRail -- Rail can process multiple jobs in parallel +- Add `Flow\TransportFlow` +- Flow can process multiple jobs in parallel ### 1.0.5 @@ -47,21 +60,21 @@ toc: true ### 1.0.3 -- Add RFBP\IpStrategy add several Ip strategy for data processing +- Add `Flow\IpStrategy` add several Ip strategy for data processing ### 1.0.2 -- Add RFBP\Driver\DriverInterface -- Add RFBP\Driver\AmpDriver -- Add RFBP\Driver\ReactDriver -- Add RFBP\Driver\SwooleDriver +- Add `Flow\Driver\DriverInterface` +- Add `Flow\Driver\AmpDriver` +- Add `Flow\Driver\ReactDriver` +- Add `Flow\Driver\SwooleDriver` ### 1.0.1 -- Add RFBP\Producer\CollectionConsumer -- Add RFBP\Producer\CollectionProducer -- Add RFBP\Transport\CollectionTransport +- Add `Flow\Producer\CollectionConsumer` +- Add `Flow\Producer\CollectionProducer` +- Add `Flow\Transport\CollectionTransport` # 1.0.0 -- Initial release : Rail, Supervisor, Client \ No newline at end of file +- Initial release : Flow, Supervisor, Client \ No newline at end of file diff --git a/docs/content/en/docs/getting-started/driver.md b/docs/content/en/docs/getting-started/driver.md index d315ef75..8fe0bdd0 100644 --- a/docs/content/en/docs/getting-started/driver.md +++ b/docs/content/en/docs/getting-started/driver.md @@ -15,7 +15,7 @@ toc: true # Driver -Railway FBP embark multiple drivers. +Flow embark multiple drivers. ## Coroutine @@ -60,4 +60,4 @@ More documentation can be found [https://reactphp.org](https://reactphp.org) ## Make your custom driver -You can make your custom driver by implementing `RFBP\DriverInterface` \ No newline at end of file +You can make your custom driver by implementing `Flow\DriverInterface` \ No newline at end of file diff --git a/docs/content/en/docs/getting-started/flow.md b/docs/content/en/docs/getting-started/flow.md new file mode 100644 index 00000000..eb79a45c --- /dev/null +++ b/docs/content/en/docs/getting-started/flow.md @@ -0,0 +1,46 @@ +--- +title: "Flow" +description: "Flow." +lead: "Flow." +date: 2020-10-13T15:21:01+02:00 +lastmod: 2020-10-13T15:21:01+02:00 +draft: false +images: [] +menu: + docs: + parent: "getting-started" +weight: 20 +toc: true +--- + +# Flow + +## Flow implementation + +According to [Wikipedia](https://en.wikipedia.org/wiki/Monad_(functional_programming)), Monads is an abstract generic structure that get its usage in function composition. Monads can shortly considered as `Programming with effects`. + +We consider `Flows` as a set of elements in our ensemble as a Monad implementation : +- By using `job` as basic function type within the `Flow`. +- By using `fn` as a binary operation, `Flow` can be composed together with others `Flow` element. + +A `Flow` can process one or many `Ips` which has its application for asynchronous programming when mixing with [`Drivers`](drivers.md). + +## Flow + +This is the standard Flow implementation that support asynchronous `Ip` processing. + +## FlowDecorator + +This is useful for implementing the [decorator design pattern](https://en.wikipedia.org/wiki/Decorator_pattern). + +## TransportFlow + +TransportFlow will interact with Flow with Producer and Sender. + +## YFlow + +YFlow use YCombinator to provide recursion. + +## Make your own Flow + +You can make your custom Flow by implementing `Flow\FlowInterface`. \ No newline at end of file diff --git a/docs/content/en/docs/getting-started/introduction.md b/docs/content/en/docs/getting-started/introduction.md index 44801536..a7bee4d0 100644 --- a/docs/content/en/docs/getting-started/introduction.md +++ b/docs/content/en/docs/getting-started/introduction.md @@ -13,11 +13,11 @@ weight: 10 toc: true --- -# Railway FBP +# Flow ## Why ? -Railway Flow Based Programming concept aims to solve +Flow concept aims to solve - Adopt asynchronous as native implementation - Build your code with functional programming and monoids @@ -25,23 +25,23 @@ Railway Flow Based Programming concept aims to solve ## Installation -PHP 8.1 is the minimal version to use _Railway Flow Based Programming_ is 8.1 +PHP 8.1 is the minimal version to use _Flow_ is 8.1 The recommended way to install it through [Composer](http://getcomposer.org/) and execute ```bash -composer require darkwood/railway-fbp +composer require darkwood/flow ``` ## Usage A working script is available in the bundled `examples` directory -- Run Rail : `php examples/rail.php` +- Run Flow : `php examples/flow.php` ## Documentation -[https://darkwood-fr.github.io/railway-fbp](https://darkwood-fr.github.io/railway-fbp) +[https://darkwood-fr.github.io/flow](https://darkwood-fr.github.io/flow) ## License -_Railway Flow Based Programming_ is released under the MIT License. +_Flow_ is released under the MIT License. diff --git a/docs/content/en/docs/getting-started/ip-strategy.md b/docs/content/en/docs/getting-started/ip-strategy.md index 1005d935..e960e07a 100644 --- a/docs/content/en/docs/getting-started/ip-strategy.md +++ b/docs/content/en/docs/getting-started/ip-strategy.md @@ -15,7 +15,7 @@ toc: true # Ip Strategy -When processing Rail with one or multiple Ips, you can choose a strategy that will sequence the order of processing Ip. +When processing Flow with one or multiple Ips, you can choose a strategy that will sequence the order of processing Ip. ## LinearIpStrategy @@ -32,4 +32,4 @@ You can embed it by a custom strategy with is `LinearIpStrategy` by default. ## Make your Ip Strategy -You can make your custom Ip strategy by implementing `RFBP\IpStrategyInterface` \ No newline at end of file +You can make your custom Ip strategy by implementing `Flow\IpStrategyInterface` \ No newline at end of file diff --git a/docs/content/en/docs/getting-started/license.md b/docs/content/en/docs/getting-started/license.md index a2a14be3..68d724de 100644 --- a/docs/content/en/docs/getting-started/license.md +++ b/docs/content/en/docs/getting-started/license.md @@ -15,7 +15,7 @@ toc: true The MIT License (MIT) -Copyright (c) 2022 Mathieu Ledru +Copyright (c) 2022 Mathieu Ledru Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/docs/content/en/docs/getting-started/rail.md b/docs/content/en/docs/getting-started/rail.md deleted file mode 100644 index f5e7d032..00000000 --- a/docs/content/en/docs/getting-started/rail.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: "Rail" -description: "Rail." -lead: "Rail." -date: 2020-10-13T15:21:01+02:00 -lastmod: 2020-10-13T15:21:01+02:00 -draft: false -images: [] -menu: - docs: - parent: "getting-started" -weight: 20 -toc: true ---- - -# Rail - -## Rail implementation - -According to [Wikipedia](https://en.wikipedia.org/wiki/Monad_(functional_programming)), Monads is an abstract generic structure that get its usage in function composition. Monads can shortly considered as `Programming with effects`. - -We consider `Rails` as a set of elements in our ensemble as a Monad implementation : -- By using `job` as basic function type within the `Rail`. -- By using `pipe` as a binary operation, `Rail` can be composed together with others `Rail` element. - -A `Rail` can process one or many `Ips` which has its application for asynchronous programming when mixing with [`Drivers`](drivers.md). - -## Rail - -This is the standard Rail implementation that support asynchronous `Ip` processing. - -## RailDecorator - -This is useful for implementing the [decorator design pattern](https://en.wikipedia.org/wiki/Decorator_pattern). - -## ErrorRail - -ErrorRail catch any exception from rail and will be handled by its own job. - -## SequenceRail - -SequenceRail will sequence in order the processing IPs from an array of Rail. - -## ParallelRail - -ParallelRail will sequence processing IPs to parallels array of jobs. - -## Make your own Rail - -You can make your custom Rail by implementing `RFBP\RailInterface` \ No newline at end of file diff --git a/docs/content/en/docs/integrations/_index.md b/docs/content/en/docs/integrations/_index.md index abc1621f..8d63dee6 100644 --- a/docs/content/en/docs/integrations/_index.md +++ b/docs/content/en/docs/integrations/_index.md @@ -1,6 +1,6 @@ --- title: "Integrations" -description: "Integrations Railway FBP." +description: "Integrations Flow." lead: "" date: 2020-10-06T08:49:15+00:00 lastmod: 2020-10-06T08:49:15+00:00 diff --git a/docs/content/en/docs/integrations/php.md b/docs/content/en/docs/integrations/php.md index 6a94d5b6..12615e80 100644 --- a/docs/content/en/docs/integrations/php.md +++ b/docs/content/en/docs/integrations/php.md @@ -22,14 +22,14 @@ This provide integration in PHP The recommended way to install it through [Composer](http://getcomposer.org/) and execute ```bash -composer require darkwood/railway-fbp +composer require darkwood/flow ``` ## Usage A working script is available in the bundled `examples` directory -- Run Rail : `php examples/rail.php` +- Run Flow : `php examples/flow.php` - Start Server : `php examples/server.php` - Start Client(s) : `php examples/client.php` @@ -37,4 +37,4 @@ Messaging part require to install [Docker](https://www.docker.com) and execute ` ## License -_darkwood/railway-fbp_ is released under the MIT License. +_darkwood/flow_ is released under the MIT License. diff --git a/docs/content/en/privacy-policy/index.md b/docs/content/en/privacy-policy/index.md index bbd26cab..d73c990e 100644 --- a/docs/content/en/privacy-policy/index.md +++ b/docs/content/en/privacy-policy/index.md @@ -22,7 +22,7 @@ __TLDR__: We do not use cookies and we do not collect any personal data. We run [Matomo](https://matomo.org/) analytics on darkwood-fr.github.io. The following information is collected: -- __Page URL__. We track the page URL of each page view on this website. We use this to understand which pages have been viewed and how many times a particular page has been viewed. For example: _https://darkwood-fr.github.io/railway-fbp/_. +- __Page URL__. We track the page URL of each page view on this website. We use this to understand which pages have been viewed and how many times a particular page has been viewed. For example: _https://darkwood-fr.github.io/flow/_. - __HTTP Referrer__. We use the referrer string to understand the number of visitors referred to this website from links on other sites. For example: _https://github.com/_. - __Browser__. We use this to understand what browsers people use when visiting this website. This is derived from the User-Agent HTTP header. The full User-Agent is discarded. For example: _Brave_. - __Operating system__. We use this to understand what operating systems people use when visiting this website. We only use the brand of the operating system and don’t include the version number or any other details. This is derived from the User-Agent HTTP header. The full User-Agent is discarded. For example: _GNU/Linux_. diff --git a/docs/images/concept.png b/docs/images/concept.png deleted file mode 100644 index c91b8ce3..00000000 Binary files a/docs/images/concept.png and /dev/null differ diff --git a/docs/images/concept1280x640.png b/docs/images/concept1280x640.png deleted file mode 100644 index 021b064a..00000000 Binary files a/docs/images/concept1280x640.png and /dev/null differ diff --git a/docs/images/favicon.ico b/docs/images/favicon.ico index 9b795875..30ec6281 100644 Binary files a/docs/images/favicon.ico and b/docs/images/favicon.ico differ diff --git a/docs/images/logo.png b/docs/images/logo.png index f0d0f705..7409a5f5 100644 Binary files a/docs/images/logo.png and b/docs/images/logo.png differ diff --git a/docs/layouts/index.html b/docs/layouts/index.html index a986aab9..f483ebd3 100644 --- a/docs/layouts/index.html +++ b/docs/layouts/index.html @@ -7,7 +7,7 @@

{{ .Title }}

diff --git a/docs/static/android-chrome-192x192.png b/docs/static/android-chrome-192x192.png index c63af795..9f0b9a8d 100644 Binary files a/docs/static/android-chrome-192x192.png and b/docs/static/android-chrome-192x192.png differ diff --git a/docs/static/android-chrome-512x512.png b/docs/static/android-chrome-512x512.png index f0d0f705..7409a5f5 100644 Binary files a/docs/static/android-chrome-512x512.png and b/docs/static/android-chrome-512x512.png differ diff --git a/docs/static/apple-touch-icon.png b/docs/static/apple-touch-icon.png index f7b15a2e..de7083d3 100644 Binary files a/docs/static/apple-touch-icon.png and b/docs/static/apple-touch-icon.png differ diff --git a/docs/static/favicon-16x16.png b/docs/static/favicon-16x16.png index 454e7530..48741d66 100644 Binary files a/docs/static/favicon-16x16.png and b/docs/static/favicon-16x16.png differ diff --git a/docs/static/favicon-32x32.png b/docs/static/favicon-32x32.png index 678dd5de..56393beb 100644 Binary files a/docs/static/favicon-32x32.png and b/docs/static/favicon-32x32.png differ diff --git a/docs/static/favicon.ico b/docs/static/favicon.ico index 9b795875..30ec6281 100644 Binary files a/docs/static/favicon.ico and b/docs/static/favicon.ico differ diff --git a/docs/static/flow.png b/docs/static/flow.png new file mode 100644 index 00000000..7409a5f5 Binary files /dev/null and b/docs/static/flow.png differ diff --git a/docs/static/logo-railway-fbp.svg b/docs/static/flow.svg similarity index 100% rename from docs/static/logo-railway-fbp.svg rename to docs/static/flow.svg diff --git a/docs/static/logo-flow.png b/docs/static/logo-flow.png new file mode 100644 index 00000000..7409a5f5 Binary files /dev/null and b/docs/static/logo-flow.png differ diff --git a/docs/static/railway-fbp.svg b/docs/static/logo-flow.svg similarity index 100% rename from docs/static/railway-fbp.svg rename to docs/static/logo-flow.svg diff --git a/docs/static/logo-railway-fbp.png b/docs/static/logo-railway-fbp.png deleted file mode 100644 index f0d0f705..00000000 Binary files a/docs/static/logo-railway-fbp.png and /dev/null differ diff --git a/docs/static/railway-fbp.png b/docs/static/railway-fbp.png deleted file mode 100644 index f0d0f705..00000000 Binary files a/docs/static/railway-fbp.png and /dev/null differ diff --git a/docs/static/site.webmanifest b/docs/static/site.webmanifest index 7dd7aaa4..e60881b5 100644 --- a/docs/static/site.webmanifest +++ b/docs/static/site.webmanifest @@ -1 +1 @@ -{"name":"Railway Flow Based Programming","short_name":"Railway FBP","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#fff","background_color":"#fff","display":"standalone"} \ No newline at end of file +{"name":"Flow","short_name":"Flow","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#fff","background_color":"#fff","display":"standalone"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 83cd8c96..4d303b74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@darkwood-fr/railway-fbp", + "name": "@darkwood-fr/flow", "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@darkwood-fr/railway-fbp", + "name": "@darkwood-fr/flow", "version": "1.1.0", "hasInstallScript": true, "license": "MIT", diff --git a/package.json b/package.json index 892c9e40..269eb0db 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,16 @@ { - "name": "@darkwood-fr/railway-fbp", - "description": "Railway FBP", + "name": "@darkwood-fr/flow", + "description": "Flow", "author": { "name": "Mathieu Ledru", - "email": "matyo91@gmail.com" + "email": "mathieu@darkwood.fr" }, "bugs": { - "url": "https://github.com/darkwood-fr/railway-fbp" + "url": "https://github.com/darkwood-fr/flow" }, - "homepage": "https://github.com/darkwood-fr/railway-fbp/tree/1.x#readme", + "homepage": "https://github.com/darkwood-fr/flow/tree/1.x#readme", "keywords": [ - "railway-fbp" + "flow" ], "version": "1.1.0", "browserslist": [ @@ -19,7 +19,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/darkwood-fr/railway-fbp.git" + "url": "https://github.com/darkwood-fr/flow.git" }, "publishConfig": { "access": "public" diff --git a/packages/php/LICENSE b/packages/php/LICENSE index 2d1a4f3b..52ca9e78 100644 --- a/packages/php/LICENSE +++ b/packages/php/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 Mathieu Ledru +Copyright (c) 2022 Mathieu Ledru Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/packages/php/README.md b/packages/php/README.md index 8de1fe6b..80a2f1b7 100644 --- a/packages/php/README.md +++ b/packages/php/README.md @@ -1,9 +1,9 @@ -## Railway Flow Based Programming implementation in PHP +## Flow implementation in PHP ## Documentation -[https://darkwood-fr.github.io/railway-fbp](https://darkwood-fr.github.io/railway-fbp) +[https://darkwood-fr.github.io/flow](https://darkwood-fr.github.io/flow) ## License -_Railway Flow Based Programming_ is released under the MIT License. +_Flow_ is released under the MIT License. diff --git a/packages/php/composer.json b/packages/php/composer.json index cf3dc49d..27565b85 100644 --- a/packages/php/composer.json +++ b/packages/php/composer.json @@ -1,16 +1,15 @@ { - "name": "darkwood/railway-fbp", - "description": "Railway Flow Based Programming implementation in PHP", + "name": "darkwood/flow", + "description": "Flow", "type": "library", "license": "MIT", "authors": [ { "name": "Mathieu Ledru", - "email": "matyo91@gmail.com" + "email": "mathieu@darkwood.fr" } ], "keywords": [ - "railway flow based programming", "php", "symfony", "coroutine", @@ -25,7 +24,6 @@ "amphp/phpunit-util": "^2.0", "edgedesign/phpqa": "^1.26", "friendsofphp/php-cs-fixer": "^3.9", - "loophp/combinator": "^2.0", "phpstan/phpstan": "^1.8", "phpunit/phpunit": "^9.5", "react/event-loop": "^1.3", @@ -39,18 +37,17 @@ "amphp/amp": "Provide asynchronous with AMP", "ext-swoole": "Provide asynchronous with Swoole", "react/event-loop": "Provide asynchronous with ReactPHP", - "loophp/combinator": "Provide Lambda Rail", "symfony/messenger": "Provide symfony messenger support" }, "autoload": { "psr-4": { - "RFBP\\": "src" + "Flow\\": "src" } }, "autoload-dev": { "psr-4": { - "RFBP\\Examples\\": "examples", - "RFBP\\Test\\": "tests" + "Flow\\Examples\\": "examples", + "Flow\\Test\\": "tests" } }, "scripts": { diff --git a/packages/php/docker-compose.yml b/packages/php/docker-compose.yml index 70d5647e..d04c34d0 100644 --- a/packages/php/docker-compose.yml +++ b/packages/php/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: mysql: - image: mysql:5.7 + image: mysql:8.0.31 environment: - MYSQL_ROOT_PASSWORD=root ports: diff --git a/packages/php/examples/Stamp/DoctrineIpTransportIdStamp.php b/packages/php/examples/Stamp/DoctrineIpTransportIdStamp.php index 99f7bb66..a54ba49c 100644 --- a/packages/php/examples/Stamp/DoctrineIpTransportIdStamp.php +++ b/packages/php/examples/Stamp/DoctrineIpTransportIdStamp.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace RFBP\Examples\Stamp; +namespace Flow\Examples\Stamp; use Symfony\Component\Messenger\Stamp\StampInterface; diff --git a/packages/php/examples/Transport/DoctrineIpTransport.php b/packages/php/examples/Transport/DoctrineIpTransport.php index ad794e95..c9ad7413 100644 --- a/packages/php/examples/Transport/DoctrineIpTransport.php +++ b/packages/php/examples/Transport/DoctrineIpTransport.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\Examples\Transport; +namespace Flow\Examples\Transport; use Doctrine\DBAL\Connection as DbalConnection; -use RFBP\Examples\Stamp\DoctrineIpTransportIdStamp; +use Flow\Examples\Stamp\DoctrineIpTransportIdStamp; use RuntimeException; use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection; use Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineReceiver; diff --git a/packages/php/examples/client.php b/packages/php/examples/client.php index 3350fed5..31f37aec 100644 --- a/packages/php/examples/client.php +++ b/packages/php/examples/client.php @@ -5,10 +5,10 @@ require __DIR__.'/../vendor/autoload.php'; use Doctrine\DBAL\DriverManager; -use RFBP\Client; -use RFBP\Examples\Transport\DoctrineIpTransport; +use Flow\Client; +use Flow\Examples\Transport\DoctrineIpTransport; -$connection = DriverManager::getConnection(['url' => 'mysql://root:root@127.0.0.1:3306/rfbp?serverVersion=5.7']); +$connection = DriverManager::getConnection(['url' => 'mysql://root:root@127.0.0.1:3306/flow?serverVersion=8.0.31']); $transport = new DoctrineIpTransport($connection, uniqid('transport_', true)); $client = new Client($transport, $transport); diff --git a/packages/php/examples/rail.php b/packages/php/examples/flow.php similarity index 56% rename from packages/php/examples/rail.php rename to packages/php/examples/flow.php index 4a2684a6..69ef9e23 100644 --- a/packages/php/examples/rail.php +++ b/packages/php/examples/flow.php @@ -5,24 +5,23 @@ require __DIR__.'/../vendor/autoload.php'; use function Amp\delay; -use RFBP\Driver\AmpDriver; -use RFBP\Driver\ReactDriver; -use RFBP\Driver\SwooleDriver; -use RFBP\Ip; -use RFBP\IpStrategy\MaxIpStrategy; -use RFBP\Rail\ErrorRail; -use RFBP\Rail\Rail; -use RFBP\Rail\SequenceRail; +use Flow\Driver\AmpDriver; +use Flow\Driver\ReactDriver; +use Flow\Driver\SwooleDriver; +use Flow\Ip; +use Flow\IpStrategy\MaxIpStrategy; +use Flow\Flow\Flow; use Swoole\Coroutine; -$randomDriver = random_int(1, 3); +$randomDriver = random_int(1, 5); + if (1 === $randomDriver) { printf("Use AmpDriver\n"); $driver = new AmpDriver(); $job1 = static function (object $data): Generator { - printf("*. #%d : Calculating %d + %d\n", $data['id'], $data['number'], $data['number']); + printf("*. #%d - Job 1 : Calculating %d + %d\n", $data['id'], $data['number'], $data['number']); // simulating calculating some "light" operation from 100 to 900 milliseconds as async generator $delay = random_int(1, 9) * 100; @@ -30,11 +29,11 @@ $result = $data['number']; $result += $result; - if (1 === random_int(1, 3)) { + if (1 === random_int(1, 5)) { throw new Error('Failure when processing "Job1"'); } - printf("*. #%d : Result for %d + %d = %d and took %d milliseconds\n", $data['id'], $data['number'], $data['number'], $result, $delay); + printf("*. #%d - Job 1 : Result for %d + %d = %d and took %d milliseconds\n", $data['id'], $data['number'], $data['number'], $result, $delay); $data['number'] = $result; }; @@ -44,7 +43,7 @@ $driver = new SwooleDriver(); $job1 = static function (object $data): void { - printf("*. #%d : Calculating %d + %d\n", $data['id'], $data['number'], $data['number']); + printf("*. #%d - Job 1 : Calculating %d + %d\n", $data['id'], $data['number'], $data['number']); // simulating calculating some "light" operation from 100 to 900 milliseconds as async generator $delay = random_int(1, 9) * 100; @@ -52,11 +51,11 @@ $result = $data['number']; $result += $result; - if (1 === random_int(1, 3)) { + if (1 === random_int(1, 5)) { throw new Error('Failure when processing "Job1"'); } - printf("*. #%d : Result for %d + %d = %d and took %d milliseconds\n", $data['id'], $data['number'], $data['number'], $result, $delay); + printf("*. #%d - Job 1 : Result for %d + %d = %d and took %d milliseconds\n", $data['id'], $data['number'], $data['number'], $result, $delay); $data['number'] = $result; }; @@ -66,56 +65,54 @@ $driver = new ReactDriver(); $job1 = static function (object $data): void { - printf("*. #%d : Calculating %d + %d\n", $data['id'], $data['number'], $data['number']); + printf("*. #%d - Job 1 : Calculating %d + %d\n", $data['id'], $data['number'], $data['number']); // simulating calculating some "light" $result = $data['number']; $result += $result; - if (1 === random_int(1, 3)) { + if (1 === random_int(1, 5)) { throw new Error('Failure when processing "Job1"'); } - printf("*. #%d : Result for %d + %d = %d\n", $data['id'], $data['number'], $data['number'], $result); + printf("*. #%d - Job 1 : Result for %d + %d = %d\n", $data['id'], $data['number'], $data['number'], $result); $data['number'] = $result; }; } $job2 = static function (object $data): void { - printf(".* #%d : Calculating %d * %d\n", $data['id'], $data['number'], $data['number']); + printf(".* #%d - Job 2 : Calculating %d * %d\n", $data['id'], $data['number'], $data['number']); // simulating calculating some "light" operation as anonymous function $result = $data['number']; $result *= $result; - printf(".* #%d : Result for %d * %d = %d\n", $data['id'], $data['number'], $data['number'], $result); + if (1 === random_int(1, 5)) { + throw new Error('Failure when processing "Job2"'); + } + + printf(".* #%d - Job 2 : Result for %d * %d = %d\n", $data['id'], $data['number'], $data['number'], $result); $data['number'] = $result; }; $errorJob = static function (object $data, Throwable $exception): void { - printf(".* #%d : Exception %s\n", $data['id'], $exception->getMessage()); + printf(".* #%d - Error Job : Exception %s\n", $data['id'], $exception->getMessage()); $data['number'] = null; }; -$rails = new SequenceRail([ - new Rail($job1, new MaxIpStrategy(2), $driver), - new Rail($job2, new MaxIpStrategy(2), $driver), -]); -$rail = new ErrorRail($rails, $errorJob, new MaxIpStrategy(2), $driver); +$flow = (new Flow($job1, $errorJob, new MaxIpStrategy(2), $driver)) + ->fn(new Flow($job2, $errorJob, new MaxIpStrategy(2), $driver)); $ipPool = new SplObjectStorage(); -$rail->pipe(static function ($ip) use ($ipPool) { - $ipPool->offsetUnset($ip); -}); for ($i = 1; $i <= 5; ++$i) { $ip = new Ip(new ArrayObject(['id' => $i, 'number' => $i])); $ipPool->offsetSet($ip, true); - $rail($ip); + $flow($ip, fn ($ip) => $ipPool->offsetUnset($ip)); } $driver->tick(1, function () use ($driver, $ipPool) { @@ -123,4 +120,4 @@ $driver->stop(); } }); -$driver->run(); +$driver->start(); diff --git a/packages/php/examples/server.php b/packages/php/examples/server.php index d141d334..6cbe5c89 100644 --- a/packages/php/examples/server.php +++ b/packages/php/examples/server.php @@ -6,15 +6,13 @@ use function Amp\delay; use Doctrine\DBAL\DriverManager; -use RFBP\Driver\AmpDriver; -use RFBP\Driver\ReactDriver; -use RFBP\Driver\SwooleDriver; -use RFBP\Examples\Transport\DoctrineIpTransport; -use RFBP\IpStrategy\MaxIpStrategy; -use RFBP\Rail\ErrorRail; -use RFBP\Rail\Rail; -use RFBP\Rail\SequenceRail; -use RFBP\Rail\TransportRail; +use Flow\Driver\AmpDriver; +use Flow\Driver\ReactDriver; +use Flow\Driver\SwooleDriver; +use Flow\Examples\Transport\DoctrineIpTransport; +use Flow\IpStrategy\MaxIpStrategy; +use Flow\Flow\Flow; +use Flow\Flow\TransportFlow; use Swoole\Coroutine; $randomDriver = random_int(1, 3); @@ -112,22 +110,18 @@ $data['number'] = null; }; -$rail = new SequenceRail([ - new Rail($addOneJob, new MaxIpStrategy(1), $driver), - new Rail($multbyTwoJob, new MaxIpStrategy(3), $driver), - new Rail($minusThreeJob, new MaxIpStrategy(2), $driver), -]); +$flow = (new Flow($addOneJob, $errorJob, new MaxIpStrategy(1), $driver)) + ->fn(new Flow($multbyTwoJob, $errorJob, new MaxIpStrategy(3), $driver)) + ->fn(new Flow($minusThreeJob, $errorJob, new MaxIpStrategy(2), $driver)); -$rail = new ErrorRail($rail, $errorJob, new MaxIpStrategy(2), $driver); - -$connection = DriverManager::getConnection(['url' => 'mysql://root:root@127.0.0.1:3306/rfbp?serverVersion=5.7']); +$connection = DriverManager::getConnection(['url' => 'mysql://root:root@127.0.0.1:3306/flow?serverVersion=8.0.31']); $transport = new DoctrineIpTransport($connection); -new TransportRail( - $rail, +new TransportFlow( + $flow, $transport, $transport, $driver ); -$driver->run(); +$driver->start(); diff --git a/packages/php/psalm.xml.dist b/packages/php/psalm.xml.dist index 36df9744..9e1f9846 100644 --- a/packages/php/psalm.xml.dist +++ b/packages/php/psalm.xml.dist @@ -1,6 +1,6 @@ ticksIds[] = Loop::repeat($interval, $callback); } - public function run(): void + public function start(): void { Loop::run(); } diff --git a/packages/php/src/Driver/ReactDriver.php b/packages/php/src/Driver/ReactDriver.php index ade67de7..c140af58 100644 --- a/packages/php/src/Driver/ReactDriver.php +++ b/packages/php/src/Driver/ReactDriver.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace RFBP\Driver; +namespace Flow\Driver; use Closure; use React\EventLoop\Loop; use React\EventLoop\LoopInterface; use React\EventLoop\TimerInterface; -use RFBP\DriverInterface; +use Flow\DriverInterface; use RuntimeException; use Throwable; @@ -59,7 +59,7 @@ public function tick(int $interval, Closure $callback): void $this->ticksIds[] = $this->eventLoop->addPeriodicTimer($interval, $callback); } - public function run(): void + public function start(): void { $this->eventLoop->run(); } diff --git a/packages/php/src/Driver/SwooleDriver.php b/packages/php/src/Driver/SwooleDriver.php index ad9879cb..2ce7e36d 100644 --- a/packages/php/src/Driver/SwooleDriver.php +++ b/packages/php/src/Driver/SwooleDriver.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\Driver; +namespace Flow\Driver; use Closure; -use RFBP\DriverInterface; +use Flow\DriverInterface; use RuntimeException; use Swoole\Coroutine; use Swoole\Timer; @@ -56,7 +56,7 @@ public function tick(int $interval, Closure $callback): void $this->ticks[] = [$interval, $callback]; } - public function run(): void + public function start(): void { foreach ($this->ticks as $tick) { [$interval, $callback] = $tick; diff --git a/packages/php/src/DriverInterface.php b/packages/php/src/DriverInterface.php index bb86ef9a..f4a0decc 100644 --- a/packages/php/src/DriverInterface.php +++ b/packages/php/src/DriverInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace RFBP; +namespace Flow; use Closure; @@ -12,7 +12,7 @@ public function coroutine(Closure $callback, ?Closure $onResolved = null): Closu public function tick(int $interval, Closure $callback): void; - public function run(): void; + public function start(): void; public function stop(): void; } diff --git a/packages/php/src/EnvelopeTrait.php b/packages/php/src/EnvelopeTrait.php index e5a10af5..4d8d29f6 100644 --- a/packages/php/src/EnvelopeTrait.php +++ b/packages/php/src/EnvelopeTrait.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace RFBP; +namespace Flow; use RuntimeException; use Symfony\Component\Messenger\Envelope; diff --git a/packages/php/src/Flow/Flow.php b/packages/php/src/Flow/Flow.php new file mode 100644 index 00000000..627dbf70 --- /dev/null +++ b/packages/php/src/Flow/Flow.php @@ -0,0 +1,110 @@ + + */ + private array $jobs; + + /** + * @var array + */ + private array $errorJobs; + + private IpStrategyInterface $ipStrategy; + + private DriverInterface $driver; + + /** + * @var SplObjectStorage + */ + private SplObjectStorage $callbacks; + private ?FlowInterface $fnFlow = null; + + /** + * @param Closure|array $jobs + * @param Closure|array $errorJobs + */ + public function __construct( + Closure|array $jobs, + Closure|array $errorJobs, + IpStrategyInterface $ipStrategy = null, + DriverInterface $driver = null + ) { + $this->jobs = is_array($jobs) ? $jobs : [$jobs]; + $this->errorJobs = is_array($errorJobs) ? $errorJobs : [$errorJobs]; + $this->ipStrategy = $ipStrategy ?? new LinearIpStrategy(); + $this->driver = $driver ?? new AmpDriver(); + $this->callbacks = new SplObjectStorage(); + } + + private function nextIpJob(): void + { + $ip = $this->ipStrategy->pop(); + if (!$ip) { + return ; + } + + $callback = $this->callbacks->offsetGet($ip); + $this->callbacks->offsetUnset($ip); + + $count = count($this->jobs); + foreach ($this->jobs as $i => $job) { + $this->driver->coroutine($job, function (Throwable $exception = null) use ($ip, &$count, $i, $callback) { + $count--; + if($count === 0 || $exception !== null) { + $count = 0; + $this->ipStrategy->done($ip); + $this->nextIpJob(); + + if($exception) { + if(isset($this->errorJobs[$i])) { + $this->errorJobs[$i]($ip->data, $exception); + } else { + throw $exception; + } + } + + if ($this->fnFlow) { + ($this->fnFlow)($ip, $callback); + } else { + ($callback)($ip); + } + } + })($ip->data); + } + } + + public function __invoke(Ip $ip, ?Closure $callback = null): void + { + $this->callbacks->offsetSet($ip, $callback); + $this->ipStrategy->push($ip); + $this->nextIpJob(); + } + + public function fn(FlowInterface $flow): FlowInterface + { + if($this->fnFlow) { + $this->fnFlow->fn($flow); + } else { + $this->fnFlow = $flow; + } + + return $this; + } +} diff --git a/packages/php/src/Flow/FlowDecorator.php b/packages/php/src/Flow/FlowDecorator.php new file mode 100644 index 00000000..a588ce75 --- /dev/null +++ b/packages/php/src/Flow/FlowDecorator.php @@ -0,0 +1,26 @@ +flow)($ip, $callback); + } + + public function fn(FlowInterface $flow): FlowInterface + { + return $this->flow->fn($flow); + } +} diff --git a/packages/php/src/Rail/TransportRail.php b/packages/php/src/Flow/TransportFlow.php similarity index 50% rename from packages/php/src/Rail/TransportRail.php rename to packages/php/src/Flow/TransportFlow.php index 383044c7..3d46002d 100644 --- a/packages/php/src/Rail/TransportRail.php +++ b/packages/php/src/Flow/TransportFlow.php @@ -2,22 +2,21 @@ declare(strict_types=1); -namespace RFBP\Rail; +namespace Flow\Flow; use Closure; -use LogicException; -use RFBP\Driver\AmpDriver; -use RFBP\DriverInterface; -use RFBP\EnvelopeTrait; -use RFBP\Ip; -use RFBP\RailInterface; +use Exception; +use Flow\Driver\AmpDriver; +use Flow\DriverInterface; +use Flow\EnvelopeTrait; +use Flow\Ip; +use Flow\FlowInterface; use SplObjectStorage; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface; use Symfony\Component\Messenger\Transport\Sender\SenderInterface; -use Throwable; -class TransportRail implements RailInterface +class TransportFlow implements FlowInterface { use EnvelopeTrait; @@ -33,14 +32,12 @@ class TransportRail implements RailInterface private DriverInterface $driver; - private ?Closure $pipeCallback = null; - /** * @param array $options valid options are: * - interval (default: 0): tick interval in milliseconds */ public function __construct( - private RailInterface $rail, + private FlowInterface $flow, private ReceiverInterface $producer, private SenderInterface $consumer, ?DriverInterface $driver = null, @@ -60,42 +57,6 @@ public function __construct( $this->emit($envelope); } }); - - $rail->pipe(function (Ip $ip, Throwable $exception = null) { - if ($exception) { - if ($this->envelopePool->contains($ip)) { - $envelope = $this->envelopePool->offsetGet($ip); - $this->producer->reject($envelope); - $this->envelopePool->offsetUnset($ip); - $id = $this->getEnvelopeId($envelope); - unset($this->envelopeIds[$id]); - } - - if ($this->pipeCallback) { - ($this->pipeCallback)($ip, $exception); - } - } else { - if ($this->envelopePool->contains($ip)) { - $envelope = $this->envelopePool->offsetGet($ip); - $this->consumer->send(Envelope::wrap($ip->getData(), array_reduce($envelope->all(), static function (array $all, array $stamps) { - foreach ($stamps as $stamp) { - $all[] = $stamp; - } - - return $all; - }, []))); - $this->producer->ack($envelope); - - $this->envelopePool->offsetUnset($ip); - $id = $this->getEnvelopeId($envelope); - unset($this->envelopeIds[$id]); - } - - if ($this->pipeCallback) { - ($this->pipeCallback)($ip, $exception); - } - } - }); } private function emit(Envelope $envelope): void @@ -105,21 +66,40 @@ private function emit(Envelope $envelope): void $this->envelopeIds[$id] = $envelope; $ip = new Ip($envelope->getMessage()); $this->envelopePool->offsetSet($ip, $envelope); - ($this->rail)($ip); + try { + $self = $this; + ($this->flow)($ip, static function($ip) use ($self) { + $envelope = $self->envelopePool->offsetGet($ip); + $self->consumer->send(Envelope::wrap($ip->data, array_reduce($envelope->all(), static function (array $all, array $stamps) { + foreach ($stamps as $stamp) { + $all[] = $stamp; + } + + return $all; + }, []))); + $self->producer->ack($envelope); + + $self->envelopePool->offsetUnset($ip); + $id = $self->getEnvelopeId($envelope); + unset($self->envelopeIds[$id]); + }); + } catch (Exception $e) { + $envelope = $this->envelopePool->offsetGet($ip); + $this->producer->reject($envelope); + $this->envelopePool->offsetUnset($ip); + $id = $this->getEnvelopeId($envelope); + unset($this->envelopeIds[$id]); + } } } - public function __invoke(Ip $ip, mixed $context = null): void + public function __invoke(Ip $ip, ?Closure $callback = null): void { - ($this->rail)($ip); + ($this->flow)($ip); } - public function pipe(Closure $callback): void + public function fn(FlowInterface $flow): FlowInterface { - if ($this->pipeCallback) { - throw new LogicException('Callback is already set'); - } - - $this->pipeCallback = $callback; + return $this->flow->fn($flow); } } diff --git a/packages/php/src/Flow/YFlow.php b/packages/php/src/Flow/YFlow.php new file mode 100644 index 00000000..dc41da4d --- /dev/null +++ b/packages/php/src/Flow/YFlow.php @@ -0,0 +1,20 @@ + $f($f); + $Y = fn(Closure $f) => $U(fn(Closure $x) => $f(fn($y) => $U($x)($y))); + + parent::__construct(new Flow($Y($job), $errorJob, $ipStrategy, $driver)); + } +} diff --git a/packages/php/src/FlowInterface.php b/packages/php/src/FlowInterface.php new file mode 100644 index 00000000..78c3ce4d --- /dev/null +++ b/packages/php/src/FlowInterface.php @@ -0,0 +1,14 @@ +data; - } } diff --git a/packages/php/src/IpStrategy/LinearIpStrategy.php b/packages/php/src/IpStrategy/LinearIpStrategy.php index c7ec5109..8e8144c5 100644 --- a/packages/php/src/IpStrategy/LinearIpStrategy.php +++ b/packages/php/src/IpStrategy/LinearIpStrategy.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\IpStrategy; +namespace Flow\IpStrategy; -use RFBP\Ip; -use RFBP\IpStrategyInterface; +use Flow\Ip; +use Flow\IpStrategyInterface; class LinearIpStrategy implements IpStrategyInterface { diff --git a/packages/php/src/IpStrategy/MaxIpStrategy.php b/packages/php/src/IpStrategy/MaxIpStrategy.php index b4607b99..03105c58 100644 --- a/packages/php/src/IpStrategy/MaxIpStrategy.php +++ b/packages/php/src/IpStrategy/MaxIpStrategy.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\IpStrategy; +namespace Flow\IpStrategy; -use RFBP\Ip; -use RFBP\IpStrategyInterface; +use Flow\Ip; +use Flow\IpStrategyInterface; class MaxIpStrategy implements IpStrategyInterface { diff --git a/packages/php/src/IpStrategy/StackIpStrategy.php b/packages/php/src/IpStrategy/StackIpStrategy.php index b902cea4..8af38cc3 100644 --- a/packages/php/src/IpStrategy/StackIpStrategy.php +++ b/packages/php/src/IpStrategy/StackIpStrategy.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\IpStrategy; +namespace Flow\IpStrategy; -use RFBP\Ip; -use RFBP\IpStrategyInterface; +use Flow\Ip; +use Flow\IpStrategyInterface; class StackIpStrategy implements IpStrategyInterface { diff --git a/packages/php/src/IpStrategyInterface.php b/packages/php/src/IpStrategyInterface.php index 599ec63c..988bd60a 100644 --- a/packages/php/src/IpStrategyInterface.php +++ b/packages/php/src/IpStrategyInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace RFBP; +namespace Flow; interface IpStrategyInterface { diff --git a/packages/php/src/Rail/ErrorRail.php b/packages/php/src/Rail/ErrorRail.php deleted file mode 100644 index 22e6ffc7..00000000 --- a/packages/php/src/Rail/ErrorRail.php +++ /dev/null @@ -1,39 +0,0 @@ -errorRail = new Rail($job, $ipStrategy, $driver); - } - - public function __invoke(Ip $ip, mixed $context = null): void - { - ($this->rail)($ip, $context); - } - - public function pipe(Closure $callback): void - { - $this->rail->pipe(function (Ip $ip, Throwable $exception = null) use ($callback) { - if ($exception) { - ($this->errorRail)($ip, $exception); - } else { - $callback($ip, null); - } - }); - $this->errorRail->pipe($callback); - } -} diff --git a/packages/php/src/Rail/LambdaRail.php b/packages/php/src/Rail/LambdaRail.php deleted file mode 100644 index 4e73fb3e..00000000 --- a/packages/php/src/Rail/LambdaRail.php +++ /dev/null @@ -1,18 +0,0 @@ - - */ - private array $jobs; - - private IpStrategyInterface $ipStrategy; - - private DriverInterface $driver; - - /** - * @var SplObjectStorage - */ - private SplObjectStorage $contexts; - private ?Closure $pipeCallback = null; - - /** - * @param Closure|array $jobs - */ - public function __construct( - Closure|array $jobs, - IpStrategyInterface $ipStrategy = null, - DriverInterface $driver = null - ) { - $this->jobs = is_array($jobs) ? $jobs : [$jobs]; - $this->ipStrategy = $ipStrategy ?? new LinearIpStrategy(); - $this->driver = $driver ?? new AmpDriver(); - $this->contexts = new SplObjectStorage(); - } - - private function nextIpJob(): void - { - $ip = $this->ipStrategy->pop(); - if (!$ip) { - return; - } - - $context = $this->contexts->offsetGet($ip); - $this->contexts->offsetUnset($ip); - - $count = count($this->jobs); - foreach ($this->jobs as $job) { - $this->driver->coroutine($job, function (Throwable $exception = null) use ($ip, &$count) { - $count--; - if($count === 0 || ($exception && $count >= 0)) { - $count = 0; - $this->ipStrategy->done($ip); - $this->nextIpJob(); - - if ($this->pipeCallback) { - ($this->pipeCallback)($ip, $exception); - } - } - })($ip->getData(), $context); - } - } - - public function __invoke(Ip $ip, mixed $context = null): void - { - $this->contexts->offsetSet($ip, $context); - $this->ipStrategy->push($ip); - $this->nextIpJob(); - } - - public function pipe(Closure $callback): void - { - if ($this->pipeCallback) { - throw new LogicException('Callback is already set'); - } - - $this->pipeCallback = $callback; - } -} diff --git a/packages/php/src/Rail/RailDecorator.php b/packages/php/src/Rail/RailDecorator.php deleted file mode 100644 index dcba85d4..00000000 --- a/packages/php/src/Rail/RailDecorator.php +++ /dev/null @@ -1,26 +0,0 @@ -rail)($ip, $context); - } - - public function pipe(Closure $callback): void - { - $this->rail->pipe($callback); - } -} diff --git a/packages/php/src/Rail/SequenceRail.php b/packages/php/src/Rail/SequenceRail.php deleted file mode 100644 index 337c57f1..00000000 --- a/packages/php/src/Rail/SequenceRail.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ - private SplObjectStorage $ips; - - /** - * @param array $rails - */ - public function __construct(private array $rails) - { - $this->ips = new SplObjectStorage(); - } - - public function __invoke(Ip $ip, mixed $context = null): void - { - if (0 === count($this->rails)) { - return; - } - - $this->ips->offsetSet($ip, $context); - ($this->rails[0])($ip); - } - - public function pipe(Closure $callback): void - { - foreach ($this->rails as $index => $rail) { - if ($index + 1 < count($this->rails)) { - $rail->pipe(function (Ip $ip, Throwable $exception = null) use ($index, $callback) { - if ($exception) { - $this->ips->offsetUnset($ip); - $callback($ip, $exception); - } else { - ($this->rails[$index + 1])($ip, $this->ips->offsetGet($ip)); - } - }); - } else { - $rail->pipe(function (Ip $ip, Throwable $exception = null) use ($callback) { - $this->ips->offsetUnset($ip); - $callback($ip, $exception); - }); - } - } - } -} diff --git a/packages/php/src/RailInterface.php b/packages/php/src/RailInterface.php deleted file mode 100644 index bec5f740..00000000 --- a/packages/php/src/RailInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -stop(); $this->assertNull($e); })(); - $driver->run(); + $driver->start(); } public function testCoroutineError(): void @@ -33,7 +33,7 @@ public function testCoroutineError(): void $driver->stop(); $this->assertNotNull($e); })(); - $driver->run(); + $driver->start(); } public function testTick(): void @@ -49,6 +49,6 @@ public function testTick(): void $this->assertGreaterThan(3, $i); })(); - $driver->run(); + $driver->start(); } } diff --git a/packages/php/tests/Driver/ReactDriverTest.php b/packages/php/tests/Driver/ReactDriverTest.php index a1606e62..7fa46eb1 100644 --- a/packages/php/tests/Driver/ReactDriverTest.php +++ b/packages/php/tests/Driver/ReactDriverTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\Test\Driver; +namespace Flow\Test\Driver; -use RFBP\Driver\ReactDriver; -use RFBP\DriverInterface; +use Flow\Driver\ReactDriver; +use Flow\DriverInterface; class ReactDriverTest extends DriverTest { diff --git a/packages/php/tests/Driver/SwooleDriverTest.php b/packages/php/tests/Driver/SwooleDriverTest.php index a5800e1c..a4c226b7 100644 --- a/packages/php/tests/Driver/SwooleDriverTest.php +++ b/packages/php/tests/Driver/SwooleDriverTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\Test\Driver; +namespace Flow\Test\Driver; -use RFBP\Driver\SwooleDriver; -use RFBP\DriverInterface; +use Flow\Driver\SwooleDriver; +use Flow\DriverInterface; class SwooleDriverTest extends DriverTest { diff --git a/packages/php/tests/EnvelopeTraitTest.php b/packages/php/tests/EnvelopeTraitTest.php index 264395cd..8cbcdcd4 100644 --- a/packages/php/tests/EnvelopeTraitTest.php +++ b/packages/php/tests/EnvelopeTraitTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\Test; +namespace Flow\Test; use PHPUnit\Framework\TestCase; -use RFBP\EnvelopeTrait; +use Flow\EnvelopeTrait; use RuntimeException; use stdClass; use Symfony\Component\Messenger\Envelope; diff --git a/packages/php/tests/Examples/Stamp/DoctrineIpTransportIdStampTest.php b/packages/php/tests/Examples/Stamp/DoctrineIpTransportIdStampTest.php index 9f51f4f9..6a976f51 100644 --- a/packages/php/tests/Examples/Stamp/DoctrineIpTransportIdStampTest.php +++ b/packages/php/tests/Examples/Stamp/DoctrineIpTransportIdStampTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace RFBP\Test\Examples\Stamp; +namespace Flow\Test\Examples\Stamp; use PHPUnit\Framework\TestCase; -use RFBP\Examples\Stamp\DoctrineIpTransportIdStamp; +use Flow\Examples\Stamp\DoctrineIpTransportIdStamp; class DoctrineIpTransportIdStampTest extends TestCase { diff --git a/packages/php/tests/Examples/Transport/DoctrineIpTransportTest.php b/packages/php/tests/Examples/Transport/DoctrineIpTransportTest.php index b6fd835e..3ef4871f 100644 --- a/packages/php/tests/Examples/Transport/DoctrineIpTransportTest.php +++ b/packages/php/tests/Examples/Transport/DoctrineIpTransportTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace RFBP\Test\Examples\Transport; +namespace Flow\Test\Examples\Transport; use ArrayObject; use Doctrine\DBAL\DriverManager; use PHPUnit\Framework\TestCase; -use RFBP\Examples\Stamp\DoctrineIpTransportIdStamp; -use RFBP\Examples\Transport\DoctrineIpTransport; +use Flow\Examples\Stamp\DoctrineIpTransportIdStamp; +use Flow\Examples\Transport\DoctrineIpTransport; use Symfony\Component\Messenger\Envelope; class DoctrineIpTransportTest extends TestCase diff --git a/packages/php/tests/Rail/AbstractRailTest.php b/packages/php/tests/Flow/AbstractFlowTest.php similarity index 82% rename from packages/php/tests/Rail/AbstractRailTest.php rename to packages/php/tests/Flow/AbstractFlowTest.php index 285f352e..14e6351a 100644 --- a/packages/php/tests/Rail/AbstractRailTest.php +++ b/packages/php/tests/Flow/AbstractFlowTest.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace RFBP\Test\Rail; +namespace Flow\Test\Flow; use Amp\PHPUnit\AsyncTestCase; -use RFBP\Driver\AmpDriver; -use RFBP\Driver\ReactDriver; -use RFBP\Driver\SwooleDriver; -use RFBP\IpStrategy\LinearIpStrategy; -use RFBP\IpStrategy\MaxIpStrategy; -use RFBP\IpStrategy\StackIpStrategy; - -abstract class AbstractRailTest extends AsyncTestCase +use Flow\Driver\AmpDriver; +use Flow\Driver\ReactDriver; +use Flow\Driver\SwooleDriver; +use Flow\IpStrategy\LinearIpStrategy; +use Flow\IpStrategy\MaxIpStrategy; +use Flow\IpStrategy\StackIpStrategy; + +abstract class AbstractFlowTest extends AsyncTestCase { /** * @param array> $datas diff --git a/packages/php/tests/Rail/AmpTransportRailTest.php b/packages/php/tests/Flow/AmpTransportFlowTest.php similarity index 76% rename from packages/php/tests/Rail/AmpTransportRailTest.php rename to packages/php/tests/Flow/AmpTransportFlowTest.php index fa4d43ec..2b6d9ebf 100644 --- a/packages/php/tests/Rail/AmpTransportRailTest.php +++ b/packages/php/tests/Flow/AmpTransportFlowTest.php @@ -2,25 +2,25 @@ declare(strict_types=1); -namespace RFBP\Test; +namespace Flow\Test; use function Amp\delay; use Amp\Loop; use Amp\PHPUnit\AsyncTestCase; use ArrayObject; use Closure; -use RFBP\Driver\AmpDriver; -use RFBP\DriverInterface; -use RFBP\Rail\Rail; -use RFBP\Rail\SequenceRail; -use RFBP\Rail\TransportRail; +use Flow\Driver\AmpDriver; +use Flow\DriverInterface; +use Flow\Flow\Flow; +use Flow\Flow\SequenceFlow; +use Flow\Flow\TransportFlow; use RuntimeException; use stdClass; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp; use Symfony\Component\Messenger\Transport\InMemoryTransport; -class AmpTransportRailTest extends AsyncTestCase +class AmpTransportFlowTest extends AsyncTestCase { /** * @dataProvider jobsProvider @@ -31,9 +31,18 @@ public function testJobs(array $jobs, DriverInterface $driver, int $resultNumber { $transport1 = new InMemoryTransport(); $transport2 = new InMemoryTransport(); - $rail = new SequenceRail(array_map(static function ($job) use ($driver) { return new Rail($job, null, $driver); }, $jobs)); + $flow = array_reduce($jobs, static function($flow, $job) use ($driver) { + $jobFlow = new Flow($job, static function() {}, null, $driver); + if($flow === null) { + $flow = $jobFlow; + } else { + $flow->fn($jobFlow); + } + + return $flow; + }, null); - new TransportRail($rail, $transport1, $transport2); + new TransportFlow($flow, $transport1, $transport2); Loop::repeat(1, static function () use ($driver, $transport2, $resultNumber) { $ips = $transport2->get(); @@ -48,7 +57,7 @@ public function testJobs(array $jobs, DriverInterface $driver, int $resultNumber $envelope = new Envelope(new ArrayObject(['number' => 0])); $transport1->send($envelope); - $driver->run(); + $driver->start(); } /** diff --git a/packages/php/tests/Rail/RailTest.php b/packages/php/tests/Flow/FlowTest.php similarity index 54% rename from packages/php/tests/Rail/RailTest.php rename to packages/php/tests/Flow/FlowTest.php index a6478abb..cf3d1303 100644 --- a/packages/php/tests/Rail/RailTest.php +++ b/packages/php/tests/Flow/FlowTest.php @@ -2,35 +2,34 @@ declare(strict_types=1); -namespace RFBP\Test\Rail; +namespace Flow\Test\Flow; use ArrayObject; use Closure; -use RFBP\DriverInterface; -use RFBP\Ip; -use RFBP\IpStrategyInterface; -use RFBP\Rail\Rail; +use Flow\DriverInterface; +use Flow\Ip; +use Flow\IpStrategyInterface; +use Flow\Flow\Flow; use RuntimeException; use Throwable; -class RailTest extends AbstractRailTest +class FlowTest extends AbstractFlowTest { /** * @dataProvider jobProvider */ - public function testJob(DriverInterface $driver, IpStrategyInterface $ipStrategy, Closure $job, int $resultNumber, ?Throwable $resultException): void + public function testJob(DriverInterface $driver, IpStrategyInterface $ipStrategy, Closure $job, int $resultNumber): void { $ip = new Ip(new ArrayObject(['number' => 0])); - $rail = new Rail($job, $ipStrategy, $driver); - $rail->pipe(function (Ip $ip, ?Throwable $exception) use ($driver, $resultNumber, $resultException) { + $errorJob = function() {}; + $flow = new Flow($job, $errorJob, $ipStrategy, $driver); + ($flow)($ip, function (Ip $ip) use ($driver, $resultNumber) { $driver->stop(); - self::assertSame(ArrayObject::class, $ip->getData()::class); - self::assertSame($resultNumber, $ip->getData()['number']); - self::assertSame($resultException, $exception); + self::assertSame(ArrayObject::class, $ip->data::class); + self::assertSame($resultNumber, $ip->data['number']); }); - ($rail)($ip); - $driver->run(); + $driver->start(); } /** @@ -46,27 +45,33 @@ public function testJobs(DriverInterface $driver): void }, function (object $data): void { $data['n2'] *= 4; }]; - $rail = new Rail($jobs, null, $driver); + $errorJobs = [function() { + + }, function() { + + }]; + $flow = new Flow($jobs, $errorJobs, null, $driver); $ips = []; - $rail->pipe(function (Ip $ip) use ($driver, &$ips, $ip1, $ip2) { + + $callback = function (Ip $ip) use ($driver, &$ips, $ip1, $ip2) { $ips[] = $ip; if(count($ips) === 2) { $this->assertSame($ip1, $ips[0]); $this->assertSame($ip2, $ips[1]); - self::assertSame(6, $ip1->getData()['n1']); - self::assertSame(16, $ip1->getData()['n2']); - self::assertSame(4, $ip2->getData()['n1']); - self::assertSame(20, $ip2->getData()['n2']); + self::assertSame(6, $ip1->data['n1']); + self::assertSame(16, $ip1->data['n2']); + self::assertSame(4, $ip2->data['n1']); + self::assertSame(20, $ip2->data['n2']); $driver->stop(); } - }); + }; - ($rail)($ip1); - ($rail)($ip2); + ($flow)($ip1, $callback); + ($flow)($ip2, $callback); - $driver->run(); + $driver->start(); } /** @@ -79,10 +84,10 @@ public function jobProvider(): array return $this->matrix([ 'job' => [static function (ArrayObject $data) { $data['number'] = 5; - }, 5, null], + }, 5], 'exceptionJob' => [static function () use ($exception) { throw $exception; - }, 0, $exception], + }, 0], ]); } } diff --git a/packages/php/tests/Rail/LambdaRailTest.php b/packages/php/tests/Flow/YFlowTest.php similarity index 57% rename from packages/php/tests/Rail/LambdaRailTest.php rename to packages/php/tests/Flow/YFlowTest.php index 987fc1f8..a3925f8c 100644 --- a/packages/php/tests/Rail/LambdaRailTest.php +++ b/packages/php/tests/Flow/YFlowTest.php @@ -2,34 +2,33 @@ declare(strict_types=1); -namespace RFBP\Test\Rail; +namespace Flow\Test\Flow; use ArrayObject; use Closure; -use RFBP\DriverInterface; -use RFBP\Ip; -use RFBP\IpStrategyInterface; -use RFBP\Rail\LambdaRail; +use Flow\DriverInterface; +use Flow\Ip; +use Flow\IpStrategyInterface; +use Flow\Flow\YFlow; use Throwable; -class LambdaRailTest extends AbstractRailTest +class YFlowTest extends AbstractFlowTest { /** * @dataProvider jobProvider */ - public function testJob(DriverInterface $driver, IpStrategyInterface $ipStrategy, Closure $job, int $resultNumber, ?Throwable $resultException): void + public function testJob(DriverInterface $driver, IpStrategyInterface $ipStrategy, Closure $job, int $resultNumber): void { $ip = new Ip(new ArrayObject(['number' => 6])); - $lambdaRail = new LambdaRail($job, $ipStrategy, $driver); - $lambdaRail->pipe(function (Ip $ip, ?Throwable $exception) use ($driver, $resultNumber, $resultException) { + $errorJob = static function() {}; + $yFlow = new YFlow($job, $errorJob, $ipStrategy, $driver); + ($yFlow)($ip, function (Ip $ip) use ($driver, $resultNumber) { $driver->stop(); - self::assertSame(ArrayObject::class, $ip->getData()::class); - self::assertSame($resultNumber, $ip->getData()['number']); - self::assertSame($resultException, $exception); + self::assertSame(ArrayObject::class, $ip->data::class); + self::assertSame($resultNumber, $ip->data['number']); }); - ($lambdaRail)($ip); - $driver->run(); + $driver->start(); } /** @@ -48,7 +47,7 @@ public function jobProvider(): array $data['number'] = 1; } }; - }, 720, null], + }, 720], ]); } } diff --git a/packages/php/tests/IpStrategy/LinearIpStrategyTest.php b/packages/php/tests/IpStrategy/LinearIpStrategyTest.php index 0968ccbd..ef0a6843 100644 --- a/packages/php/tests/IpStrategy/LinearIpStrategyTest.php +++ b/packages/php/tests/IpStrategy/LinearIpStrategyTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace RFBP\Test\IpStrategy; +namespace Flow\Test\IpStrategy; use PHPUnit\Framework\TestCase; -use RFBP\Ip; -use RFBP\IpStrategy\LinearIpStrategy; +use Flow\Ip; +use Flow\IpStrategy\LinearIpStrategy; class LinearIpStrategyTest extends TestCase { diff --git a/packages/php/tests/IpStrategy/MaxIpStrategyTest.php b/packages/php/tests/IpStrategy/MaxIpStrategyTest.php index 048b4432..197a4e77 100644 --- a/packages/php/tests/IpStrategy/MaxIpStrategyTest.php +++ b/packages/php/tests/IpStrategy/MaxIpStrategyTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace RFBP\Test\IpStrategy; +namespace Flow\Test\IpStrategy; use PHPUnit\Framework\TestCase; -use RFBP\Ip; -use RFBP\IpStrategy\MaxIpStrategy; +use Flow\Ip; +use Flow\IpStrategy\MaxIpStrategy; class MaxIpStrategyTest extends TestCase { diff --git a/packages/php/tests/IpStrategy/StackIpStrategyTest.php b/packages/php/tests/IpStrategy/StackIpStrategyTest.php index b38aae1c..08eae2e8 100644 --- a/packages/php/tests/IpStrategy/StackIpStrategyTest.php +++ b/packages/php/tests/IpStrategy/StackIpStrategyTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace RFBP\Test\IpStrategy; +namespace Flow\Test\IpStrategy; use PHPUnit\Framework\TestCase; -use RFBP\Ip; -use RFBP\IpStrategy\StackIpStrategy; +use Flow\Ip; +use Flow\IpStrategy\StackIpStrategy; class StackIpStrategyTest extends TestCase { diff --git a/packages/php/tests/Rail/ErrorRailTest.php b/packages/php/tests/Rail/ErrorRailTest.php deleted file mode 100644 index 509f916d..00000000 --- a/packages/php/tests/Rail/ErrorRailTest.php +++ /dev/null @@ -1,51 +0,0 @@ - 0])); - $rail = new Rail(function () { - throw new RuntimeException('job rail error'); - }); - $errorRail = new ErrorRail($rail, $job, $ipStrategy, $driver); - $errorRail->pipe(function (Ip $ip, ?Throwable $exception) use ($driver, $resultNumber, $resultException) { - $driver->stop(); - self::assertSame(ArrayObject::class, $ip->getData()::class); - self::assertSame($resultNumber, $ip->getData()['number']); - self::assertSame($resultException, $exception); - }); - ($errorRail)($ip); - - $driver->run(); - } - - /** - * @return array> - */ - public function jobProvider(): array - { - return $this->matrix([ - 'job' => [static function (ArrayObject $data) { - $data['number'] = 5; - }, 5, null], - ]); - } -} diff --git a/packages/php/tests/Rail/SequenceRailTest.php b/packages/php/tests/Rail/SequenceRailTest.php deleted file mode 100644 index 8f83ba09..00000000 --- a/packages/php/tests/Rail/SequenceRailTest.php +++ /dev/null @@ -1,51 +0,0 @@ - 0])); - $rails = [new Rail(function (object $data) { - $data['number'] = 2; - }, null, $driver), new Rail(function (object $data) { - $data['number'] = 4; - }, null, $driver)]; - $rail = new SequenceRail($rails); - $rail->pipe(function (Ip $ip) use ($driver) { - $driver->stop(); - self::assertSame(4, $ip->getData()['number']); - }); - ($rail)($ip); - - $driver->run(); - } - - /** - * @return array> - */ - public function jobProvider(): array - { - return [ - [new AmpDriver()], - [new ReactDriver()], - [new SwooleDriver()], - ]; - } -} diff --git a/packages/php/tests/Transport/Receiver/CollectionReceiverTest.php b/packages/php/tests/Transport/Receiver/CollectionReceiverTest.php index 0bde62fb..5c792815 100644 --- a/packages/php/tests/Transport/Receiver/CollectionReceiverTest.php +++ b/packages/php/tests/Transport/Receiver/CollectionReceiverTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace RFBP\Test\Transport\Receiver; +namespace Flow\Test\Transport\Receiver; use ArrayObject; use PHPUnit\Framework\TestCase; -use RFBP\EnvelopeTrait; -use RFBP\Transport\Receiver\CollectionReceiver; +use Flow\EnvelopeTrait; +use Flow\Transport\Receiver\CollectionReceiver; use SplObjectStorage; use stdClass; use Symfony\Component\Messenger\Envelope; diff --git a/packages/php/tests/Transport/Sender/CollectionSenderTest.php b/packages/php/tests/Transport/Sender/CollectionSenderTest.php index 4398bcdb..4e1d01ea 100644 --- a/packages/php/tests/Transport/Sender/CollectionSenderTest.php +++ b/packages/php/tests/Transport/Sender/CollectionSenderTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace RFBP\Test\Transport\Sender; +namespace Flow\Test\Transport\Sender; use ArrayObject; use PHPUnit\Framework\TestCase; -use RFBP\Transport\Sender\CollectionSender; +use Flow\Transport\Sender\CollectionSender; use stdClass; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Transport\Sender\SenderInterface; diff --git a/theme.toml b/theme.toml index d4001cd5..67010ac7 100644 --- a/theme.toml +++ b/theme.toml @@ -1,10 +1,10 @@ -name = "Railway FBP" +name = "Flow" license = "MIT" -licenselink = "https://github.com/darkwood-fr/railway-fbp/blob/1.x/LICENSE" +licenselink = "https://github.com/darkwood-fr/flow/blob/1.x/LICENSE" description = "Assemble your code by adopting asynchronous as native implementation and build with functional programming and monads." source = "docs" -homepage = "https://github.com/darkwood-fr/railway-fbp" +homepage = "https://github.com/darkwood-fr/flow" demosite = "https://darkwood-fr.github.io" tags = ["landing page", "documentation", "blog", "minimal", "modern", "customizable", "search", "dark mode", "bootstrap"]