Skip to content

Commit

Permalink
Drop tmail-common module
Browse files Browse the repository at this point in the history
  • Loading branch information
vttranlina committed Jan 17, 2025
1 parent 11f52fd commit 8780cbf
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package com.linagora.tmail.james.app;

import static com.linagora.tmail.event.TmailEventModule.TMAIL_EVENT_BUS_INJECT_NAME;

import jakarta.inject.Named;

import org.apache.james.events.CassandraEventDeadLetters;
Expand All @@ -29,14 +31,13 @@
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.linagora.tmail.common.event.TmailInjectNameConstants;
import com.linagora.tmail.event.TmailEventSerializer;

public class TmailEventDeadLettersModule extends AbstractModule {

@Provides
@Singleton
@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME)
@Named(TMAIL_EVENT_BUS_INJECT_NAME)
EventDeadLetters provideEventDeadLetters(CassandraEventDeadLettersGroupDAO cassandraEventDeadLettersGroupDAO,
CqlSession session,
TmailEventSerializer tmailEventSerializer) {
Expand Down
40 changes: 0 additions & 40 deletions tmail-backend/backend-commons/tmail-common/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions tmail-backend/blob/secondary-blob-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<name>Twake Mail :: Blob :: SecondaryBlobStore</name>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>tmail-common</artifactId>
</dependency>

<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>blob-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
import org.apache.james.blob.api.BlobStoreDAO;
import org.apache.james.blob.api.BucketName;
import org.apache.james.events.Event;
import org.apache.james.events.EventListener;
import org.apache.james.events.Group;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.linagora.tmail.common.event.TmailReactiveGroupEventListener;

import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

public class FailedBlobOperationListener implements TmailReactiveGroupEventListener {
public class FailedBlobOperationListener implements EventListener.ReactiveGroupEventListener {
public static final Logger LOGGER = LoggerFactory.getLogger(FailedBlobOperationListener.class);

public static class FailedBlobOperationListenerGroup extends Group {
Expand Down
5 changes: 0 additions & 5 deletions tmail-backend/guice/blob-guice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
<groupId>${project.groupId}</groupId>
<artifactId>secondary-blob-store</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>tmail-common</artifactId>
</dependency>

<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>apache-james-backends-cassandra</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.james.blob.objectstorage.aws.sse.S3SSECConfiguration;
import org.apache.james.blob.objectstorage.aws.sse.S3SSECustomerKeyFactory;
import org.apache.james.events.EventBus;
import org.apache.james.events.EventListener;
import org.apache.james.eventsourcing.Event;
import org.apache.james.eventsourcing.eventstore.dto.EventDTO;
import org.apache.james.eventsourcing.eventstore.dto.EventDTOModule;
Expand Down Expand Up @@ -74,15 +75,14 @@
import com.linagora.tmail.blob.blobid.list.SingleSaveBlobStoreDAO;
import com.linagora.tmail.blob.secondaryblobstore.FailedBlobOperationListener;
import com.linagora.tmail.blob.secondaryblobstore.SecondaryBlobStoreDAO;
import com.linagora.tmail.common.event.TmailInjectNameConstants;
import com.linagora.tmail.common.event.TmailReactiveGroupEventListener;

public class BlobStoreModulesChooser {
public static final String INITIAL_BLOBSTORE_DAO = "initial_blobstore_dao";
public static final String MAYBE_SECONDARY_BLOBSTORE = "maybe_secondary_blob_store_dao";
public static final String MAYBE_ENCRYPTION_BLOBSTORE = "maybe_encryption_blob_store_dao";
public static final String MAYBE_SINGLE_SAVE_BLOBSTORE = "maybe_single_save_blob_store_dao";
public static final String SECOND_BLOB_STORE_DAO = "second_blob_store_dao";
public static final String TMAIL_EVENT_BUS_INJECT_NAME = "TMAIL_EVENT_BUS";

static class ObjectStorageBlobStoreDAODeclarationModule extends AbstractModule {
@Override
Expand Down Expand Up @@ -161,8 +161,9 @@ BlobStoreDAO getSecondaryS3BlobStoreDAO(BlobId.Factory blobIdFactory,
}

@ProvidesIntoSet
TmailReactiveGroupEventListener provideFailedBlobOperationListener(@Named(INITIAL_BLOBSTORE_DAO) BlobStoreDAO firstBlobStoreDAO,
@Named(SECOND_BLOB_STORE_DAO) BlobStoreDAO secondBlobStoreDAO) {
@Named(TMAIL_EVENT_BUS_INJECT_NAME)
EventListener.ReactiveGroupEventListener provideFailedBlobOperationListener(@Named(INITIAL_BLOBSTORE_DAO) BlobStoreDAO firstBlobStoreDAO,
@Named(SECOND_BLOB_STORE_DAO) BlobStoreDAO secondBlobStoreDAO) {
return new FailedBlobOperationListener(firstBlobStoreDAO, secondBlobStoreDAO, secondaryS3BlobStoreConfiguration.secondaryBucketSuffix());
}

Expand All @@ -171,7 +172,7 @@ TmailReactiveGroupEventListener provideFailedBlobOperationListener(@Named(INITIA
@Named(MAYBE_SECONDARY_BLOBSTORE)
BlobStoreDAO provideSecondaryBlobStoreDAO(@Named(INITIAL_BLOBSTORE_DAO) BlobStoreDAO firstBlobStoreDAO,
@Named(SECOND_BLOB_STORE_DAO) BlobStoreDAO secondBlobStoreDAO,
@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME) EventBus eventBus) {
@Named(TMAIL_EVENT_BUS_INJECT_NAME) EventBus eventBus) {
return new SecondaryBlobStoreDAO(firstBlobStoreDAO, secondBlobStoreDAO, secondaryS3BlobStoreConfiguration.secondaryBucketSuffix(), eventBus);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.james.events.EventBusId;
import org.apache.james.events.EventBusName;
import org.apache.james.events.EventDeadLetters;
import org.apache.james.events.EventListener;
import org.apache.james.events.EventSerializer;
import org.apache.james.events.NamingStrategy;
import org.apache.james.events.RabbitMQEventBus;
Expand All @@ -47,28 +48,29 @@
import com.google.inject.multibindings.Multibinder;
import com.google.inject.multibindings.ProvidesIntoSet;
import com.google.inject.name.Names;
import com.linagora.tmail.common.event.TmailInjectNameConstants;
import com.linagora.tmail.common.event.TmailReactiveGroupEventListener;

import reactor.rabbitmq.Sender;

public class TmailEventModule extends AbstractModule {
public static final NamingStrategy TMAIL_NAMING_STRATEGY = new NamingStrategy(new EventBusName("tmailEvent"));
public static final String TMAIL_EVENT_BUS_INJECT_NAME = "TMAIL_EVENT_BUS";

@Override
protected void configure() {
bind(TmailEventSerializer.class).in(Scopes.SINGLETON);
bind(EventBusId.class).annotatedWith(Names.named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME)).toInstance(EventBusId.random());
bind(EventBusId.class).annotatedWith(Names.named(TMAIL_EVENT_BUS_INJECT_NAME)).toInstance(EventBusId.random());

Multibinder.newSetBinder(binder(), EventSerializer.class)
.addBinding()
.to(TmailEventSerializer.class);
Multibinder.newSetBinder(binder(), TmailReactiveGroupEventListener.class);
Multibinder.newSetBinder(binder(), EventListener.ReactiveGroupEventListener.class,
Names.named(TMAIL_EVENT_BUS_INJECT_NAME));

}

@ProvidesIntoSet
InitializationOperation workQueue(@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME) RabbitMQEventBus instance,
Set<TmailReactiveGroupEventListener> tmailReactiveGroupEventListeners) {
InitializationOperation workQueue(@Named(TMAIL_EVENT_BUS_INJECT_NAME) RabbitMQEventBus instance,
@Named(TMAIL_EVENT_BUS_INJECT_NAME) Set<EventListener.ReactiveGroupEventListener> tmailReactiveGroupEventListeners) {
return InitilizationOperationBuilder
.forClass(RabbitMQEventBus.class)
.init(() -> {
Expand All @@ -79,12 +81,12 @@ InitializationOperation workQueue(@Named(TmailInjectNameConstants.TMAIL_EVENT_BU

@Provides
@Singleton
@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME)
@Named(TMAIL_EVENT_BUS_INJECT_NAME)
RabbitMQEventBus provideEmailAddressContactEventBus(Sender sender, ReceiverProvider receiverProvider,
RetryBackoffConfiguration retryBackoffConfiguration,
@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME) EventDeadLetters eventDeadLetters,
@Named(TMAIL_EVENT_BUS_INJECT_NAME) EventDeadLetters eventDeadLetters,
MetricFactory metricFactory, ReactorRabbitMQChannelPool channelPool,
@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME) EventBusId eventBusId,
@Named(TMAIL_EVENT_BUS_INJECT_NAME) EventBusId eventBusId,
RabbitMQConfiguration configuration,
TmailEventSerializer tmailEventSerializer) {
return new RabbitMQEventBus(
Expand All @@ -95,13 +97,13 @@ sender, receiverProvider, tmailEventSerializer, retryBackoffConfiguration, new R

@Provides
@Singleton
@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME)
EventBus provideEmailAddressContactEventBus(@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME) RabbitMQEventBus eventBus) {
@Named(TMAIL_EVENT_BUS_INJECT_NAME)
EventBus provideEmailAddressContactEventBus(@Named(TMAIL_EVENT_BUS_INJECT_NAME) RabbitMQEventBus eventBus) {
return eventBus;
}

@ProvidesIntoSet
EventBus registerEventBus(@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME) EventBus eventBus) {
EventBus registerEventBus(@Named(TMAIL_EVENT_BUS_INJECT_NAME) EventBus eventBus) {
return eventBus;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.linagora.tmail.james;

import static com.linagora.tmail.blob.guice.BlobStoreModulesChooser.MAYBE_SECONDARY_BLOBSTORE;
import static com.linagora.tmail.event.TmailEventModule.TMAIL_EVENT_BUS_INJECT_NAME;
import static io.netty.handler.codec.http.HttpHeaderNames.ACCEPT;
import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.requestSpecification;
Expand Down Expand Up @@ -83,7 +84,6 @@
import com.linagora.tmail.blob.secondaryblobstore.FailedBlobEvents;
import com.linagora.tmail.blob.secondaryblobstore.FailedBlobOperationListener;
import com.linagora.tmail.blob.secondaryblobstore.SecondaryBlobStoreDAO;
import com.linagora.tmail.common.event.TmailInjectNameConstants;
import com.linagora.tmail.encrypted.MailboxConfiguration;
import com.linagora.tmail.james.app.CassandraExtension;
import com.linagora.tmail.james.app.DistributedJamesConfiguration;
Expand Down Expand Up @@ -119,7 +119,7 @@ static class BlobStoreProbe implements GuiceProbe {

@Inject
public BlobStoreProbe(@Named(MAYBE_SECONDARY_BLOBSTORE) BlobStoreDAO blobStoreDAO,
@Named(TmailInjectNameConstants.TMAIL_EVENT_BUS_INJECT_NAME) EventDeadLetters eventDeadLetters) {
@Named(TMAIL_EVENT_BUS_INJECT_NAME) EventDeadLetters eventDeadLetters) {
SecondaryBlobStoreDAO secondaryBlobStoreDAO = (SecondaryBlobStoreDAO) blobStoreDAO;
this.primaryBlobStoreDAO = (S3BlobStoreDAO) secondaryBlobStoreDAO.getFirstBlobStoreDAO();
this.secondaryBlobStoreDAO = (S3BlobStoreDAO) secondaryBlobStoreDAO.getSecondBlobStoreDAO();
Expand Down
7 changes: 0 additions & 7 deletions tmail-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
<modules>
<module>apps</module>

<module>backend-commons/tmail-common</module>

<module>blob/blobid-list</module>
<module>blob/secondary-blob-store</module>

Expand Down Expand Up @@ -187,11 +185,6 @@
<artifactId>secondary-blob-store</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>tmail-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>tmail-guice-common</artifactId>
Expand Down

0 comments on commit 8780cbf

Please sign in to comment.