manager

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package manager provides the central gateway for message dispatching.

The Manager handles provider registration, initialization, and message routing for all message types (Email, SMS, Push, Chat).

Usage

cfg, _ := config.LoadFromEnv()
mgr, err := manager.New(cfg)
if err != nil {
    log.Fatal(err)
}

// Send using default provider
result, err := mgr.SendEmail(ctx, &contracts.Email{...})

// Send using specific provider
result, err := mgr.SendEmailWith(ctx, "sendgrid", &contracts.Email{...})

Thread Safety

Manager is safe for concurrent use. Provider maps are protected by sync.RWMutex.

Custom Providers

Register custom provider implementations at runtime:

mgr.RegisterEmailProvider("custom", myCustomProvider)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles provider registration and message dispatching. It is the central gateway for all message types (Email, SMS, Push, Chat).

func New

func New(cfg *config.Config) (*Manager, error)

New creates a new Manager with the given configuration. It automatically initializes all configured providers.

func (*Manager) AvailableChatProviders

func (m *Manager) AvailableChatProviders() []string

AvailableChatProviders returns the names of all registered chat providers

func (*Manager) AvailableEmailProviders

func (m *Manager) AvailableEmailProviders() []string

AvailableEmailProviders returns the names of all registered email providers

func (*Manager) AvailablePushProviders

func (m *Manager) AvailablePushProviders() []string

AvailablePushProviders returns the names of all registered push providers

func (*Manager) AvailableSMSProviders

func (m *Manager) AvailableSMSProviders() []string

AvailableSMSProviders returns the names of all registered SMS providers

func (*Manager) Chat

func (m *Manager) Chat() (contracts.ChatSender, error)

Chat returns the default chat sender

func (*Manager) ChatProvider

func (m *Manager) ChatProvider(name string) (contracts.ChatSender, error)

ChatProvider returns a specific chat provider by name

func (*Manager) Config

func (m *Manager) Config() *config.Config

Config returns the manager's configuration (read-only access)

func (*Manager) Email

func (m *Manager) Email() (contracts.EmailSender, error)

Email returns the default email sender

func (*Manager) EmailProvider

func (m *Manager) EmailProvider(name string) (contracts.EmailSender, error)

EmailProvider returns a specific email provider by name

func (*Manager) Push

func (m *Manager) Push() (contracts.PushSender, error)

Push returns the default push notification sender

func (*Manager) PushProvider

func (m *Manager) PushProvider(name string) (contracts.PushSender, error)

PushProvider returns a specific push notification provider by name

func (*Manager) RegisterChatProvider

func (m *Manager) RegisterChatProvider(name string, provider contracts.ChatSender)

RegisterChatProvider registers a custom chat provider

func (*Manager) RegisterEmailProvider

func (m *Manager) RegisterEmailProvider(name string, provider contracts.EmailSender)

RegisterEmailProvider registers a custom email provider

func (*Manager) RegisterPushProvider

func (m *Manager) RegisterPushProvider(name string, provider contracts.PushSender)

RegisterPushProvider registers a custom push notification provider

func (*Manager) RegisterSMSProvider

func (m *Manager) RegisterSMSProvider(name string, provider contracts.SMSSender)

RegisterSMSProvider registers a custom SMS provider

func (*Manager) SMS

func (m *Manager) SMS() (contracts.SMSSender, error)

SMS returns the default SMS sender

func (*Manager) SMSProvider

func (m *Manager) SMSProvider(name string) (contracts.SMSSender, error)

SMSProvider returns a specific SMS provider by name

func (*Manager) SendChat

func (m *Manager) SendChat(ctx context.Context, message *contracts.ChatMessage) (*contracts.SendResult, error)

SendChat sends a chat message using the default provider

func (*Manager) SendChatWith

func (m *Manager) SendChatWith(ctx context.Context, providerName string, message *contracts.ChatMessage) (*contracts.SendResult, error)

SendChatWith sends a chat message using a specific provider

func (*Manager) SendEmail

func (m *Manager) SendEmail(ctx context.Context, email *contracts.Email) (*contracts.SendResult, error)

SendEmail sends an email using the default provider

func (*Manager) SendEmailWith

func (m *Manager) SendEmailWith(ctx context.Context, providerName string, email *contracts.Email) (*contracts.SendResult, error)

SendEmailWith sends an email using a specific provider

func (*Manager) SendPush

func (m *Manager) SendPush(ctx context.Context, notification *contracts.PushNotification) (*contracts.SendResult, error)

SendPush sends a push notification using the default provider

func (*Manager) SendPushWith

func (m *Manager) SendPushWith(ctx context.Context, providerName string, notification *contracts.PushNotification) (*contracts.SendResult, error)

SendPushWith sends a push notification using a specific provider

func (*Manager) SendSMS

func (m *Manager) SendSMS(ctx context.Context, sms *contracts.SMS) (*contracts.SendResult, error)

SendSMS sends an SMS using the default provider

func (*Manager) SendSMSWith

func (m *Manager) SendSMSWith(ctx context.Context, providerName string, sms *contracts.SMS) (*contracts.SendResult, error)

SendSMSWith sends an SMS using a specific provider

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL