mailbox

package
v0.6.1-0...-efaa8b1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *ql.DB

Functions

func AssetPending

func AssetPending(md5 string) (bool, error)

func CloseDB

func CloseDB() error

func CreateDB

func CreateDB() error

func DeleteMessage

func DeleteMessage(msgId string) error

Marks a message as deleted in the mailbox.

func Deregister

func Deregister(id string) error

func GenerateIdentifier

func GenerateIdentifier() string

GenerateIdentifier is used for generating various IDs. It is used to create messageIds, deploymentIds, access tokens, etc.

func GetDBVersion

func GetDBVersion() (string, error)

func KeyExists

func KeyExists(name string) bool

func OpenDB

func OpenDB()

func OpenMemDB

func OpenMemDB() error

func Revoke

func Revoke(name string) error

Types

type AccessKey

type AccessKey struct {
	Name       string
	MailboxId  string
	FullAccess bool
	Secret     string
}

func AdminKeys

func AdminKeys() ([]*AccessKey, error)

func AllKeys

func AllKeys() ([]*AccessKey, error)

func FindKeyByName

func FindKeyByName(name string) (*AccessKey, error)

func (*AccessKey) CanAdmin

func (key *AccessKey) CanAdmin() bool

func (*AccessKey) CanDelete

func (key *AccessKey) CanDelete(mb *Mailbox) bool

func (*AccessKey) CanGet

func (key *AccessKey) CanGet(mb *Mailbox) bool

func (*AccessKey) CanPut

func (key *AccessKey) CanPut(mb *Mailbox) bool

func (*AccessKey) Create

func (key *AccessKey) Create() error

type Deployment

type Deployment struct {
	Id            string
	Name          string
	DeployedAt    time.Time
	DeployedBy    string
	TotalMessages int64
	MessageBody   string
	Open          bool
	Asset         string
}

func FindDeployment

func FindDeployment(id string) (*Deployment, error)

func ListDeployments

func ListDeployments(name string, count int, token string) ([]Deployment, error)

func (*Deployment) AddResponse

func (dp *Deployment) AddResponse(mailbox, response string, isErr bool) error

func (*Deployment) Create

func (dp *Deployment) Create() error

func (*Deployment) Deploy

func (dp *Deployment) Deploy(mb *Mailbox) (*Message, error)

func (*Deployment) GetName

func (dp *Deployment) GetName() string

func (*Deployment) GetResponses

func (dp *Deployment) GetResponses() ([]DeploymentResponse, error)

func (*Deployment) Save

func (dp *Deployment) Save() error

func (*Deployment) Stats

func (dp *Deployment) Stats() (*DeploymentStats, error)

type DeploymentResponse

type DeploymentResponse struct {
	Deployment  string
	Mailbox     string
	Response    string
	RespondedAt time.Time
	IsError     bool
}

type DeploymentStats

type DeploymentStats struct {
	MessageCount  int64
	PendingCount  int64
	ResponseCount int64
}

type Mailbox

type Mailbox struct {
	Id       string
	LastSeen time.Time
	Version  string
	Host     string
}

Mailboxes represent a bucket or queue of messages. Messages can be added to the mailbox through a deployment. Messages can be requested from the mailbox and one will be returned (with no garenteed ordering). Once the message has been processed it can be deleted from the mailbox.

Mailboxes must have a unique Id, but this value can be anything unique. The system is designed with the idea of manually created and namespaced identifiers such as:

newton.maxwell.bohr

This allows pattern searches to be intuitive such as:

newton.*.bohr

func All

func All() ([]Mailbox, error)

All returns a slice of all mailboxes.

func Create

func Create(id string) (*Mailbox, error)

Create will generate and persist a new mailbox.

func Find

func Find(id string) (*Mailbox, error)

Find will return a mailbox or nil for a given mailbox identifier

func Search(rawPattern string) ([]Mailbox, error)

Search will return a slice of mailboxes whos identifiers match a given pattern. This pattern can be any valid regex. However it will automatically convert '*' to '.*'. This allows * to be used as a simple wildcard when searching by pattern.

func (*Mailbox) Checkin

func (mb *Mailbox) Checkin(host, version string) error

func (*Mailbox) DeployMessage

func (mb *Mailbox) DeployMessage(depId string) (*Message, error)

DeployMessage accepts a deployment identifier and adds this mailbox to its deployment. A new message will be available for this deployment in the mailbox.

func (*Mailbox) GetMessage

func (mb *Mailbox) GetMessage() (*Message, error)

GetMessage returns a message from the mailbox. Once the message is processed it should be removed from the queue with Delete.

func (*Mailbox) MessageCount

func (mb *Mailbox) MessageCount() (int64, error)

MessageCount returns a cound of all pending messages in the mailbox. This will not return messages that were marked as deleted.

func (*Mailbox) Purge

func (mb *Mailbox) Purge() (int64, error)

Purge will mark all messages in the mailbox as deleted. They will no longer be availble when polling for messages.

func (*Mailbox) PutMessage

func (mb *Mailbox) PutMessage(body string) (*Message, error)

PutMessage will automatically generate a deployment and add a message to the mailbox. The access token for the deployment will be "SYSTEM". This is intended to be used for internal actions.

type Message

type Message struct {
	Id             string
	Body           string
	ReceiveCount   int64
	Mailbox        string
	CreatedAt      time.Time
	LastReceivedAt time.Time
	Deployment     string
	Deleted        bool
}

func FindMessage

func FindMessage(msgId string) (*Message, error)

FindMessage will return a Message or nil for a given message identifier

func (*Message) Create

func (m *Message) Create() error

func (*Message) GetDeployment

func (m *Message) GetDeployment() (*Deployment, error)

func (*Message) Save

func (m *Message) Save() error

type SystemStats

type SystemStats struct {
	MailboxCount    int64
	MessageCount    int64
	PendingMessages int64
}

func Stats

func Stats() (*SystemStats, error)

Stats returns a SystemStats structure with overall message count information.

Jump to

Keyboard shortcuts

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