Documentation
¶
Index ¶
- type GatewayConfig
- type GatewayService
- func (s *GatewayService) Chat() (port.ChatSender, error)
- func (s *GatewayService) ChatProvider(name string) (port.ChatSender, error)
- func (s *GatewayService) Email() (port.EmailSender, error)
- func (s *GatewayService) EmailProvider(name string) (port.EmailSender, error)
- func (s *GatewayService) Push() (port.PushSender, error)
- func (s *GatewayService) PushProvider(name string) (port.PushSender, error)
- func (s *GatewayService) RegisterChatProvider(name string, provider port.ChatSender)
- func (s *GatewayService) RegisterEmailProvider(name string, provider port.EmailSender)
- func (s *GatewayService) RegisterPushProvider(name string, provider port.PushSender)
- func (s *GatewayService) RegisterSMSProvider(name string, provider port.SMSSender)
- func (s *GatewayService) SMS() (port.SMSSender, error)
- func (s *GatewayService) SMSProvider(name string) (port.SMSSender, error)
- func (s *GatewayService) SendChat(ctx context.Context, message *contracts.ChatMessage) (*contracts.SendResult, error)
- func (s *GatewayService) SendChatWith(ctx context.Context, providerName string, message *contracts.ChatMessage) (*contracts.SendResult, error)
- func (s *GatewayService) SendEmail(ctx context.Context, email *contracts.Email) (*contracts.SendResult, error)
- func (s *GatewayService) SendEmailWith(ctx context.Context, providerName string, email *contracts.Email) (*contracts.SendResult, error)
- func (s *GatewayService) SendPush(ctx context.Context, notification *contracts.PushNotification) (*contracts.SendResult, error)
- func (s *GatewayService) SendPushWith(ctx context.Context, providerName string, ...) (*contracts.SendResult, error)
- func (s *GatewayService) SendSMS(ctx context.Context, sms *contracts.SMS) (*contracts.SendResult, error)
- func (s *GatewayService) SendSMSWith(ctx context.Context, providerName string, sms *contracts.SMS) (*contracts.SendResult, error)
- type ProviderNotFoundError
- type Registry
- func (r *Registry) GetChatProvider(name string) (port.ChatSender, bool)
- func (r *Registry) GetEmailProvider(name string) (port.EmailSender, bool)
- func (r *Registry) GetPushProvider(name string) (port.PushSender, bool)
- func (r *Registry) GetSMSProvider(name string) (port.SMSSender, bool)
- func (r *Registry) RegisterChatProvider(name string, provider port.ChatSender)
- func (r *Registry) RegisterEmailProvider(name string, provider port.EmailSender)
- func (r *Registry) RegisterPushProvider(name string, provider port.PushSender)
- func (r *Registry) RegisterSMSProvider(name string, provider port.SMSSender)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GatewayConfig ¶
type GatewayConfig interface {
DefaultEmailProvider() string
DefaultSMSProvider() string
DefaultPushProvider() string
DefaultChatProvider() string
}
GatewayConfig holds the configuration needed by the service.
type GatewayService ¶
type GatewayService struct {
// contains filtered or unexported fields
}
GatewayService handles provider registration and message dispatching.
func NewGatewayService ¶
func NewGatewayService(cfg GatewayConfig, registry *Registry) *GatewayService
NewGatewayService creates a new GatewayService.
func (*GatewayService) Chat ¶
func (s *GatewayService) Chat() (port.ChatSender, error)
Chat returns the default chat provider.
func (*GatewayService) ChatProvider ¶
func (s *GatewayService) ChatProvider(name string) (port.ChatSender, error)
ChatProvider returns a specific chat provider by name.
func (*GatewayService) Email ¶
func (s *GatewayService) Email() (port.EmailSender, error)
Email returns the default email provider.
func (*GatewayService) EmailProvider ¶
func (s *GatewayService) EmailProvider(name string) (port.EmailSender, error)
EmailProvider returns a specific email provider by name.
func (*GatewayService) Push ¶
func (s *GatewayService) Push() (port.PushSender, error)
Push returns the default push provider.
func (*GatewayService) PushProvider ¶
func (s *GatewayService) PushProvider(name string) (port.PushSender, error)
PushProvider returns a specific push provider by name.
func (*GatewayService) RegisterChatProvider ¶
func (s *GatewayService) RegisterChatProvider(name string, provider port.ChatSender)
RegisterChatProvider registers a custom chat provider.
func (*GatewayService) RegisterEmailProvider ¶
func (s *GatewayService) RegisterEmailProvider(name string, provider port.EmailSender)
RegisterEmailProvider registers a custom email provider.
func (*GatewayService) RegisterPushProvider ¶
func (s *GatewayService) RegisterPushProvider(name string, provider port.PushSender)
RegisterPushProvider registers a custom push provider.
func (*GatewayService) RegisterSMSProvider ¶
func (s *GatewayService) RegisterSMSProvider(name string, provider port.SMSSender)
RegisterSMSProvider registers a custom SMS provider.
func (*GatewayService) SMS ¶
func (s *GatewayService) SMS() (port.SMSSender, error)
SMS returns the default SMS provider.
func (*GatewayService) SMSProvider ¶
func (s *GatewayService) SMSProvider(name string) (port.SMSSender, error)
SMSProvider returns a specific SMS provider by name.
func (*GatewayService) SendChat ¶
func (s *GatewayService) SendChat(ctx context.Context, message *contracts.ChatMessage) (*contracts.SendResult, error)
SendChat sends a chat message using the default provider.
func (*GatewayService) SendChatWith ¶
func (s *GatewayService) SendChatWith(ctx context.Context, providerName string, message *contracts.ChatMessage) (*contracts.SendResult, error)
SendChatWith sends a chat message using a specific provider.
func (*GatewayService) SendEmail ¶
func (s *GatewayService) SendEmail(ctx context.Context, email *contracts.Email) (*contracts.SendResult, error)
SendEmail sends an email using the default provider.
func (*GatewayService) SendEmailWith ¶
func (s *GatewayService) SendEmailWith(ctx context.Context, providerName string, email *contracts.Email) (*contracts.SendResult, error)
SendEmailWith sends an email using a specific provider.
func (*GatewayService) SendPush ¶
func (s *GatewayService) SendPush(ctx context.Context, notification *contracts.PushNotification) (*contracts.SendResult, error)
SendPush sends a push notification using the default provider.
func (*GatewayService) SendPushWith ¶
func (s *GatewayService) SendPushWith(ctx context.Context, providerName string, notification *contracts.PushNotification) (*contracts.SendResult, error)
SendPushWith sends a push notification using a specific provider.
func (*GatewayService) SendSMS ¶
func (s *GatewayService) SendSMS(ctx context.Context, sms *contracts.SMS) (*contracts.SendResult, error)
SendSMS sends an SMS using the default provider.
func (*GatewayService) SendSMSWith ¶
func (s *GatewayService) SendSMSWith(ctx context.Context, providerName string, sms *contracts.SMS) (*contracts.SendResult, error)
SendSMSWith sends an SMS using a specific provider.
type ProviderNotFoundError ¶
func NewProviderNotFoundError ¶
func NewProviderNotFoundError(providerType, providerName string) *ProviderNotFoundError
func (*ProviderNotFoundError) Error ¶
func (e *ProviderNotFoundError) Error() string
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages provider instances in a thread-safe manner.
func (*Registry) GetChatProvider ¶
func (r *Registry) GetChatProvider(name string) (port.ChatSender, bool)
GetChatProvider returns a chat provider by name.
func (*Registry) GetEmailProvider ¶
func (r *Registry) GetEmailProvider(name string) (port.EmailSender, bool)
GetEmailProvider returns an email provider by name.
func (*Registry) GetPushProvider ¶
func (r *Registry) GetPushProvider(name string) (port.PushSender, bool)
GetPushProvider returns a push provider by name.
func (*Registry) GetSMSProvider ¶
GetSMSProvider returns an SMS provider by name.
func (*Registry) RegisterChatProvider ¶
func (r *Registry) RegisterChatProvider(name string, provider port.ChatSender)
RegisterChatProvider registers a chat provider with the given name.
func (*Registry) RegisterEmailProvider ¶
func (r *Registry) RegisterEmailProvider(name string, provider port.EmailSender)
RegisterEmailProvider registers an email provider with the given name.
func (*Registry) RegisterPushProvider ¶
func (r *Registry) RegisterPushProvider(name string, provider port.PushSender)
RegisterPushProvider registers a push provider with the given name.