mongo

package
v0.0.0-...-30e5c69 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg config.Storage) (storage.Store, error)

New returns an emtpy memory store.

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.

func (*Mailbox) CreatedAt

func (m *Mailbox) CreatedAt() time.Time

Date returns the date received.

func (*Mailbox) ID

func (m *Mailbox) ID() string

ID the message ID.

func (*Mailbox) Mailbox

func (m *Mailbox) Mailbox() string

func (*Mailbox) UpdatedAt

func (m *Mailbox) UpdatedAt() time.Time

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.

func (*Mailhost) CreatedAt

func (m *Mailhost) CreatedAt() string

func (*Mailhost) Host

func (m *Mailhost) Host() string

func (*Mailhost) ID

func (m *Mailhost) ID() string

ID the message ID.

func (*Mailhost) UpdatedAt

func (m *Mailhost) UpdatedAt() string

func (*Mailhost) Weight

func (m *Mailhost) Weight() int

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.

func (*Message) Date

func (m *Message) Date() time.Time

Date returns the date received.

func (*Message) From

func (m *Message) From() *mail.Address

From returns the from address.

func (*Message) ID

func (m *Message) ID() string

ID the message ID.

func (*Message) Mailbox

func (m *Message) Mailbox() string

Mailbox returns the mailbox name.

func (*Message) Seen

func (m *Message) Seen() bool

Seen returns the message seen flag.

func (*Message) Size

func (m *Message) Size() int64

Size returns the message size in bytes.

func (*Message) Source

func (m *Message) Source() (io.ReadCloser, error)

Source returns a reader for the message source.

func (*Message) Subject

func (m *Message) Subject() string

Subject returns the subject line.

func (*Message) To

func (m *Message) To() []*mail.Address

To returns the to address list.

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

func (s *Store) AddAllowedMailbox(mailbox string) error

allow mailbox

func (*Store) AddAllowedMailhost

func (s *Store) AddAllowedMailhost(host string, weight int) error

mailhost

func (*Store) AddMessage

func (s *Store) AddMessage(message storage.Message) (id string, err error)

AddMessage stores the message, message ID and Size will be ignored.

func (*Store) CleanupExpiredMailbox

func (s *Store) CleanupExpiredMailbox(period time.Duration) int

func (*Store) GetMessage

func (s *Store) GetMessage(mailbox, id string) (m storage.Message, err error)

GetMessage gets a mesage.

func (*Store) GetMessages

func (s *Store) GetMessages(mailbox string) (ms []storage.Message, err error)

GetMessages gets a list of messages.

func (*Store) IsMailboxAllow

func (s *Store) IsMailboxAllow(mailbox string, period time.Duration) bool

func (*Store) KeepaliveAllowedMailbox

func (s *Store) KeepaliveAllowedMailbox(mailbox string) error

func (*Store) ListMailhost

func (s *Store) ListMailhost() []storage.Mailhost

func (*Store) MarkSeen

func (s *Store) MarkSeen(mailbox, id string) error

MarkSeen marks a message as having been read.

func (*Store) PurgeMessages

func (s *Store) PurgeMessages(mailbox string) error

PurgeMessages deletes the contents of a mailbox.

func (*Store) RemoveAllowedMailbox

func (s *Store) RemoveAllowedMailbox(mailbox string) error

func (*Store) RemoveAllowedMailhost

func (s *Store) RemoveAllowedMailhost(id string) error

func (*Store) RemoveMessage

func (s *Store) RemoveMessage(mailbox, id string) error

RemoveMessage deletes a single message.

func (*Store) UpdateMailhost

func (s *Store) UpdateMailhost(id string, mailhost string, weight int) error

func (*Store) VisitMailboxes

func (s *Store) VisitMailboxes(f func([]storage.Message) (cont bool)) error

VisitMailboxes visits each mailbox in the store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL