Skip to content

Conversation

yevhenii-nadtochii
Copy link

@yevhenii-nadtochii yevhenii-nadtochii commented Oct 28, 2021

It's a migration of #1407 to the 2.x branch.

Problem

Previously, in scope of 2.x versions it was impossible to obtain a Client to some BlackBox context. That was a problem, since in a multi-Bounded-Context environment, the contexts often communicated with each other with the Clients. And the black-boxing of either clients made it very difficult to run the integration flow — as no proper Client could be created for the black-boxed Bounded Context.

Solution

It is now possible to create an in-process Client to any BlackBox:

BlackBox box = ...

// Creates the instance with the same `TenantId` as the one currently set in the `box`.
Client client = box.clients().withMatchingTenant();

// For multi-tenant Contexts only, it is also possible to create a `Client` with a specific tenant:
Client client = box.clients().create(myTenant);

The created Client instances are running through the in-process gRPC server. The lifecycle of this server is similar to the lifecycle of the associated BlackBox: once the box is closed, the server is closed as well.

Other Changes

The versions of the dependencies and the own version of core-java modules were set to the latest available.

@yevhenii-nadtochii yevhenii-nadtochii changed the base branch from master to integration-broker-feature October 28, 2021 16:36
@codecov
Copy link

codecov bot commented Oct 28, 2021

Codecov Report

Merging #1409 (acfae46) into master (a3fe6f8) will increase coverage by 0.03%.
The diff coverage is 94.87%.

@@             Coverage Diff              @@
##             master    #1409      +/-   ##
============================================
+ Coverage     91.10%   91.13%   +0.03%     
- Complexity     4908     4929      +21     
============================================
  Files           626      628       +2     
  Lines         15342    15420      +78     
  Branches        890      893       +3     
============================================
+ Hits          13977    14053      +76     
+ Misses         1065     1064       -1     
- Partials        300      303       +3     

@yevhenii-nadtochii yevhenii-nadtochii marked this pull request as ready for review November 1, 2021 09:05
@armiol armiol self-requested a review November 1, 2021 13:39
Base automatically changed from integration-broker-feature to master November 12, 2021 13:25
@armiol armiol self-assigned this Nov 12, 2021
@armiol armiol removed their request for review November 12, 2021 14:51
@armiol armiol changed the title Make BlackBoxContext provide a Client linked to the context under the test Make BlackBox provide a Client linked to the context under-the-test Nov 15, 2021
@armiol
Copy link
Contributor

armiol commented Nov 15, 2021

@yevhenii-nadtochii PTAL. Should you have any comments, let's discuss them vocally.

@armiol armiol requested a review from a team November 15, 2021 17:12
Copy link
Author

@yevhenii-nadtochii yevhenii-nadtochii left a comment

Choose a reason for hiding this comment

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

Please see my questions

@@ -93,6 +94,11 @@
*/
private final BoundedContext context;

/**
* A supplier of {@link Client}s which are linked to this context.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* A supplier of {@link Client}s which are linked to this context.
* A supplier of {@link Client}s which send requests to this context.

Comment on lines 481 to 484
if(!isOpen()) {
return;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if(!isOpen()) {
return;
}
if (!isOpen()) {
return;
}

import static com.google.common.base.Preconditions.checkNotNull;

/**
* Creates the {@link Client}s to a particular {@link BlackBox} instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check the grammar around articles here.
I'd expect:

Creates Clients for a ...

* <p>As {@code Client} requires a gRPC server to be connected to, the supplier assembles
* and starts a {@link GrpcContainer}. The server and the created clients are working in-process.
*/
class ClientSupplier implements Closeable {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be called Clients so that it's coherent with the BlackBoxClients. Maybe, ClientFactory, but then the BlackBoxClients should also be renamed.

This type is too complicated to be a "supplier".

Copy link
Contributor

@dmdashenkov dmdashenkov left a comment

Choose a reason for hiding this comment

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

LGTM.

@armiol armiol merged commit 894d7a8 into master Nov 16, 2021
@armiol armiol deleted the black-box-feature branch November 16, 2021 15:08
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