Skip to content

Commit

Permalink
Make push notification senders available via CommandDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-signal committed Aug 16, 2024
1 parent 2744d33 commit 0b1ec1e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ record CommandDependencies(
MessagesManager messagesManager,
ClientPresenceManager clientPresenceManager,
KeysManager keysManager,
APNSender apnSender,
FcmSender fcmSender,
PushNotificationManager pushNotificationManager,
PushNotificationExperimentSamples pushNotificationExperimentSamples,
FaultTolerantRedisCluster cacheCluster,
Expand Down Expand Up @@ -254,6 +256,7 @@ static CommandDependencies build(
configuration.getDynamoDbTables().getPushNotificationExperimentSamples().getTableName(),
Clock.systemUTC());

environment.lifecycle().manage(apnSender);
environment.lifecycle().manage(messagesCache);
environment.lifecycle().manage(clientPresenceManager);
environment.lifecycle().manage(new ManagedAwsCrt());
Expand All @@ -266,6 +269,8 @@ static CommandDependencies build(
messagesManager,
clientPresenceManager,
keys,
apnSender,
fcmSender,
pushNotificationManager,
pushNotificationExperimentSamples,
cacheCluster,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@

package org.whispersystems.textsecuregcm.workers;

import static com.codahale.metrics.MetricRegistry.name;

import io.dropwizard.core.Application;
import io.dropwizard.core.cli.ServerCommand;
import io.dropwizard.core.server.DefaultServerFactory;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.jetty.HttpsConnectorFactory;
import java.util.concurrent.ExecutorService;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
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.util.logging.UncaughtExceptionHandler;

Expand Down Expand Up @@ -73,15 +68,9 @@ protected void run(Environment environment, Namespace namespace, WhisperServerCo
});
}

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(
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);

MetricsUtil.registerSystemResourceMetrics(environment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ void setUp() {
null,
null,
null,
null,
null,
pushNotificationExperimentSamples,
null,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private TestNotifyIdleDevicesWithoutMessagesCommand(final MessagesManager messag
null,
null,
null,
null,
null,
null);

this.idleDeviceNotificationScheduler = idleDeviceNotificationScheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public TestStartPushNotificationExperimentCommand(
null,
null,
null,
null,
null,
pushNotificationExperimentSamples,
null,
null,
Expand Down

0 comments on commit 0b1ec1e

Please sign in to comment.