Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LoadStateFunc ¶
LoadStateFunc is the function definition of LoadState in the Store interface.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages mail syncers and persists their state in a store.
func NewManager ¶
NewManagerreturns a new mailsync manager that uses the given MongoDB client and database.
type MessageHandler ¶
MessageHandler is called for each new E-Mail that has been received by the watched mailbox.
type MessageHandlerFunc ¶
MessageHandlerFunc is a convenience type for implementing MessageHandler.
func (MessageHandlerFunc) HandleMail ¶
func (fn MessageHandlerFunc) HandleMail(ctx context.Context, mail *mailbox.EMail)
HandleMail implements MessageHandler.
type SaveStateFunc ¶
SaveStateFunc is the function definition of SaveState in the Store interface.
type SimpleStore ¶
type SimpleStore struct { Load LoadStateFunc Save SaveStateFunc }
SimpleStore is a convenience struct for implementing Store with anonymous functions.
type State ¶
type State struct { // ID is the MongoDB object ID. ID primitive.ObjectID `bson:"_id,omitempty"` // Name is the name of the mail syncer the // state belongs to. Name string `bson:"name,omitempty"` // UIDValidtity is the last UIDVALIDITY value // seen. UIDValidity uint32 `bson:"uidValidity,omitempty"` // LastUIDFetched is the last mail UID that has // been fetched. // Only valid if UIDValidity is still unchanged. LastUIDFetched uint32 `bson:"lastUidFetched,omitempty"` }
State is the state of a mail syncer.
type Store ¶
type Store interface { // LoadState should return the state stored under name. If no state // is stored LoadState should return a nil state and a nil error. // In case of an error LoadState should return a non-nil error. LoadState(ctx context.Context, name string) (*State, error) // SaveState should store state and make it retrievable by it's name. // It should return a non-nil error if the state cannot be stored // for whatever reason. SaveState(ctx context.Context, state State) error }
Store stores the state of individual mail syncers.