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

Shape legacy code into new interfaces good bits part 2 #9844

Conversation

pihme
Copy link
Contributor

@pihme pihme commented Jul 19, 2022

Description

  • Move logic to select processor into engine
  • Move processing logic into engine
  • Use ProcessingResult to return response and execute side effects
  • Move error handling logic into engine
  • Fix tests

Review Hints

  • most of the commits have some failing tests
  • this was unavoidable, because substeps in the modification were invalid/incomplete
  • In the end, all tests are now passing again. This was quite satisfying acutally - adding more changes and seeing the test failure count go down again
  • Overall I would say we are through the valley of pain. Was quite volatile recently, but I am confident we can bring some calmness back to development
  • This achieves that most of the engine abstraction classes are in play; and the division of labor is largely as intended.
  • Still lots of stuff to do on either side, though

Related issues

related to #9725

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • New content is added to the release announcement
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Please refer to our review guidelines.

pihme added 12 commits July 19, 2022 18:44
Currently, the process builder is handed over to the engine, but
the engine doesn't use it yet to build the result. Instead, the
engine writes to the wrapped response writer directly.

This circumvents the flag and in turn leads to no response being sent.
…gStateMachine

The side effects were already collected by the engine, but nobody
executed the side effects.

Secondly, the sending of the response used to be just another side
effect. Now it is a special action which is under direct control
by ProcessingStateMachine.
This is because sending of responses is now part of the
ProcessingStateMachine. It is a dedicated step and no longer
part of the side effects
Prevent pushing response more than once in DirectProcessingResult

Remove manual call to responseWriter.flush()
The tests failed for two reasons:
The process instance key was not set.
Some intent JobIntent.COMPLETE which should not be blacklisted at all, but was

This was because the old code:
zeebeState.getBlackListState().tryToBlacklist(typedCommand, errorRecord::setProcessInstanceKey);

Did check the intents and did set process instance key with this
strange setter.

Now, we don't use the logic anymore and instead create en error event.
However, the event applier is not aware of the logic and has
no access to the intent of the record that caused the error.
@pihme pihme requested a review from npepinpe July 19, 2022 17:33

public Engine() {}

@Override
public void init(final RecordProcessorContext recordProcessorContext) {
streamWriter = recordProcessorContext.getStreamWriterProxy();

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [RecordProcessorContext.getStreamWriterProxy](1) should be avoided because it has been deprecated.

public Engine() {}

@Override
public void init(final RecordProcessorContext recordProcessorContext) {
streamWriter = recordProcessorContext.getStreamWriterProxy();
responseWriter = recordProcessorContext.getTypedResponseWriter();

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [RecordProcessorContext.getTypedResponseWriter](1) should be avoided because it has been deprecated.

final var zeebeState = typedProcessorContext.getZeebeState();
writers = typedProcessorContext.getWriters();
recordProcessorContext.setWriters(writers);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation

Invoking [RecordProcessorContext.setWriters](1) should be avoided because it has been deprecated.
@github-actions
Copy link
Contributor

github-actions bot commented Jul 19, 2022

Unit Test Results

   792 files  ±  0     792 suites  ±0   1h 36m 52s ⏱️ - 3m 41s
6 067 tests +57  6 058 ✔️ +57  9 💤 ±0  0 ±0 
6 236 runs  +57  6 227 ✔️ +57  9 💤 ±0  0 ±0 

Results for commit 1440ed5. ± Comparison against base commit ec0ac77.

♻️ This comment has been updated with latest results.

Copy link
Member

@npepinpe npepinpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Nothing major, it's nice to see things coming together 👍

@pihme
Copy link
Contributor Author

pihme commented Jul 20, 2022

bors merge

zeebe-bors-camunda bot added a commit that referenced this pull request Jul 20, 2022
9840: `TypedStreamWriter` that writes to buffer r=pihme a=pihme

## Description

- Implements `TypedStreamWriter` that writes to buffer
- Implements processing result builder to use the buffered stream writer
- does not add tests. I started it, but it would take too much time. Hope I can revisit it after my holidays. For now there is just a follow up issue: #9838

## Related issues

closes #9780 



9844: Shape legacy code into new interfaces good bits part 2 r=pihme a=pihme

## Description

- Move logic to select processor into engine
- Move processing logic into engine
- Use `ProcessingResult` to return response and execute side effects
- Move error handling logic into engine
- Fix tests

## Review Hints
- most of the commits have some failing tests
- this was unavoidable, because substeps in the modification were invalid/incomplete
- In the end, all tests are now passing again. This was quite satisfying acutally - adding more changes and seeing the test failure count go down again
- Overall I would say we are through the valley of pain. Was quite volatile recently, but I am confident we can bring some calmness back to development
- This achieves that most of the engine abstraction classes are in play; and the division of labor is largely as intended. 
- Still lots of stuff to do on either side, though

## Related issues

related to #9725



Co-authored-by: pihme <pihme@users.noreply.github.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed (retrying...):

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit 8c5db4d into main Jul 20, 2022
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the 9725-shape-legacy-code-into-new-interfaces-good-bits-part-2 branch July 20, 2022 10:26
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.

None yet

2 participants