engine

package
v0.0.0-...-8035c07 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connect

type Connect struct {
	Host     string
	AuthDb   string
	Username string
	Pass     string
	Db       string
}

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 New

func New(c Connect) (*Engine, error)

New returns a new query engine 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

type ResultCallback func(error, []bson.M)

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

Jump to

Keyboard shortcuts

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