Skip to content

Add a writer that transform items before delegating to another writer #65

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

Merged
merged 2 commits into from
May 31, 2022

Conversation

yann-eugone
Copy link
Contributor

@yann-eugone yann-eugone commented May 18, 2022

This one might be a game changer, combined with recent additions.we will be able to do many things in write process.

Example :

new ItemJob(
    500, 
    new JsonLinesReader(/* dependencies */),
    /* your processor that convert json line to an entity*/,
    new ChainWriter(
        [
            new ObjectWriter(/* dependencies */),
            new ConditionalWriter(
                fn ($entity) => /* your condition to detect entity was created */,
                new TransformingWriter(
                    new CallbackProcessor(fn () => new NewEntityCreated()),
                    new DispatchEachItemAsMessageWriter(/* dependencies */)
                )
            ),
        ]
    ), 
    /*  dependencies  */
);
  • read from a json file
  • convert each line to an entity
  • persist/flush each converted entities
  • if entity is new, dispatch a message in the bus

@codecov
Copy link

codecov bot commented May 18, 2022

Codecov Report

Merging #65 (08af435) into 0.x (69b3cf6) will not change coverage.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##                 0.x       #65   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       724       734   +10     
===========================================
  Files            124       125    +1     
  Lines           1846      1871   +25     
===========================================
+ Hits            1846      1871   +25     
Impacted Files Coverage Δ
...c/batch/src/Job/Item/Writer/TransformingWriter.php 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69b3cf6...08af435. Read the comment docs.

@yann-eugone yann-eugone requested review from halundraN and J-Ben87 May 18, 2022 08:57
@yann-eugone yann-eugone merged commit e51b748 into 0.x May 31, 2022
@yann-eugone yann-eugone deleted the transforming-writer branch June 18, 2022 08:45
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.

3 participants