From c95fff7ebc5c5266b01d84f0572b78657437f67c Mon Sep 17 00:00:00 2001
From: Vaibhav <thevaibhavdixit@gmail.com>
Date: Thu, 15 Feb 2024 21:26:22 +0530
Subject: [PATCH] chore(notifications): rename executor to push_executor
 (#4005)

---
 core/notifications/src/app/config.rs                 |  4 ++--
 core/notifications/src/app/error.rs                  |  4 ++--
 core/notifications/src/app/mod.rs                    |  4 ++--
 core/notifications/src/job/error.rs                  |  4 ++--
 core/notifications/src/job/mod.rs                    |  6 +++---
 core/notifications/src/job/send_push_notification.rs |  4 ++--
 core/notifications/src/lib.rs                        |  2 +-
 .../src/{executor => push_executor}/config.rs        |  2 +-
 .../src/{executor => push_executor}/error.rs         |  2 +-
 .../src/{executor => push_executor}/fcm/config.rs    |  0
 .../src/{executor => push_executor}/fcm/error.rs     |  0
 .../src/{executor => push_executor}/fcm/mod.rs       |  0
 .../src/{executor => push_executor}/mod.rs           | 12 ++++++------
 13 files changed, 22 insertions(+), 22 deletions(-)
 rename core/notifications/src/{executor => push_executor}/config.rs (82%)
 rename core/notifications/src/{executor => push_executor}/error.rs (92%)
 rename core/notifications/src/{executor => push_executor}/fcm/config.rs (100%)
 rename core/notifications/src/{executor => push_executor}/fcm/error.rs (100%)
 rename core/notifications/src/{executor => push_executor}/fcm/mod.rs (100%)
 rename core/notifications/src/{executor => push_executor}/mod.rs (91%)

diff --git a/core/notifications/src/app/config.rs b/core/notifications/src/app/config.rs
index 9bd14b0e35..3d5f8d0217 100644
--- a/core/notifications/src/app/config.rs
+++ b/core/notifications/src/app/config.rs
@@ -1,8 +1,8 @@
 use serde::{Deserialize, Serialize};
 
-use crate::executor::ExecutorConfig;
+use crate::push_executor::PushExecutorConfig;
 
 #[derive(Clone, Default, Serialize, Deserialize)]
 pub struct AppConfig {
-    pub executor: ExecutorConfig,
+    pub executor: PushExecutorConfig,
 }
diff --git a/core/notifications/src/app/error.rs b/core/notifications/src/app/error.rs
index a51e51c027..1b8c5dbbe4 100644
--- a/core/notifications/src/app/error.rs
+++ b/core/notifications/src/app/error.rs
@@ -1,7 +1,7 @@
 use thiserror::Error;
 
 use crate::{
-    executor::error::ExecutorError, job::error::JobError,
+    job::error::JobError, push_executor::error::PushExecutorError,
     user_notification_settings::error::UserNotificationSettingsError,
 };
 
@@ -12,7 +12,7 @@ pub enum ApplicationError {
     #[error("{0}")]
     JobError(#[from] JobError),
     #[error("{0}")]
-    ExecutorError(#[from] ExecutorError),
+    PushExecutorError(#[from] PushExecutorError),
     #[error("{0}")]
     Sqlx(#[from] sqlx::Error),
 }
diff --git a/core/notifications/src/app/mod.rs b/core/notifications/src/app/mod.rs
index ab96ba1d5b..fd3ade9a6b 100644
--- a/core/notifications/src/app/mod.rs
+++ b/core/notifications/src/app/mod.rs
@@ -8,7 +8,7 @@ use tracing::instrument;
 use std::sync::Arc;
 
 use crate::{
-    executor::*, job, notification_event::*, primitives::*, user_notification_settings::*,
+    job, notification_event::*, primitives::*, push_executor::*, user_notification_settings::*,
 };
 
 pub use config::*;
@@ -25,7 +25,7 @@ pub struct NotificationsApp {
 impl NotificationsApp {
     pub async fn init(pool: Pool<Postgres>, config: AppConfig) -> Result<Self, ApplicationError> {
         let settings = UserNotificationSettingsRepo::new(&pool);
-        let executor = Executor::init(config.executor.clone(), settings.clone()).await?;
+        let executor = PushExecutor::init(config.executor.clone(), settings.clone()).await?;
         let runner = job::start_job_runner(&pool, executor).await?;
         Ok(Self {
             _config: config,
diff --git a/core/notifications/src/job/error.rs b/core/notifications/src/job/error.rs
index 8c7bd5ec3c..c52a01a0f1 100644
--- a/core/notifications/src/job/error.rs
+++ b/core/notifications/src/job/error.rs
@@ -1,13 +1,13 @@
 use thiserror::Error;
 
-use crate::executor::error::ExecutorError;
+use crate::push_executor::error::PushExecutorError;
 
 #[derive(Error, Debug)]
 pub enum JobError {
     #[error("JobError - Sqlx: {0}")]
     Sqlx(#[from] sqlx::Error),
     #[error("JobError - ExecutorError: {0}")]
-    Executor(#[from] ExecutorError),
+    PushExecutor(#[from] PushExecutorError),
 }
 
 impl job_executor::JobExecutionError for JobError {}
diff --git a/core/notifications/src/job/mod.rs b/core/notifications/src/job/mod.rs
index 55e86bbb63..fa662d2963 100644
--- a/core/notifications/src/job/mod.rs
+++ b/core/notifications/src/job/mod.rs
@@ -7,7 +7,7 @@ use tracing::instrument;
 
 use job_executor::JobExecutor;
 
-use crate::executor::Executor;
+use crate::push_executor::PushExecutor;
 
 use error::JobError;
 
@@ -15,7 +15,7 @@ use send_push_notification::SendPushNotificationData;
 
 pub async fn start_job_runner(
     pool: &sqlx::PgPool,
-    executor: Executor,
+    executor: PushExecutor,
 ) -> Result<JobRunnerHandle, JobError> {
     let mut registry = JobRegistry::new(&[send_push_notification]);
     registry.set_context(executor);
@@ -29,7 +29,7 @@ pub async fn start_job_runner(
 )]
 async fn send_push_notification(
     mut current_job: CurrentJob,
-    executor: Executor,
+    executor: PushExecutor,
 ) -> Result<(), JobError> {
     JobExecutor::builder(&mut current_job)
         .build()
diff --git a/core/notifications/src/job/send_push_notification.rs b/core/notifications/src/job/send_push_notification.rs
index 2cd59a56f3..d6549efcf5 100644
--- a/core/notifications/src/job/send_push_notification.rs
+++ b/core/notifications/src/job/send_push_notification.rs
@@ -4,7 +4,7 @@ use tracing::instrument;
 use std::collections::HashMap;
 
 use super::error::JobError;
-use crate::{executor::Executor, notification_event::NotificationEventPayload};
+use crate::{notification_event::NotificationEventPayload, push_executor::PushExecutor};
 
 #[derive(Debug, Serialize, Deserialize)]
 pub(super) struct SendPushNotificationData {
@@ -25,7 +25,7 @@ impl From<NotificationEventPayload> for SendPushNotificationData {
 #[instrument(name = "job.send_push_notification", skip(executor), err)]
 pub async fn execute(
     data: SendPushNotificationData,
-    executor: Executor,
+    executor: PushExecutor,
 ) -> Result<SendPushNotificationData, JobError> {
     executor.notify(&data.payload).await?;
     Ok(data)
diff --git a/core/notifications/src/lib.rs b/core/notifications/src/lib.rs
index 1cb5b71a63..f662191b70 100644
--- a/core/notifications/src/lib.rs
+++ b/core/notifications/src/lib.rs
@@ -9,9 +9,9 @@ mod job;
 mod messages;
 
 pub mod cli;
-pub mod executor;
 pub mod graphql;
 pub mod grpc;
 pub mod notification_event;
 pub mod primitives;
+pub mod push_executor;
 pub mod user_notification_settings;
diff --git a/core/notifications/src/executor/config.rs b/core/notifications/src/push_executor/config.rs
similarity index 82%
rename from core/notifications/src/executor/config.rs
rename to core/notifications/src/push_executor/config.rs
index 397da3efd0..e698ca058e 100644
--- a/core/notifications/src/executor/config.rs
+++ b/core/notifications/src/push_executor/config.rs
@@ -3,6 +3,6 @@ use serde::{Deserialize, Serialize};
 use super::fcm::FcmConfig;
 
 #[derive(Clone, Default, Debug, Deserialize, Serialize)]
-pub struct ExecutorConfig {
+pub struct PushExecutorConfig {
     pub fcm: FcmConfig,
 }
diff --git a/core/notifications/src/executor/error.rs b/core/notifications/src/push_executor/error.rs
similarity index 92%
rename from core/notifications/src/executor/error.rs
rename to core/notifications/src/push_executor/error.rs
index 8c0471b2c5..d68f52c4d9 100644
--- a/core/notifications/src/executor/error.rs
+++ b/core/notifications/src/push_executor/error.rs
@@ -4,7 +4,7 @@ use super::fcm::error::FcmError;
 use crate::user_notification_settings::error::*;
 
 #[derive(Error, Debug)]
-pub enum ExecutorError {
+pub enum PushExecutorError {
     #[error("ExecutorError - FcmError: {0}")]
     Fcm(#[from] FcmError),
     #[error("ExecutorError - UserNotificationSettingsError: {0}")]
diff --git a/core/notifications/src/executor/fcm/config.rs b/core/notifications/src/push_executor/fcm/config.rs
similarity index 100%
rename from core/notifications/src/executor/fcm/config.rs
rename to core/notifications/src/push_executor/fcm/config.rs
diff --git a/core/notifications/src/executor/fcm/error.rs b/core/notifications/src/push_executor/fcm/error.rs
similarity index 100%
rename from core/notifications/src/executor/fcm/error.rs
rename to core/notifications/src/push_executor/fcm/error.rs
diff --git a/core/notifications/src/executor/fcm/mod.rs b/core/notifications/src/push_executor/fcm/mod.rs
similarity index 100%
rename from core/notifications/src/executor/fcm/mod.rs
rename to core/notifications/src/push_executor/fcm/mod.rs
diff --git a/core/notifications/src/executor/mod.rs b/core/notifications/src/push_executor/mod.rs
similarity index 91%
rename from core/notifications/src/executor/mod.rs
rename to core/notifications/src/push_executor/mod.rs
index 18e6295b5c..4e5e16e835 100644
--- a/core/notifications/src/executor/mod.rs
+++ b/core/notifications/src/push_executor/mod.rs
@@ -11,17 +11,17 @@ pub use config::*;
 use error::*;
 
 #[derive(Clone)]
-pub struct Executor {
-    _config: ExecutorConfig,
+pub struct PushExecutor {
+    _config: PushExecutorConfig,
     fcm: FcmClient,
     settings: UserNotificationSettingsRepo,
 }
 
-impl Executor {
+impl PushExecutor {
     pub async fn init(
-        mut config: ExecutorConfig,
+        mut config: PushExecutorConfig,
         settings: UserNotificationSettingsRepo,
-    ) -> Result<Self, ExecutorError> {
+    ) -> Result<Self, PushExecutorError> {
         Ok(Self {
             fcm: FcmClient::init(config.fcm.service_account_key()).await?,
             _config: config,
@@ -35,7 +35,7 @@ impl Executor {
         fields(n_errors, n_removed_tokens),
         err
     )]
-    pub async fn notify<T: NotificationEvent>(&self, event: &T) -> Result<(), ExecutorError> {
+    pub async fn notify<T: NotificationEvent>(&self, event: &T) -> Result<(), PushExecutorError> {
         let mut settings = self.settings.find_for_user_id(event.user_id()).await?;
         if !settings.should_send_notification(UserNotificationChannel::Push, event.category()) {
             return Ok(());