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

Multitenancy support #141

Merged
merged 27 commits into from
May 5, 2020
Merged

Multitenancy support #141

merged 27 commits into from
May 5, 2020

Conversation

dmitrykuzmin
Copy link
Contributor

This PR adds the multitenancy support to the JS client.

The Client factory API now accepts a TenantProvider as a part of the passed client options.

The TenantProvider defines the current tenant ID to be used for all requests done with the client.

The current tenant ID can be dynamically updated with the help of TenantProvider.update(TenantId).

For single-tenant applications, the TenantProvider can be omitted in the options.

Spine web version advances to 1.5.4.

dmitrykuzmin and others added 17 commits April 29, 2020 22:12
Due to what is seemingly an issue with the Spine core the `MirrorProjection` messages can be delivered only within a single `BoundedContext` - the one which is registered last. So the "main" bounded context, where the multitenant tests run and multiple aggregates are read, is now registered last and the "auxiliary" single-tenant context will contain a `UserInfo` aggregate and a corresponding projection instead of having a single visible aggregate.

Also fixed how the `observe`d event is handled in the single-tenant tests.
Also documented the tenant-related classes.
...to avoid skipping versions `1.5.4`-`1.5.10` of Spine `web`. The `base` and `core` dependencies remain `1.5.11` and `1.5.10` correspondingly.
@dmitrykuzmin dmitrykuzmin self-assigned this May 4, 2020
@codecov
Copy link

codecov bot commented May 4, 2020

Codecov Report

Merging #141 into master will increase coverage by 0.13%.
The diff coverage is 53.40%.

@@             Coverage Diff              @@
##             master     #141      +/-   ##
============================================
+ Coverage     62.00%   62.14%   +0.13%     
  Complexity      178      178              
============================================
  Files            86       87       +1     
  Lines          2116     2174      +58     
  Branches         38       38              
============================================
+ Hits           1312     1351      +39     
- Misses          795      814      +19     
  Partials          9        9              

@dmitrykuzmin dmitrykuzmin requested review from armiol and dmdashenkov May 4, 2020 16:08
@dmitrykuzmin
Copy link
Contributor Author

@armiol, @dmdashenkov PTAL.

* @param {!string} tenantIdValue the tenant ID
* @return {TenantId} a new `TenantId` instance
*/
static plainString(tenantIdValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's have convenience methods for other types of TennantIds as well.

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the empty line.

@@ -1,6 +1,6 @@
{
"name": "spine-web",
"version": "1.5.3",
"version": "1.5.11",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep in sync this version and the version quoted in the PR description.

import io.spine.core.UserId;
import io.spine.server.aggregate.AggregateRepository;

class UserInfoRepository extends AggregateRepository<UserId, UserInfoAggregate> {
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
class UserInfoRepository extends AggregateRepository<UserId, UserInfoAggregate> {
final class UserInfoRepository extends AggregateRepository<UserId, UserInfoAggregate> {

import io.spine.core.UserId;
import io.spine.server.projection.ProjectionRepository;

class UserInfoViewRepository
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
class UserInfoViewRepository
final class UserInfoViewRepository

@dmitrykuzmin dmitrykuzmin requested a review from dmdashenkov May 5, 2020 13:16
@dmitrykuzmin
Copy link
Contributor Author

@dmdashenkov PTAL again.

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 with a couple of comments to discuss.

import io.spine.core.UserId;
import io.spine.server.aggregate.AggregateRepository;

final class UserInfoRepository extends AggregateRepository<UserId, UserInfoAggregate> {
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 if you can use the default repository instead of explicitly declaring one.

import io.spine.core.UserId;
import io.spine.server.projection.ProjectionRepository;

final class UserInfoViewRepository
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@dmitrykuzmin dmitrykuzmin merged commit 6b4d32c into master May 5, 2020
@dmitrykuzmin dmitrykuzmin deleted the multitenancy-support branch May 5, 2020 18:15
@dmitrykuzmin dmitrykuzmin mentioned this pull request Sep 8, 2020
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.

2 participants