builtins

package
Version: v0.0.0-...-daaaa79 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2015 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllFunc

func AllFunc(ctx expr.EvalContext, vals ...value.Value) (value.BoolValue, bool)

All: Answers True/False if all of the arguments evaluate to truish (javascripty)

  type definintion of true

int > 0 = true
string != "" = true
boolean natively supported true/false

all("hello",2, true) => true
all("hello",0,true)  => false
all("",2, true)      => false

func AnyFunc

func AnyFunc(ctx expr.EvalContext, vals ...value.Value) (value.BoolValue, bool)

Any: Answers True/False if any of the arguments evaluate to truish (javascripty)

  type definintion of true

int > 0 = true
string != "" = true

any(item,item2)  => true, true
any(not_field)   => false, true

func ContainsFunc

func ContainsFunc(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)

String contains

Will first convert to string, so may get unexpected results

func CountFunc

func CountFunc(ctx expr.EvalContext, val value.Value) (value.IntValue, bool)

Count: count occurences of value, ignores the value and ensures it is non null

count(anyvalue)     =>  1, true
count(not_number)   =>  -- Could not be evaluated

func DayOfWeek

func DayOfWeek(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)

day of week [0-6]

func EmailDomainFunc

func EmailDomainFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)

email a string, parses email

email("Bob <bob@bob.com>") =>  bob@bob.com

func EmailFunc

func EmailFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)

email a string, parses email

email("Bob <bob@bob.com>")  =>  bob@bob.com, true
email("Bob <bob>")          =>  "", false

func EmailNameFunc

func EmailNameFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)

emailname a string, parses email

emailname("Bob <bob@bob.com>") =>  Bob

func Eq

func Eq(ctx expr.EvalContext, itemA, itemB value.Value) (value.BoolValue, bool)

Equal function? returns true if items are equal

eq(item,5)

func Exists

func Exists(ctx expr.EvalContext, item interface{}) (value.BoolValue, bool)

Exists: Answers True/False if the field exists and is non null

exists(real_field) => true
exists("value") => true
exists("") => false
exists(empty_field) => false
exists(2) => true
exists(todate(date_field)) => true

func Ge

func Ge(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)

>= GreaterThan or Equal

Must be able to convert items to Floats or else not ok

func Gt

func Gt(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)

> GreaterThan

Must be able to convert items to Floats or else not ok

func HostFunc

func HostFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)

Extract host from a String (must be urlish), doesn't do much/any validation

host("http://www.lytics.io/index.html") =>  http://www.lytics.io

In the event the value contains more than one input url, will ONLY evaluate first

func HourOfDay

func HourOfDay(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)

hour of day [0-23]

func HourOfWeek

func HourOfWeek(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)

hour of week [0-167]

func JoinFunc

func JoinFunc(ctx expr.EvalContext, items ...value.Value) (value.StringValue, bool)

Join items

join("applies","oranges",",") => "apples,oranges"

func LeFunc

func LeFunc(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)

<= Less Than or Equal

Must be able to convert items to Floats or else not ok

func LoadAllBuiltins

func LoadAllBuiltins()

func Lower

func Lower(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)

String lower function

must be able to convert to string

func LtFunc

func LtFunc(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)

< Less Than

Must be able to convert items to Floats or else not ok

func Match

func Match(ctx expr.EvalContext, item value.Value) (value.MapValue, bool)

match: Match a simple pattern match and return matched value

given input:
    {"score_value":24,"event_click":true}

   match("score_") => {"value":24}
   match("amount_") => false
   match("event_") => {"click":true}

func Mm

func Mm(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)

Get month as integer from date

 @optional timestamp (if not, gets from context reader)

mm()                =>  01, true  /// assuming message ts = jan 1
mm("2014-03-17")    =>  03, true

func Ne

func Ne(ctx expr.EvalContext, itemA, itemB value.Value) (value.BoolValue, bool)

Not Equal function? returns true if items are equal

ne(item,5)

func NotFunc

func NotFunc(ctx expr.EvalContext, item value.Value) (value.BoolValue, bool)

Not: urnary negation function

eq(item,5)

func Now

func Now(ctx expr.EvalContext, items ...value.Value) (value.TimeValue, bool)

Get current time of Message (message time stamp) or else choose current

server time if none is available in message context

func OneOfFunc

func OneOfFunc(ctx expr.EvalContext, vals ...value.Value) (value.Value, bool)

choose OneOf these fields, first non-null

func PowFunc

func PowFunc(ctx expr.EvalContext, val, toPower value.Value) (value.NumberValue, bool)

Pow: exponents, raise x to the power of y

pow(5,2)            =>  25, true
pow(3,2)            =>  9, true
pow(not_number,2)   =>  0, false

func Qs

func Qs(ctx expr.EvalContext, urlItem, keyItem value.Value) (value.StringValue, bool)

Extract qs param from a string (must be url valid)

qs("http://www.lytics.io/?utm_source=google","utm_source")  => "google", true

func SplitFunc

func SplitFunc(ctx expr.EvalContext, input value.Value, splitByV value.StringValue) (value.StringsValue, bool)

Split a string, accepts an optional with parameter

split(item, ",")

func SqrtFunc

func SqrtFunc(ctx expr.EvalContext, val value.Value) (value.NumberValue, bool)

Sqrt

sqrt(4)            =>  2, true
sqrt(9)            =>  3, true
sqrt(not_number)   =>  0, false

func ToDate

func ToDate(ctx expr.EvalContext, item value.Value) (value.TimeValue, bool)

todate: convert to Date

func ToInt

func ToInt(ctx expr.EvalContext, item value.Value) (value.IntValue, bool)

Convert to Integer: Best attempt at converting to integer

toint("5") => 5
toint("5.75") => 5
toint("5,555") => 5555
toint("$5") => 5
toint("5,555.00") => 5555

func ToTimestamp

func ToTimestamp(ctx expr.EvalContext, item value.Value) (value.IntValue, bool)

totimestamp: convert to date, then to unix Seconds

func UrlPath

func UrlPath(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)

Extract url path from a String (must be urlish), doesn't do much/any validation

host("http://www.lytics.io/blog/index.html") =>  blog

In the event the value contains more than one input url, will ONLY evaluate first

func Yy

func Yy(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)

Get year in integer from field, must be able to convert to date

yy()                 =>  15, true    // assuming it is 2015
yy("2014-03-01")     =>  14, true

func YyMm

func YyMm(ctx expr.EvalContext, items ...value.Value) (value.StringValue, bool)

Get yymm in 4 digits from argument if supplied, else uses message context ts

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL