You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "vttranlina (via GitHub)" <gi...@apache.org> on 2024/01/03 08:36:31 UTC

[PR] JAMES-2586 Refactor the way initPostgres of PostgresTableManager [james-project]

vttranlina opened a new pull request, #1896:
URL: https://github.com/apache/james-project/pull/1896

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org


Re: [PR] JAMES-2586 Refactor the way initPostgres of PostgresTableManager [james-project]

Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on code in PR #1896:
URL: https://github.com/apache/james-project/pull/1896#discussion_r1440234438


##########
server/container/guice/configuration/src/main/java/org/apache/james/utils/InitializationOperation.java:
##########
@@ -41,4 +41,9 @@ public interface InitializationOperation {
     default List<Class<?>> requires() {
         return ImmutableList.of();
     }
+
+    default int priority() {
+        return 0;

Review Comment:
   Maybe a constant to avoid the magic number? Like `DEFAULT_PRIORITY`.



##########
server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresCommonModule.java:
##########
@@ -102,16 +103,29 @@ PostgresModule composePostgresDataDefinitions(Set<PostgresModule> modules) {
 
     @Provides
     @Singleton
-    PostgresTableManager postgresTableManager(PostgresExecutor.Factory factory,
+    PostgresTableManager postgresTableManager(PostgresExecutor postgresExecutor,
                                               PostgresModule postgresModule,
                                               PostgresConfiguration postgresConfiguration) {
-        return new PostgresTableManager(factory, postgresModule, postgresConfiguration);
+        return new PostgresTableManager(postgresExecutor, postgresModule, postgresConfiguration);
     }
 
     @Provides
     @Named(DEFAULT_INJECT)
     @Singleton
-    PostgresExecutor defaultPostgresExecutor(PostgresTableManager postgresTableManager) {
-        return postgresTableManager.get();
+    PostgresExecutor defaultPostgresExecutor(PostgresExecutor.Factory factory) {
+        return factory.create();
+    }
+
+    @Provides
+    @Singleton
+    PostgresExecutor postgresExecutor(@Named(DEFAULT_INJECT) PostgresExecutor postgresExecutor) {
+        return postgresExecutor;
+    }
+
+    @ProvidesIntoSet
+    InitializationOperation provisionPostgresTablesAndIndexes(PostgresTableManager postgresTableManager) {
+        return InitilizationOperationBuilder
+            .forClass(PostgresTableManager.class, 2)

Review Comment:
   Maybe a constant to avoid the magic number? Like `HIGH_PRIORITY`. Or whatever better name.



##########
server/container/guice/common/src/main/java/org/apache/james/utils/InitializationOperations.java:
##########
@@ -47,6 +47,7 @@ private Set<InitializationOperation> processStartables() {
         return startables.get().stream()
             .flatMap(this::configurationPerformerFor)
             .distinct()
+            .sorted((a, b) -> Integer.compare(b.priority(), a.priority()))

Review Comment:
   Luv that ^^



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org


Re: [PR] JAMES-2586 Refactor the way initPostgres of PostgresTableManager [james-project]

Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael merged PR #1896:
URL: https://github.com/apache/james-project/pull/1896


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org