Documentation
¶
Index ¶
- Constants
- type MockProvider
- type Module
- func (m *Module) FieldResolvers() map[string]any
- func (m *Module) ID() string
- func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error
- func (m *Module) ListNotifications(ctx context.Context, recipient *string) ([]*Notification, error)
- func (m *Module) Models() []any
- func (m *Module) Mutations() map[string]any
- func (m *Module) Queries() map[string]any
- func (m *Module) Repo() *Repository
- func (m *Module) Routes() []mdk.Route
- func (m *Module) SendNotification(ctx context.Context, input any) (any, error)
- func (m *Module) SendNotificationStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) Shutdown(ctx context.Context) error
- type Notification
- type NotificationChannel
- type NotificationStatus
- type Provider
- type Repository
Constants ¶
View Source
const ( StatusPending NotificationStatus = "PENDING" StatusSent NotificationStatus = "SENT" StatusFailed NotificationStatus = "FAILED" ChannelEmail NotificationChannel = "EMAIL" ChannelSMS NotificationChannel = "SMS" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockProvider ¶
type MockProvider struct {
ShouldFail bool
}
MockProvider is a simple provider for testing and development.
func (*MockProvider) Send ¶
func (m *MockProvider) Send(ctx context.Context, n *Notification) error
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the mdk.Module interface for Notification.
func (*Module) FieldResolvers ¶
func (*Module) ListNotifications ¶
func (*Module) Repo ¶
func (m *Module) Repo() *Repository
func (*Module) SendNotification ¶
SendNotification executes the notification delivery via the provider.
func (*Module) SendNotificationStep ¶
func (m *Module) SendNotificationStep(sCtx mdk.StepContext) mdk.StepResult
SendNotificationStep wraps SendNotification to mdk.StepHandler.
type Notification ¶
type Notification struct {
ID string `gorm:"primaryKey" json:"id"`
Recipient string `gorm:"index;not null" json:"recipient"`
Channel NotificationChannel `gorm:"not null" json:"channel"`
Subject string `json:"subject"`
Body string `json:"body"`
Status NotificationStatus `gorm:"not null" json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
Notification represents a message sent to a user.
type NotificationChannel ¶
type NotificationChannel string
type NotificationStatus ¶
type NotificationStatus string
type Provider ¶
type Provider interface {
Send(ctx context.Context, n *Notification) error
}
Provider defines the interface for sending notifications.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository handles data access for notifications.
func NewRepository ¶
func NewRepository(database *gorm.DB) *Repository
NewRepository creates a new Repository.
func (*Repository) GetByID ¶
func (r *Repository) GetByID(ctx context.Context, id string) (*Notification, error)
GetByID retrieves a notification by its ID.
func (*Repository) List ¶
func (r *Repository) List(ctx context.Context, recipient string) ([]*Notification, error)
List retrieves all notifications, optionally filtered by recipient.
func (*Repository) Save ¶
func (r *Repository) Save(ctx context.Context, n *Notification) error
Save persists a notification to the database.
Click to show internal directories.
Click to hide internal directories.