Documentation ¶
Overview ¶
Package database provides functions and types for interacting with MongoDB, as well as a message queue built on mongo
Index ¶
- type DNSRecord
- type Database
- func (d Database) AddMetadata(m MetadataElement) error
- func (d Database) AddQueueMessage(message QueueMessage) error
- func (d Database) GetMetadata(l MetaLabel) (MetadataElement, error)
- func (d Database) GetNode(id string) bson.M
- func (d Database) ListQueue() ([]QueueMessage, error)
- func (d Database) NextQueueMessage() (QueueMessage, error)
- func (d Database) QueueConfirm(message QueueMessage) error
- type MetaLabel
- type MetadataElement
- type Node
- type QueueMessage
- type User
- type Zone
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DNSRecord ¶
type DNSRecord struct {
RRString string `json:"rr" validate:"required"`
}
DNSRecord stores a DNS RR string
type Database ¶
Database wraps a *mongo.Database
func (Database) AddMetadata ¶
func (d Database) AddMetadata(m MetadataElement) error
AddMetadata adds a MetadataElement to the database
func (Database) AddQueueMessage ¶
func (d Database) AddQueueMessage(message QueueMessage) error
AddQueueMessage appends a message to the queue
func (Database) GetMetadata ¶
func (d Database) GetMetadata(l MetaLabel) (MetadataElement, error)
GetMetadata returns the metadata object with specified label
func (Database) ListQueue ¶
func (d Database) ListQueue() ([]QueueMessage, error)
ListQueue returns all messages in queue
func (Database) NextQueueMessage ¶
func (d Database) NextQueueMessage() (QueueMessage, error)
NextQueueMessage retrieves a single queue message
func (Database) QueueConfirm ¶
func (d Database) QueueConfirm(message QueueMessage) error
QueueConfirm marks a queue message as complete
type MetadataElement ¶
type MetadataElement struct { ID primitive.ObjectID `bson:"-" bson:"_id,omitempty"` Label string `bson:"label"` Payload map[string]string `bson:"payload"` }
MetadataElement stores a document in the metadata collection in mongo
type Node ¶
type Node struct { ID string `json:"-" bson:"_id,omitempty"` Endpoint string `json:"endpoint" validate:"required"` Provider string `json:"provider" validate:"required"` Latitude float32 `json:"latitude" validate:"required"` Longitude float32 `json:"longitude" validate:"required"` Region string `json:"region" validate:"region"` Authorized bool `json:"-"` }
Node stores a single edge node
type QueueMessage ¶
type QueueMessage struct { ID primitive.ObjectID `json:"-" bson:"_id,omitempty"` Payload map[string]string `json:"payload"` Created int64 `json:"-"` Locked bool `json:"-"` LockedAt int64 `json:"-"` }
QueueMessage stores a single queue entry
Click to show internal directories.
Click to hide internal directories.