linagora / james-project

Mirror of Apache James Project
Apache License 2.0
72 stars 62 forks source link

[Multitenant] Memory multitenancy implem (bucket per tenant) #5283

Open vttranlina opened 1 month ago

vttranlina commented 1 month ago

Epic: https://github.com/linagora/james-project/issues/5263

How

Create a new class: MemoryMultiTenancyByBucketBlobStoreDAO implements BlobStoreDAO

We will decorate the BucketName based on the Bucket object The code would look like this:

public BucketName decoratedBucketname(Bucket bucket) {
    return bucket.tenant()
        .map(tenant -> bucket.bucketName().asString() +"-" + tenant.asString())
        .map(BucketName::of)
        .orElse(bucket.bucketName());
}

Then, the method implementation will be:

@Override
public InputStream read(Bucket bucket, BlobId blobId) {
    BucketName decoratedBucketName = decoratedBucketname(bucket);
    return memoryBlobStoreDAO.read(decoratedBucketName, blobId);
}

Dod

Arsnael commented 3 weeks ago

Should refactor MemoryBlobStoreDAO and not create an other DAO for this

Arsnael commented 3 weeks ago

Memory always using multitenancy for different domains? Or need some conf to denable/disable it?

Should have a special contract test for multitenancy