pop

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is a fake backend interface implementation used for test

func NewBackend

func NewBackend(dumpClient pb.DMSDumpServiceClient, lookupClient pb.LookupServiceClient,
	privateKey *easyecc.PrivateKey, user, password string, localStore store.Store) *Backend

func (*Backend) Authorize

func (b *Backend) Authorize(user, pass string) bool

func (*Backend) Dele

func (b *Backend) Dele(user string, msgId int) error

Delete message by message ID - message should be just marked as deleted until Update() is called. Be aware that after Dele() is called, functions like List() etc. should ignore all these messages even if Update() hasn't been called yet

func (*Backend) List

func (b *Backend) List(user string) (octets []int, err error)

List of sizes of all messages in bytes (octets)

func (*Backend) ListMessage

func (b *Backend) ListMessage(user string, msgId int) (exists bool, octets int, err error)

Returns whether message exists and if yes, then return size of the message in bytes (octets)

func (*Backend) Lock

func (b *Backend) Lock(user string) error

Lock is called immediately after client is connected. The best way what to use Lock() for is to read all the messages into cache after client is connected. If another user tries to lock the storage, you should return an error to avoid data race.

func (*Backend) Poll

func (b *Backend) Poll(ctx context.Context, user string) error

func (*Backend) Retr

func (b *Backend) Retr(user string, msgId int) (message string, err error)

Retrieve whole message by ID - note that message ID is a message position returned by List() function, so be sure to keep that order unchanged while client is connected See Lock() function for more details

func (*Backend) Rset

func (b *Backend) Rset(user string) error

Undelete all messages marked as deleted in single connection

func (*Backend) Stat

func (b *Backend) Stat(user string) (messages, octets int, err error)

Returns total message count and total mailbox size in bytes (octets). Deleted messages are ignored.

func (*Backend) Top added in v0.4.0

func (b *Backend) Top(user string, msgId int, n int) (lines []string, err error)

func (*Backend) Uidl

func (b *Backend) Uidl(user string) (uids []string, err error)

List of unique IDs of all message, similar to List(), but instead of size there is a unique ID which persists the same across all connections. Uid (unique id) is used to allow client to be able to keep messages on the server.

func (*Backend) UidlMessage

func (b *Backend) UidlMessage(user string, msgId int) (exists bool, uid string, err error)

Similar to ListMessage, but returns unique ID by message ID instead of size.

func (*Backend) Unlock

func (b *Backend) Unlock(user string) error

Release lock on storage, Unlock() is called after client is disconnected.

func (*Backend) Update

func (b *Backend) Update(user string) error

Write all changes to persistent storage, i.e. delete all messages marked as deleted.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts *ServerOptions) *Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

type ServerOptions

type ServerOptions struct {
	Ctx          context.Context
	Domain       string
	Port         int
	User         string
	Password     string
	DumpClient   pb.DMSDumpServiceClient
	LookupClient pb.LookupServiceClient
	Key          *easyecc.PrivateKey
	CertFile     string
	KeyFile      string
	LocalStore   store.Store
}

type Session

type Session struct {
	PrivateKey *easyecc.PrivateKey
	Messages   []*pb.DMSMessage
	Deleted    []bool
}

Jump to

Keyboard shortcuts

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