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

Add rule for coordination between services of different contexts #348

Merged

Conversation

mLeveIST
Copy link
Contributor

Overview

This change provides a way to represent coordination between services of different contexts, with the addition of a Coordination rule in the Application and Process Layer of Bounded Contexts. Example in CML:

ContextMap TestMap {
    contains ContextA
    contains ContextB

    ContextA <- ContextB
}

BoundedContext ContextA {
    Application {
        Coordination CoordinationA {
            ContextA::ServiceA::stepA;
            ContextB::ServiceB::stepB;
        }

        Service ServiceA {
            void stepA();
        }
    }
}

BoundedContext ContextB {
    Application {
        Service ServiceB {
            void stepB();
        }
    }
}

A Coordination can be visualised in a BPMN diagram with Sketch Miner, where each context will be represented as a different actor, and each operation as a task. The example above generates the following code:

ContextA: service ServiceA.stepA
ContextB: service ServiceB.stepB

Motivation

The main drive for this rule is to be able to model in CML processes that span multiple Bounded Contexts, like Sagas. CML does already provides a Flow rule to model processes, but these processes are restricted to a single Bounded Context and the rule has a focus on modelling Event/Command flows for Event Storming.

Technical Details

The following sections specify details on the implementation of the rule.

Validation

Since the steps of a coordination are composed of references to other rules, the following verifications are done to avoid ambiguity when pinpointing the step operation:

  • A reference to an outer context must be reachable by Context Map relationships
  • A reference to a service must originate from an Application Layer Service
  • A reference to an operation should be unique within the service

IDE integration

The following features were implemented for the IDE when writing in CML:

  • Formatting for the rule
  • Step wise visualisation of validation errors
  • BPMN Sketch Miner diagram code generation
  • Quick-fix to generate and open a Coordination in BPMN Sketch Miner website

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #348 (59f7924) into master (314b9ca) will decrease coverage by 0.4%.
The diff coverage is 77.6%.

@@            Coverage Diff             @@
##             master    #348     +/-   ##
==========================================
- Coverage      93.0%   92.6%   -0.4%     
- Complexity     2354    2406     +52     
==========================================
  Files           204     209      +5     
  Lines          6344    6490    +146     
  Branches        851     875     +24     
==========================================
+ Hits           5902    6016    +114     
- Misses          214     225     +11     
- Partials        228     249     +21     
Files Coverage Δ
...ntextmapper/dsl/ide/actions/CMLActionRegistry.java 86.0% <100.0%> (+0.1%) ⬆️
...pl/OpenCoordinationInSketchMinerCommandMapper.java 100.0% <100.0%> (ø)
...etchminer/SketchMinerCoordinationModelCreator.java 100.0% <100.0%> (ø)
.../generator/sketchminer/SketchMinerLinkCreator.java 100.0% <100.0%> (ø)
...tchminer/converter/SimplifiedCoordinationStep.java 100.0% <100.0%> (ø)
...rg/contextmapper/dsl/scoping/CMLScopingHelper.java 72.0% <ø> (ø)
...ntextmapper/dsl/validation/ValidationMessages.java 0.0% <ø> (ø)
...textmapper/dsl/validation/UniquenessValidator.java 83.5% <85.7%> (+0.1%) ⬆️
...r/converter/Coordination2SketchMinerConverter.java 87.0% <87.0%> (ø)
...textmapper/dsl/generator/SketchMinerGenerator.java 69.2% <50.0%> (-4.5%) ⬇️
... and 2 more

@stefan-ka
Copy link
Member

Thanks for creating the PR @mLeveIST ;)
I will probably need a few days until you get a response (review comments)...
Best regards,
Stefan

Copy link
Member

@stefan-ka stefan-ka left a comment

Choose a reason for hiding this comment

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

Hi @mLeveIST

I have a few small comments (only code-level details), but overall this is very good work 👌 Looking forward to merge it 😊

Can you maybe have a look at the comments? If something is not clear I can help or we discuss it in a short meeting. Another thing we have to prepare is documentation on the website (repo: https://github.com/ContextMapper/contextmapper.github.io).

Best regards,
Stefan


@Test
@DisabledOnOs(OS.WINDOWS)
public void canCreateSketchMinerLinkForCoordinationModelUnix() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

We should also add these tests for Windows. Do you have a Windows machine to test it? Otherwise I can do that...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately I could not test it on a Windows :(

@mLeveIST
Copy link
Contributor Author

Hello Stefan,

Thank you for the review!
I will tag you once I have addressed the comments :)

Best regards,
Miguel

@mLeveIST
Copy link
Contributor Author

Hello @stefan-ka,

I added most of the changes you requested, just missing the test for the Windows machine...
I also added some additional tests for the code coverage.

Regarding the documentation, can this be added to the Application and Process Layer page?

If you have the time this or next week, I wouldn't mind having a small meeting to discuss the results of Coordinations as is, and if you think it is worthwhile to expand upon it in the future (having the type of coordination, the synchronicity of the steps, if they can relate to flows).

Best regards,
Miguel

@stefan-ka
Copy link
Member

Hi @mLeveIST

Thank you! I will try to do the tests on Windows... I will come back to you regarding a meeting. Probably next week earliest.

Best regards,
Stefan

@stefan-ka
Copy link
Member

Sorry @mLeveIST, I forgot to answer your question regarding documentation.

I would say, yes. Or create a new page but then we have to link it on the application layer page.

Best regards,
Stefan

@stefan-ka
Copy link
Member

Hi @mLeveIST

I just realized that we have many other issues with unit tests on Windows 🫣
I suggest we fix that we a separate PR later. I have to fix several other tests to run on Windows...

From my point of view we can then merge it. But lets give @socadk a chance to test the new feature as well.

We'll come back to you.

Best regards,
Stefan

@stefan-ka stefan-ka merged commit cc42f8d into ContextMapper:master Nov 14, 2023
@stefan-ka
Copy link
Member

Hi @mLeveIST

We tested your feature and it looks good from our side, so I merged it right now :)
We'll have to see when we will make the next Context Mapper release; hopefully we can publish one by the end of this year.

Were you already able to do something regarding documentation? ;) I can also put it on my own TODO-list, but I think it would be good if you could do it; also to provide proper background information.

Best regards,
Stefan

@mLeveIST
Copy link
Contributor Author

Hi @stefan-ka,

Thank you for the update! That's great to know.
Regarding documentation, I'll have a pull request for it and also the examples repo soon, most likely sometime next week if that's ok.

Best regards,
Miguel

@stefan-ka
Copy link
Member

Perfect, thanks @mLeveIST!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants