Documentation ¶
Index ¶
- type Connect
- type Engine
- func (e *Engine) Close()
- func (e *Engine) Query(bo []byte, params map[string]interface{}, rx ResultTypeCallback) error
- func (e *Engine) QueryExpression(exp *Expression, rx ResultCallback)
- func (e *Engine) QueryFile(file string, params map[string]interface{}, rx ResultTypeCallback) error
- func (e *Engine) QueryRule(ro *Rule, rx ResultTypeCallback)
- type Expression
- type ResultCallback
- type ResultTypeCallback
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connect ¶
Connect provides a basic connection config struct for creating the necessary mongodb connection object.
type Engine ¶
type Engine struct { *Connect *mgo.Session // contains filtered or unexported fields }
Engine provides a basic mongodb query controller, ensuring concurrent request to the given database instance.
func (*Engine) Close ¶
func (e *Engine) Close()
Close ends the session and frees the resources but ensures all request are fully processed before ending.
func (*Engine) Query ¶
func (e *Engine) Query(bo []byte, params map[string]interface{}, rx ResultTypeCallback) error
Query takes a byte slice that contain a json rule which gets turned rule struct and provided with the needed params to resolve any necessary value substitution. End result is supplied to the given callback
func (*Engine) QueryExpression ¶
func (e *Engine) QueryExpression(exp *Expression, rx ResultCallback)
QueryExpression executes a given expression against a given collection and passes the result or an error if occured to a given callback handler.
func (*Engine) QueryFile ¶
func (e *Engine) QueryFile(file string, params map[string]interface{}, rx ResultTypeCallback) error
QueryFile requests a file be loaded which contains specific rules to be used in performing a QueryRule,the file contains a json formatted rule set which will be processed and results returned to the callback
func (*Engine) QueryRule ¶
func (e *Engine) QueryRule(ro *Rule, rx ResultTypeCallback)
QueryRule runs a given rule set against a collection executing the fail or pass depending on the outcome of the Test if no error occured.
type Expression ¶
type Expression struct { Collection string `yaml:"collection" json:"collection"` Conditions []string `yaml:"conditions" json:"conditions"` }
Expression represents a query to be used against the aggregation api
type ResultCallback ¶
ResultCallback provides a function type for the return of a result from a call to Engine.Query.
type ResultTypeCallback ¶
type ResultTypeCallback func(error, *Expression, []bson.M)
ResultTypeCallback provides a function type for the returned result from a call to Engine.Query, it supplies an error, the expression used in and the result of the expression
type Rule ¶
type Rule struct { Test *Expression `json:"test" yaml:"test"` Fail *Expression `json:"failed" yaml:"failed"` Pass *Expression `json:"passed" yaml:"passed"` }
Rule repesent a set of expressions which will be tested against