Conversation
Contributor
Reviewer's GuideAdds optional logger injection support to notification backends and ensures notification creation is logged at info level, updating the notification service, backend interface, and corresponding tests, plus repository configuration tweaks. Sequence diagram for VintaSend initialization with logger injectionsequenceDiagram
actor App
participant Factory as VintaSendFactory
participant Backend as BaseNotificationBackend
participant Logger as BaseLogger
participant Adapter1 as BaseNotificationAdapter_1
participant Adapter2 as BaseNotificationAdapter_2
participant Renderer1 as TemplateRenderer_1
App->>Factory: create(adapters, backend, logger, contextGeneratorsMap, queueService, attachmentManager, options)
activate Factory
Factory->>Factory: new VintaSend(...)
deactivate Factory
activate Backend
loop for each adapter in adapters
activate Adapter1
Adapter1->>Adapter1: injectBackend(backend)
Adapter1->>Adapter1: injectLogger(logger)
Adapter1->>Renderer1: injectLogger(logger)
deactivate Adapter1
end
Backend->>Backend: injectLogger(logger)
deactivate Backend
note over App,Backend: After construction, backend and adapters share the same logger for consistent logging
Updated class diagram for notification logging and backendsclassDiagram
class BaseLogger {
}
class BaseNotificationTypeConfig {
<<interface>>
ContextMap
NotificationIdType
}
class BaseNotificationTemplateRenderer {
<<interface>>
+generate(notification, context) Promise~any~
}
class BaseEmailTemplateRenderer {
<<interface>>
+render(notification, context) Promise~EmailTemplate~
+injectLogger(logger) void
}
class BaseNotificationAdapter {
<<interface>>
+notificationType
+key
+enqueueNotifications
+injectBackend(backend) void
+injectLogger(logger) void
+send(notification, context) Promise~void~
}
class BaseNotificationBackend {
<<interface>>
+getAllPendingNotifications() Promise~AnyDatabaseNotification~
+persistNotification(notification) Promise~DatabaseNotification~
+persistNotificationUpdate(notificationId, notification) Promise~DatabaseNotification~
+persistOneOffNotification(notification) Promise~DatabaseOneOffNotification~
+persistOneOffNotificationUpdate(notificationId, notification) Promise~DatabaseOneOffNotification~
+getNotification(notificationId, forUpdate) Promise~DatabaseNotification or null~
+getOneOffNotification(notificationId, forUpdate) Promise~DatabaseOneOffNotification or null~
+markAsFailed(notificationId, propagate) Promise~void~
+markAsSent(notificationId, propagate) Promise~void~
+markAsRead(notificationId, checkIsSent) Promise~DatabaseNotification~
+cancelNotification(notificationId) Promise~void~
+storeContextUsed(notificationId, context) Promise~void~
+getAllFutureNotifications() Promise~AnyDatabaseNotification[]~
+getAllFutureNotificationsFromUser(userId) Promise~AnyDatabaseNotification[]~
+getFutureNotificationsFromUser(userId, page, pageSize) Promise~AnyDatabaseNotification[]~
+getFutureNotifications(page, pageSize) Promise~AnyDatabaseNotification[]~
+getPendingNotifications(page, pageSize) Promise~AnyDatabaseNotification[]~
+bulkPersistNotifications(notifications) Promise~NotificationIdType[]~
+getNotifications(pageNumber, batchSize) Promise~AnyDatabaseNotification[]~
+injectLogger(logger) void
}
class BaseNotificationQueueService {
<<interface>>
+enqueueNotification(notificationId) Promise~void~
}
class BaseAttachmentManager {
<<abstract>>
}
class NotificationContextGeneratorsMap {
+getContextGenerator(contextName)
}
class VintaSendOptions {
+raiseErrorOnFailedSend boolean
}
class VintaSendFactory {
+create(adapters, backend, logger, contextGeneratorsMap, queueService, attachmentManager, options) VintaSend
}
class VintaSend {
-adapters AdaptersList
-backend Backend
-logger Logger
-queueService QueueService
-attachmentManager AttachmentMgr
-options VintaSendOptions
-contextGeneratorsMap NotificationContextGeneratorsMap
+constructor(adapters, backend, logger, contextGeneratorsMap, queueService, attachmentManager, options)
+registerQueueService(queueService) void
+send(notification) Promise~void~
+createNotification(notification) Promise~DatabaseNotification~
+updateNotification(notificationId, notification)
+createOneOffNotification(notification) Promise~DatabaseOneOffNotification~
+updateOneOffNotification(notificationId, notification) Promise~DatabaseOneOffNotification~
+getNotificationContext(contextName, parameters) Promise~JsonObject~
+sendPendingNotifications() Promise~void~
+getPendingNotifications(page, pageSize)
+getNotification(notificationId, forUpdate)
+getOneOffNotification(notificationId, forUpdate) Promise~DatabaseOneOffNotification or null~
+markRead(notificationId, checkIsSent) Promise~DatabaseNotification~
+cancelNotification(notificationId) Promise~void~
+resendNotification(notificationId, useStoredContextIfAvailable) Promise~DatabaseNotification or undefined~
+delayedSend(notificationId) Promise~void~
+bulkPersistNotifications(notifications) Promise~NotificationIdType[]~
+migrateToBackend(destinationBackend, batchSize) Promise~void~
}
VintaSendFactory --> VintaSend : creates
VintaSend --> BaseNotificationAdapter : uses
VintaSend --> BaseNotificationBackend : uses
VintaSend --> BaseNotificationQueueService : uses
VintaSend --> BaseAttachmentManager : uses
VintaSend --> NotificationContextGeneratorsMap : uses
VintaSend --> BaseLogger : uses
BaseNotificationAdapter --> BaseNotificationTemplateRenderer : uses
BaseEmailTemplateRenderer ..|> BaseNotificationTemplateRenderer : extends
BaseNotificationBackend --> BaseLogger : injectLogger
BaseNotificationAdapter --> BaseLogger : injectLogger
BaseEmailTemplateRenderer --> BaseLogger : injectLogger
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Inject logger support into notification backends and fix incorrect logging level when creating notifications.
Enhancements:
Tests: