Documentation
¶
Overview ¶
* ===================================================================================== * * Package: mongo * Filename: ${FILENAME} * * Description: tempmail * * Created: 9/23/18 9:25 AM * * Author: hacklog * URL: http://80x86.io * * =====================================================================================
* ===================================================================================== * * Package: mongo * Filename: ${FILENAME} * * Description: tempmail * * Created: 9/23/18 9:25 AM * * Author: hacklog * URL: http://80x86.io * * =====================================================================================
Index ¶
- func New(cfg config.Storage) (storage.Store, error)
- type CtripMongoOption
- type Mailbox
- type Mailhost
- type Message
- func (m *Message) Date() time.Time
- func (m *Message) From() *mail.Address
- func (m *Message) ID() string
- func (m *Message) Mailbox() string
- func (m *Message) Seen() bool
- func (m *Message) Size() int64
- func (m *Message) Source() (io.ReadCloser, error)
- func (m *Message) Subject() string
- func (m *Message) To() []*mail.Address
- type Store
- func (s *Store) AddAllowedMailbox(mailbox string) error
- func (s *Store) AddAllowedMailhost(host string, weight int) error
- func (s *Store) AddMessage(message storage.Message) (id string, err error)
- func (s *Store) CleanupExpiredMailbox(period time.Duration) int
- func (s *Store) GetMessage(mailbox, id string) (m storage.Message, err error)
- func (s *Store) GetMessages(mailbox string) (ms []storage.Message, err error)
- func (s *Store) IsMailboxAllow(mailbox string, period time.Duration) bool
- func (s *Store) KeepaliveAllowedMailbox(mailbox string) error
- func (s *Store) ListMailhost() []storage.Mailhost
- func (s *Store) MarkSeen(mailbox, id string) error
- func (s *Store) PurgeMessages(mailbox string) error
- func (s *Store) RemoveAllowedMailbox(mailbox string) error
- func (s *Store) RemoveAllowedMailhost(id string) error
- func (s *Store) RemoveMessage(mailbox, id string) error
- func (s *Store) UpdateMailhost(id string, mailhost string, weight int) error
- func (s *Store) VisitMailboxes(f func([]storage.Message) (cont bool)) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CtripMongoOption ¶
type CtripMongoOption struct { User string Passwd string Host string Port string DbName string Otions string }
options
type Mailbox ¶
type Mailbox struct { MID bson.ObjectId `bson:"_id" json:"_id"` MMailbox string `bson:"mailbox" json:"mailbox"` MCreatedAt int64 `bson:"created_at" json:"created_at"` MUpdatedAt int64 `bson:"updated_at" json:"updated_at"` }
Message is a memory store message.
type Mailhost ¶
type Mailhost struct { MID bson.ObjectId `bson:"_id" json:"_id"` MWeight int `bson:"weight" json:"weight"` MMailhost string `bson:"mailhost" json:"mailhost"` MCreatedAt int64 `bson:"created_at" json:"created_at"` MUpdatedAt int64 `bson:"updated_at" json:"updated_at"` }
Message is a memory store message.
type Message ¶
type Message struct { MID bson.ObjectId `bson:"_id" json:"_id"` MMailbox string `bson:"mailbox" json:"mailbox"` MFrom *mail.Address `bson:"from" json:"from"` MTo []*mail.Address `bson:"to" json:"to"` MDate int64 `bson:"date" json:"date"` MSubject string `bson:"subject" json:"subject"` MSource []byte `bson:"source" json:"source"` MSeen bool `bson:"seen" json:"seen"` }
Message is a memory store message.
type Store ¶
type Store struct { sync.Mutex RetentionPeriod time.Duration RetentionSleep time.Duration Option *CtripMongoOption Sess *mgo.Session // contains filtered or unexported fields }
Store implements an in-memory message store.
func (*Store) AddAllowedMailbox ¶
allow mailbox
func (*Store) AddAllowedMailhost ¶
mailhost
func (*Store) AddMessage ¶
AddMessage stores the message, message ID and Size will be ignored.
func (*Store) CleanupExpiredMailbox ¶
func (*Store) GetMessage ¶
GetMessage gets a mesage.
func (*Store) GetMessages ¶
GetMessages gets a list of messages.
func (*Store) IsMailboxAllow ¶
func (*Store) KeepaliveAllowedMailbox ¶
func (*Store) ListMailhost ¶
func (*Store) PurgeMessages ¶
PurgeMessages deletes the contents of a mailbox.
func (*Store) RemoveAllowedMailbox ¶
func (*Store) RemoveAllowedMailhost ¶
func (*Store) RemoveMessage ¶
RemoveMessage deletes a single message.