Documentation ¶
Index ¶
- func BuildInsertQuery(w Watch, command map[string]interface{}) bson.M
- func BuildUpdateQuery(w Watch, command map[string]interface{}) bson.M
- func GetValue(from string, ds interface{}) interface{}
- type BehaviourSettings
- type Configuration
- type InsertTracker
- type Mongo
- type Query
- type RemoveTracker
- type TailAgent
- type Tracker
- type UpdateTracker
- type Watch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildInsertQuery ¶
BuildInsertQuery generates the query
func BuildUpdateQuery ¶
BuildUpdateQuery generates the query
func GetValue ¶
func GetValue(from string, ds interface{}) interface{}
GetValue works like this: from must be a selector like user.comment.author GetValue then looks recursively for that element therefore all of the following return values are possible map[string]interface{} nil string or basic mongodb types
Types ¶
type BehaviourSettings ¶
type BehaviourSettings struct {
CascadeDelete bool `json:"cascadeDelete"`
}
BehaviourSettings can define how one specific watch handles special cases
type Configuration ¶
type Configuration struct { Mongo Mongo `json:"mongo" validate:"required"` Watches []Watch `json:"watches" validate:"required,gt=0,dive"` }
Configuration for red keep
func NewConfiguration ¶
func NewConfiguration(configData []byte) (*Configuration, error)
NewConfiguration loads a configuration from data if it is not valid json, it will return an error
type InsertTracker ¶
type InsertTracker interface { HandleInsert( w Watch, command map[string]interface{}, originRef mgo.DBRef, ) }
InsertTracker can handle inserts
type Mongo ¶
type Mongo struct {
ConnectionURI string `json:"connectionURI" validate:"required,gt=0"`
}
Mongo is a config struct that changes the way the client connects. ConnectionURI should be a string identifying your cluster if you have to slaves and one master it would be like slave-01:27018,slave-02:27018,master:27018 where slave-01 is either a hostname or an ip
type Query ¶
Query represents a mongodb oplog query
func NewOplogQuery ¶
NewOplogQuery generates a new query object from the given dataset
type RemoveTracker ¶
type RemoveTracker interface { HandleRemove( w Watch, command map[string]interface{}, selector map[string]interface{}, ) }
RemoveTracker can handle removes
type TailAgent ¶
type TailAgent struct {
// contains filtered or unexported fields
}
TailAgent the worker that tails the database
func NewTailAgent ¶
func NewTailAgent(c Configuration) (*TailAgent, error)
NewTailAgent will generate a new tail agent
func NewTailAgentWithStartDate ¶
func NewTailAgentWithStartDate(c Configuration, startTime time.Time) (*TailAgent, error)
NewTailAgentWithStartDate will start
type Tracker ¶
type Tracker interface { RemoveTracker UpdateTracker InsertTracker }
Tracker handles changes in the oplog it is a combination of CRUD Tracker Remove/Update/Create/Delete
func NewChangeTracker ¶
func NewChangeTracker(session *mgo.Session) Tracker
NewChangeTracker is the default tracker implementation of redkeep
type UpdateTracker ¶
type UpdateTracker interface { HandleUpdate( w Watch, command map[string]interface{}, selector map[string]interface{}, ) }
UpdateTracker can handle updates
type Watch ¶
type Watch struct { //TODO validate collections to be in this scheme: database.collection TrackCollection string `json:"trackCollection" validate:"required,gt=0"` TrackFields []string `json:"trackFields" validate:"required,min=1,dive,min=1"` TargetCollection string `json:"targetCollection" validate:"required,min=1"` TargetNormalizedField string `json:"targetNormalizedField" validate:"required,min=1"` TriggerReference string `json:"triggerReference" validate:"required,min=1"` BehaviourSettings BehaviourSettings `json:"behaviourSettings"` }
Watch defines one watch that redkeep will do for you