0
0
mirror of https://github.com/signalapp/Signal-Server.git synced 2024-09-19 19:42:18 +02:00

Make push notification senders available via CommandDependencies

This commit is contained in:
Jon Chambers 2024-08-16 16:45:33 -04:00 committed by Jon Chambers
parent 2744d33ef8
commit 0b1ec1e50b
5 changed files with 12 additions and 12 deletions

View File

@ -75,6 +75,8 @@ record CommandDependencies(
MessagesManager messagesManager, MessagesManager messagesManager,
ClientPresenceManager clientPresenceManager, ClientPresenceManager clientPresenceManager,
KeysManager keysManager, KeysManager keysManager,
APNSender apnSender,
FcmSender fcmSender,
PushNotificationManager pushNotificationManager, PushNotificationManager pushNotificationManager,
PushNotificationExperimentSamples pushNotificationExperimentSamples, PushNotificationExperimentSamples pushNotificationExperimentSamples,
FaultTolerantRedisCluster cacheCluster, FaultTolerantRedisCluster cacheCluster,
@ -254,6 +256,7 @@ record CommandDependencies(
configuration.getDynamoDbTables().getPushNotificationExperimentSamples().getTableName(), configuration.getDynamoDbTables().getPushNotificationExperimentSamples().getTableName(),
Clock.systemUTC()); Clock.systemUTC());
environment.lifecycle().manage(apnSender);
environment.lifecycle().manage(messagesCache); environment.lifecycle().manage(messagesCache);
environment.lifecycle().manage(clientPresenceManager); environment.lifecycle().manage(clientPresenceManager);
environment.lifecycle().manage(new ManagedAwsCrt()); environment.lifecycle().manage(new ManagedAwsCrt());
@ -266,6 +269,8 @@ record CommandDependencies(
messagesManager, messagesManager,
clientPresenceManager, clientPresenceManager,
keys, keys,
apnSender,
fcmSender,
pushNotificationManager, pushNotificationManager,
pushNotificationExperimentSamples, pushNotificationExperimentSamples,
cacheCluster, cacheCluster,

View File

@ -5,20 +5,15 @@
package org.whispersystems.textsecuregcm.workers; package org.whispersystems.textsecuregcm.workers;
import static com.codahale.metrics.MetricRegistry.name;
import io.dropwizard.core.Application; import io.dropwizard.core.Application;
import io.dropwizard.core.cli.ServerCommand; import io.dropwizard.core.cli.ServerCommand;
import io.dropwizard.core.server.DefaultServerFactory; import io.dropwizard.core.server.DefaultServerFactory;
import io.dropwizard.core.setup.Environment; import io.dropwizard.core.setup.Environment;
import io.dropwizard.jetty.HttpsConnectorFactory; import io.dropwizard.jetty.HttpsConnectorFactory;
import java.util.concurrent.ExecutorService;
import net.sourceforge.argparse4j.inf.Namespace; import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser; import net.sourceforge.argparse4j.inf.Subparser;
import org.whispersystems.textsecuregcm.WhisperServerConfiguration; import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
import org.whispersystems.textsecuregcm.metrics.MetricsUtil; import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
import org.whispersystems.textsecuregcm.push.APNSender;
import org.whispersystems.textsecuregcm.push.FcmSender;
import org.whispersystems.textsecuregcm.push.PushNotificationScheduler; import org.whispersystems.textsecuregcm.push.PushNotificationScheduler;
import org.whispersystems.textsecuregcm.util.logging.UncaughtExceptionHandler; import org.whispersystems.textsecuregcm.util.logging.UncaughtExceptionHandler;
@ -73,15 +68,9 @@ public class ScheduledApnPushNotificationSenderServiceCommand extends ServerComm
}); });
} }
final ExecutorService pushNotificationSenderExecutor = environment.lifecycle().executorService(name(getClass(), "apnSender-%d"))
.maxThreads(1).minThreads(1).build();
final APNSender apnSender = new APNSender(pushNotificationSenderExecutor, configuration.getApnConfiguration());
final FcmSender fcmSender = new FcmSender(pushNotificationSenderExecutor, configuration.getFcmConfiguration().credentials().value());
final PushNotificationScheduler pushNotificationScheduler = new PushNotificationScheduler( final PushNotificationScheduler pushNotificationScheduler = new PushNotificationScheduler(
deps.pushSchedulerCluster(), apnSender, fcmSender, deps.accountsManager(), namespace.getInt(WORKER_COUNT), namespace.getInt(MAX_CONCURRENCY)); deps.pushSchedulerCluster(), deps.apnSender(), deps.fcmSender(), deps.accountsManager(), namespace.getInt(WORKER_COUNT), namespace.getInt(MAX_CONCURRENCY));
environment.lifecycle().manage(apnSender);
environment.lifecycle().manage(pushNotificationScheduler); environment.lifecycle().manage(pushNotificationScheduler);
MetricsUtil.registerSystemResourceMetrics(environment); MetricsUtil.registerSystemResourceMetrics(environment);

View File

@ -72,6 +72,8 @@ class FinishPushNotificationExperimentCommandTest {
null, null,
null, null,
null, null,
null,
null,
pushNotificationExperimentSamples, pushNotificationExperimentSamples,
null, null,
null, null,

View File

@ -65,6 +65,8 @@ class NotifyIdleDevicesWithoutMessagesCommandTest {
null, null,
null, null,
null, null,
null,
null,
null); null);
this.idleDeviceNotificationScheduler = idleDeviceNotificationScheduler; this.idleDeviceNotificationScheduler = idleDeviceNotificationScheduler;

View File

@ -61,6 +61,8 @@ class StartPushNotificationExperimentCommandTest {
null, null,
null, null,
null, null,
null,
null,
pushNotificationExperimentSamples, pushNotificationExperimentSamples,
null, null,
null, null,