Documentation
¶
Index ¶
- type Connection
- func (db *Connection) GetHistory(deviceID string) (History, error)
- func (db *Connection) GetTombstone(deviceID string) (map[string]Event, error)
- func (db *Connection) Initialize() error
- func (db *Connection) InsertEvent(deviceID string, event Event, tombstoneMapKey string) error
- func (db *Connection) RemoveAll() error
- func (db *Connection) UpdateHistory(deviceID string, events []Event) error
- type Event
- type History
- type Interface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶ added in v0.1.1
type Connection struct {
Server string
Username string
Password string
Bucket string
// number of times to try when initially connecting to the database
NumRetries int
// the time duration to add when creating TTLs for history documents
Timeout time.Duration
// contains filtered or unexported fields
}
Connection contains the bucket connection and configuration values
func (*Connection) GetHistory ¶ added in v0.1.1
func (db *Connection) GetHistory(deviceID string) (History, error)
GetHistory returns the history (list of events) for a given device
func (*Connection) GetTombstone ¶ added in v0.1.1
func (db *Connection) GetTombstone(deviceID string) (map[string]Event, error)
GetTombstone returns the tombstone (map of events) for a given device
func (*Connection) Initialize ¶ added in v0.1.1
func (db *Connection) Initialize() error
Initialize creates the connection with couchbase and opens the specified bucket
func (*Connection) InsertEvent ¶ added in v0.1.1
func (db *Connection) InsertEvent(deviceID string, event Event, tombstoneMapKey string) error
InsertEvent adds an event to the history of the given device id and adds it to the tombstone if a key is given
func (*Connection) RemoveAll ¶ added in v0.1.1
func (db *Connection) RemoveAll() error
RemoveAll removes everything in the database. Used for testing
func (*Connection) UpdateHistory ¶ added in v0.1.1
func (db *Connection) UpdateHistory(deviceID string, events []Event) error
UpdateHistory updates the history to the list of events given for a given device
type Event ¶
type Event struct {
// the id for the event
//
// required: true
ID string `json:"id"`
// the time this event was found
//
// required: true
Time int64 `json:"time"`
// the source of this event
//
// required: true
Source string `json:"src"`
// the destination of this event
//
// required: true
Destination string `json:"dest"`
// the partners related to this device
//
// required: true
PartnerIDs []string `json:"partner_ids"`
// the transaction id for this event
//
// required: true
TransactionUUID string `json:"transaction_uuid,omitempty"`
// payload
//
// required: false
Payload []byte `json:"payload,omitempty"`
// other metadata and details related to this state
//
// required: true
Details map[string]interface{} `json:"details"`
}
Event represents the event information in the database
swagger:model Event
type History ¶ added in v0.1.1
type History struct {
// the list of events from newest to oldest
Events []Event `json:"events"`
}
History is a list of events related to a device id, and has a TTL
swagger:model History
type Interface ¶
type Interface interface {
Initialize() error
GetHistory(deviceID string) (History, error)
GetTombstone(deviceID string) (map[string]Event, error)
UpdateHistory(deviceID string, events []Event) error
InsertEvent(deviceID string, event Event, tombstoneKey string) error
RemoveAll() error
}
Interface describes the main functionality needed to connect to a db