Documentation ¶
Overview ¶
Builtin functions injected into expression vm.
Index ¶
- func AllFunc(ctx expr.EvalContext, vals ...value.Value) (value.BoolValue, bool)
- func AnyFunc(ctx expr.EvalContext, vals ...value.Value) (value.BoolValue, bool)
- func AvgFunc(ctx expr.EvalContext, val value.Value) (value.NumberValue, bool)
- func CastFunc(ctx expr.EvalContext, items ...value.Value) (value.Value, bool)
- func ContainsFunc(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)
- func CountFunc(ctx expr.EvalContext, val value.Value) (value.IntValue, bool)
- func DayOfWeek(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)
- func DomainFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
- func DomainsFunc(ctx expr.EvalContext, items ...value.Value) (value.StringsValue, bool)
- func EmailDomainFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
- func EmailFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
- func EmailNameFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
- func Eq(ctx expr.EvalContext, itemA, itemB value.Value) (value.BoolValue, bool)
- func Exists(ctx expr.EvalContext, item interface{}) (value.BoolValue, bool)
- func FilterFunc(ctx expr.EvalContext, val value.Value, filterVals ...value.Value) (value.Value, bool)
- func FiltersFromArgs(filterVals []value.Value) []string
- func Ge(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)
- func Gt(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)
- func HashMd5Func(ctx expr.EvalContext, arg value.Value) (value.StringValue, bool)
- func HashSha1Func(ctx expr.EvalContext, arg value.Value) (value.StringValue, bool)
- func HashSha256Func(ctx expr.EvalContext, arg value.Value) (value.StringValue, bool)
- func HashSha512Func(ctx expr.EvalContext, arg value.Value) (value.StringValue, bool)
- func HostFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
- func HostsFunc(ctx expr.EvalContext, items ...value.Value) (value.StringsValue, bool)
- func HourOfDay(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)
- func HourOfWeek(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)
- func JoinFunc(ctx expr.EvalContext, items ...value.Value) (value.StringValue, bool)
- func LeFunc(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)
- func LengthFunc(ctx expr.EvalContext, val value.Value) (value.IntValue, bool)
- func LoadAllBuiltins()
- func Lower(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
- func LtFunc(ctx expr.EvalContext, lv, rv value.Value) (value.BoolValue, bool)
- func MapFunc(ctx expr.EvalContext, lv, rv value.Value) (value.MapValue, bool)
- func Match(ctx expr.EvalContext, items ...value.Value) (value.MapValue, bool)
- func Mm(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)
- func Ne(ctx expr.EvalContext, itemA, itemB value.Value) (value.BoolValue, bool)
- func NotFunc(ctx expr.EvalContext, item value.Value) (value.BoolValue, bool)
- func Now(ctx expr.EvalContext, items ...value.Value) (value.TimeValue, bool)
- func OneOfFunc(ctx expr.EvalContext, vals ...value.Value) (value.Value, bool)
- func PowFunc(ctx expr.EvalContext, val, toPower value.Value) (value.NumberValue, bool)
- func Qs(ctx expr.EvalContext, urlItem, keyItem value.Value) (value.StringValue, bool)
- func Replace(ctx expr.EvalContext, vals ...value.Value) (value.StringValue, bool)
- func SplitFunc(ctx expr.EvalContext, input value.Value, splitByV value.StringValue) (value.StringsValue, bool)
- func SqrtFunc(ctx expr.EvalContext, val value.Value) (value.NumberValue, bool)
- func SumFunc(ctx expr.EvalContext, vals ...value.Value) (value.NumberValue, bool)
- func TimeExtractFunc(ctx expr.EvalContext, items ...value.Value) (value.StringValue, bool)
- func TimeSeconds(ctx expr.EvalContext, val value.Value) (value.NumberValue, bool)
- func ToDate(ctx expr.EvalContext, items ...value.Value) (value.TimeValue, bool)
- func ToInt(ctx expr.EvalContext, item value.Value) (value.IntValue, bool)
- func ToNumber(ctx expr.EvalContext, item value.Value) (value.NumberValue, bool)
- func ToTimestamp(ctx expr.EvalContext, item value.Value) (value.IntValue, bool)
- func UrlDecode(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
- func UrlMain(ctx expr.EvalContext, urlItem value.Value) (value.StringValue, bool)
- func UrlMinusQs(ctx expr.EvalContext, urlItem, keyItem value.Value) (value.StringValue, bool)
- func UrlPath(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
- func UuidGenerate(ctx expr.EvalContext) (value.StringValue, bool)
- func Yy(ctx expr.EvalContext, items ...value.Value) (value.IntValue, bool)
- func YyMm(ctx expr.EvalContext, items ...value.Value) (value.StringValue, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllFunc ¶
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 ¶
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 AvgFunc ¶
func AvgFunc(ctx expr.EvalContext, val value.Value) (value.NumberValue, bool)
avg: average doesn't avg bc it doesn't have a storage, but does return number
func CastFunc ¶
Cast : type coercion
cast(identity AS <type>) => 5.0 cast(reg_date AS string) => "2014/01/12" Types: [char, string, int, float]
func CountFunc ¶
Count: This should be renamed Increment
and in general is a horrible, horrible function that needs to be replaced with occurences of value, ignores the value and ensures it is non null count(anyvalue) => 1, true count(not_number) => -- 0, false
func DomainFunc ¶
func DomainFunc(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
Extract Domain from a Value, or Values (must be urlish), doesn't do much/any validation
domain("http://www.lytics.io/index.html") => "lytics.io" if input is a list of strings, only first is evaluated, for plural see domains()
func DomainsFunc ¶
func DomainsFunc(ctx expr.EvalContext, items ...value.Value) (value.StringsValue, bool)
Extract Domains from a Value, or Values (must be urlish), doesn't do much/any validation
domains("http://www.lytics.io/index.html") => []string{"lytics.io"}
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 ¶
Equal function? returns true if items are equal
given {"name":"wil","event":"stuff", "int4": 4} eq(int4,5) => false
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 FilterFunc ¶
func FilterFunc(ctx expr.EvalContext, val value.Value, filterVals ...value.Value) (value.Value, bool)
FilterFunc Filter out Values that match specified list of match filter criteria
Operates on MapValue (map[string]interface{}), StringsValue ([]string), or string
takes N Filter Criteria
supports Matching: "filter*" // matches "filter_x", "filterstuff"
-- Filter a map of values by key to remove certain keys filter(match("topic_"),key_to_filter, key2_to_filter) => {"goodkey": 22}, true
-- Filter out VALUES (not keys) from a list of []string{} for a specific value
filter(split("apples,oranges",","),"ora*") => ["apples"], true
-- Filter out values for single strings
filter("apples","app*") => []string{}, true
func FiltersFromArgs ¶
func HashMd5Func ¶
func HashMd5Func(ctx expr.EvalContext, arg value.Value) (value.StringValue, bool)
HashMd5Func Hash a value to MD5 string
hash.md5("/blog/index.html") => abc345xyz
func HashSha1Func ¶
func HashSha1Func(ctx expr.EvalContext, arg value.Value) (value.StringValue, bool)
HashSha1Func Hash a value to SHA256 string
hash.sha1("/blog/index.html") => abc345xyz
func HashSha256Func ¶
func HashSha256Func(ctx expr.EvalContext, arg value.Value) (value.StringValue, bool)
HashSha256Func Hash a value to SHA256 string
hash.sha256("/blog/index.html") => abc345xyz
func HashSha512Func ¶
func HashSha512Func(ctx expr.EvalContext, arg value.Value) (value.StringValue, bool)
HashSha512Func Hash a value to SHA512 string
hash.sha512("/blog/index.html") => abc345xyz
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") => www.lytics.io
In the event the value contains more than one input url, will ONLY evaluate first
func HostsFunc ¶
func HostsFunc(ctx expr.EvalContext, items ...value.Value) (value.StringsValue, bool)
Extract hosts from a Strings (must be urlish), doesn't do much/any validation
hosts("http://www.lytics.io", "http://www.activate.lytics.io") => www.lytics.io, www.activate.lytics.io
func HourOfWeek ¶
hour of week [0-167]
func JoinFunc ¶
func JoinFunc(ctx expr.EvalContext, items ...value.Value) (value.StringValue, bool)
Join items together (string concatenation)
join("apples","oranges",",") => "apples,oranges" join(["apples","oranges"],",") => "apples,oranges" join("apples","oranges","") => "applesoranges"
func LengthFunc ¶
len: length of array types
len([1,2,3]) => 3, true len(not_a_field) => -- NilInt, false
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 MapFunc ¶
Map() Create a map from two values. If the right side value is nil
then does not evaluate Map(left, right) => map[string]value{left:right}
func Match ¶
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 ¶
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 ¶
Not Equal function? returns true if items are equal
given {"5s":"5","item4":4,"item4s":"4"} ne(`5s`,5) => true, true ne(`not_a_field`,5) => false, true ne(`item4s`,5) => false, true ne(`item4`,5) => false, true
func NotFunc ¶
Not: urnary negation function
not(eq(5,5)) => false, true not(eq("false")) => false, true
func Now ¶
Get current time of Message (message time stamp) or else choose current
server time if none is available in message context
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) => NilNumber, false
func Qs ¶
func Qs(ctx expr.EvalContext, urlItem, keyItem value.Value) (value.StringValue, bool)
Qs Extract qs param from a string (must be url valid)
qs("http://www.lytics.io/?utm_source=google","utm_source") => "google", true
func Replace ¶
func Replace(ctx expr.EvalContext, vals ...value.Value) (value.StringValue, bool)
Replace a string(s), accepts any number of parameters to replace
replaces with "" replace("/blog/index.html", "/blog","") => /index.html replace("/blog/index.html", "/blog") => /index.html replace("/blog/index.html", "/blog/archive/","/blog") => /blog/index.html replace(item, "M")
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 SumFunc ¶
func SumFunc(ctx expr.EvalContext, vals ...value.Value) (value.NumberValue, bool)
Sum
func TimeExtractFunc ¶
func TimeExtractFunc(ctx expr.EvalContext, items ...value.Value) (value.StringValue, bool)
func TimeSeconds ¶
func TimeSeconds(ctx expr.EvalContext, val value.Value) (value.NumberValue, bool)
TimeSeconds time in Seconds, parses a variety of formats looking for seconds
See github.com/araddon/dateparse for formats supported on date parsing seconds("M10:30") => 630 seconds("M100:30") => 6030 seconds("00:30") => 30 seconds("30") => 30 seconds(30) => 30 seconds("2015/07/04") => 1435968000
func ToDate ¶
todate: convert to Date
todate("now-3m") uses lytics/datemath todate(field) uses araddon/dateparse util to recognize formats todate("01/02/2006", field ) uses golang date parse rules first parameter is the layout/format
func ToInt ¶
Convert to Integer: Best attempt at converting to integer
toint("5") => 5, true toint("5.75") => 5, true toint("5,555") => 5555, true toint("$5") => 5, true toint("5,555.00") => 5555, true
func ToNumber ¶
func ToNumber(ctx expr.EvalContext, item value.Value) (value.NumberValue, bool)
Convert to Number: Best attempt at converting to integer
tonumber("5") => 5.0 tonumber("5.75") => 5.75 tonumber("5,555") => 5555 tonumber("$5") => 5.00 tonumber("5,555.00") => 5555
func ToTimestamp ¶
totimestamp: convert to date, then to unix Seconds
func UrlDecode ¶
func UrlDecode(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
url decode a string
urldecode("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 UrlMain ¶
func UrlMain(ctx expr.EvalContext, urlItem value.Value) (value.StringValue, bool)
UrlMain remove the querystring and scheme from url
urlmain("http://www.lytics.io/?utm_source=google") => "www.lytics.io/", true
func UrlMinusQs ¶
func UrlMinusQs(ctx expr.EvalContext, urlItem, keyItem value.Value) (value.StringValue, bool)
UrlMinusQs removes a specific query parameter and its value from a url
urlminusqs("http://www.lytics.io/?q1=google&q2=123", "q1") => "http://www.lytics.io/?q2=123", true
func UrlPath ¶
func UrlPath(ctx expr.EvalContext, item value.Value) (value.StringValue, bool)
UrlPath Extract url path from a String (must be urlish), doesn't do much/any validation
path("http://www.lytics.io/blog/index.html") => blog/index.html
In the event the value contains more than one input url, will ONLY evaluate first
func UuidGenerate ¶
func UuidGenerate(ctx expr.EvalContext) (value.StringValue, bool)
uuid generates a uuid
func Yy ¶
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.