Documentation ¶
Overview ¶
Package mailspree contains all of the mailspree domain models and interfaces. Implementation of interfaces is generally put into subpackages named by the main dependency which that particular implementaion is based upon.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthService ¶
type AuthService interface { Authenticate(User, string) (string, error) Validate(string, UserService) (User, error) }
AuthService is a common interface to token authentication. Authenticate takes a User and a password, and returns a token if they match. Validate takes a token and returns a user if it is valid
type CircuitBreakerTimer ¶
type CircuitBreakerTimer interface { // Run starts a timer which returns an int when it runs out Run() <-chan int }
CircuitBreakerTimer is an interface to the timer used when the channel is open. This is defined as an interface so that we can make a mock implementation
func NewCircuitBreakerTimer ¶
func NewCircuitBreakerTimer() CircuitBreakerTimer
NewCircuitBreakerTimer returns a CircuitBreakerTimer which runs out after 30 seconds.
type Email ¶
type Email struct { Name string `json:"name"` Address string `json:"address" valid:"email,required"` }
Email is simply a real name together with the address
type MailingProvider ¶
MailingProvider abstacts different mailing providers.
func NewCircuitBreaker ¶
func NewCircuitBreaker(mp MailingProvider, t CircuitBreakerTimer) MailingProvider
NewCircuitBreaker wraps a mailing provider with a circuit breaker.
type MailingProviders ¶
type MailingProviders []MailingProvider
MailingProviders is a list of MailingProvider implementations
func (MailingProviders) SendEmail ¶
func (mps MailingProviders) SendEmail(m Message) error
SendEmail runs through the mailing providers and tries to send the email. Returns on first successful try. This also makes MailingProviders be a MailingProvider, which is a bit fun.
type Message ¶
type Message struct { From Email `json:"from" valid:"required"` To []Email `json:"to" valid:"required"` Subject string `json:"subject" valid:"required"` Body string `json:"body" valid:"required"` }
Message represents an email with all the related information.
type NewSession ¶
type NewSession struct { Username string `json:"username" valid:"required"` Password string `json:"password" valid:"required"` }
NewSession is what the api receives in order to login a user
type SimpleUserService ¶
type SimpleUserService struct {
User User
}
SimpleUserService only has a single user. A lookup for any other user will return an error.
type User ¶
User represents a user of the mailspree system
func (User) CheckPassword ¶
CheckPassword checks if the given password is correct
func (*User) SetPassword ¶
SetPassword takes a cleartext password and sets the user password.
type UserService ¶
UserService is a common interface for retrieving Users from usernames. This will make it easy to swap out with a database.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
mailspree
The command mailspree starts a mailspree server.
|
The command mailspree starts a mailspree server. |
Package http contains all the http api logic which serves as the interface to the mailspree service.
|
Package http contains all the http api logic which serves as the interface to the mailspree service. |