Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(handler fnHandler, interfacePtr any)
Register adds a notification handler factory function to the handlerFactory slice. The handler function creates an INotifiable implementation for a specific notification type. This allows registering different notification channels (Mail, SMS, Slack, etc.). The interfacePtr should be a pointer to an interface (e.g., (*IMailNotification)(nil))
func Send ¶
Send delivers notifications concurrently through multiple notification handlers (SMS|Mail|Slack|Database). It takes a notification object of any type and sends it through all registered handlers that implement the corresponding notification interfaces. If notifications are disabled via NOTIFICATION_ENABLE env var, it will skip sending and return nil. Returns error.NotImplemented if no valid handlers are found.
Parameters:
- notification: Any object implementing notification interfaces for registered handlers To send Mail. For example, a struct implementing IMailNotification interface for mail notifications. To send SMS. For example, a struct implementing ISmsNotification interface for sms notifications. To send Slack. For example, a struct implementing ISlackNotification interface for Slack notifications. To send Database. For example, a struct implementing IDatabaseNotification interface for database notifications.
Returns:
- error: error.NotImplemented if no handlers match, nil on success or disabled notifications
Types ¶
type INotifiable ¶
type INotifiable interface {
// Notify sends the actual notification through the specific channel
Notify()
}
INotifiable is the interface that defines a notification that can be sent through different channels like Mail, SMS, Slack, etc. Each notification handler must implement this interface.