Stats collector main application.

Constructor

new ()

Fields

config:Config

Configuration file access.

moduleClasses:Array<Dynamic>

List of module classes to load. Set by the child class.

moduleManager:ModuleManager

Stats modules manager.

Methods

getCount (q:String):Int

Executes counting SQL query and returns the result. The query should return cnt field, for example, SELECT count(*) AS cnt FROM Users.

Parameters:

q

SQL query.

Returns:

Result of counting.

inline getMedian (q:String):Float

Returns the median value for values returned by query. The query must use "val" field and be ordered from min to max, for example "SELECT ID AS Val FROM Users ORDER BY Time".

Parameters:

q

Query string.

Returns:

Median value.

getStats (key:String, ?date:String):Float

Returns the statistics value for that key.

Parameters:

key

Statistics key.

date

Statistics date. Will use "'yesterday'" by default. Note that the given string will not be quoted in the query.

Returns:

Statistics value.

init ():Void

Stats collector initialization. Should be called after instancing.

inline log (s:String):Void

Adds a message to log.

Parameters:

s

Log message.

inline query (q:String):PostgresResultSet

Executes SQL query in database.

Parameters:

q

SQL query.

Returns:

Database result set.

inline queryTrace (q:String):PostgresResultSet

Executes SQL query in database tracing it.

Parameters:

q

SQL query.

Returns:

Database result set.

inline quote (s:String):String

Escapes a string for using in SQL query as a row field.

Parameters:

s

String.

Returns:

Escaped string.

run ():Void

Run stats collection. Execute after init().