Documentation ¶
Index ¶
- type CallFunc
- type CallResult
- type Circuit
- func (circuit *Circuit) Call(message EmailMessage) (error, CallResult)
- func (circuit *Circuit) IsClosed() bool
- func (circuit *Circuit) IsClosedChangeChannel() chan bool
- func (circuit *Circuit) WithPollInterval(pollInterval time.Duration) *Circuit
- func (circuit *Circuit) WithTimeout(timeout time.Duration) *Circuit
- type Configuration
- type EmailMessage
- type EmailService
- type MailGunEmailService
- type MockEmailService
- type SendGridEmailService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallFunc ¶
type CallFunc func(message EmailMessage) error
CallFunc is the function being wrapped by a circuit breaker
type CallResult ¶
type CallResult int
CallResult CIRCUIT_OPEN | TIMEOUT | CALL_COMPLETE
const ( CIRCUIT_OPEN CallResult = iota TIMEOUT CALL_COMPLETE )
type Circuit ¶
type Circuit struct {
// contains filtered or unexported fields
}
func NewCircuit ¶
func NewCircuit(callfunc CallFunc, pollMessage EmailMessage) *Circuit
NewCircuit ctor
func (*Circuit) Call ¶
func (circuit *Circuit) Call(message EmailMessage) (error, CallResult)
Call is the outer call of the underlying CallFunc and is where the circuit break login exists
func (*Circuit) IsClosedChangeChannel ¶
IsClosedChangeChannel: the state of the circuit is cent on this channel each time it changes
func (*Circuit) WithPollInterval ¶
WithPollInterval enables the poll interval to be changed
type Configuration ¶
type EmailMessage ¶
type EmailService ¶
type EmailService interface {
Send(message EmailMessage) error
}
func NewMailGunEmailService ¶
func NewMailGunEmailService(domain string, apikey string) EmailService
NewMailGunEmailService ctor
func NewSendGridEmailService ¶
func NewSendGridEmailService(apiKey string) EmailService
NewSendGridEmailService ctor
type MailGunEmailService ¶
type MailGunEmailService struct {
// contains filtered or unexported fields
}
MailGunEmailService
func (MailGunEmailService) Send ¶
func (service MailGunEmailService) Send(message EmailMessage) error
Send message using mail gun
type MockEmailService ¶
type MockEmailService struct{}
MockEmailService breaks the dependency on real email service implementations for the purpose of testing
func (MockEmailService) Send ¶
func (mockEmailService MockEmailService) Send(message EmailMessage) error
Send will result in no error, error 500 or a timeout depending on the subject of the message. timeout, fail or anything else for no error.
type SendGridEmailService ¶
type SendGridEmailService struct {
// contains filtered or unexported fields
}
SendGridEmailService
func (*SendGridEmailService) Send ¶
func (service *SendGridEmailService) Send(message EmailMessage) error
Send message using SendGrid