Created
November 27, 2015 10:33
-
-
Save alicebob/67930e7a66ec8449609a to your computer and use it in GitHub Desktop.
Revisions
-
Harmen created this gist
Nov 27, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ package main import ( "fmt" "time" as "github.com/aerospike/aerospike-client-go" ) const lua = ` function echoint(r, now) info("call echoint with %d", now) return now end ` func main() { client, err := as.NewClient("127.0.0.1", 3000) if err != nil { panic(err) } task, err := client.RegisterUDF( nil, []byte(lua), "echoint.lua", as.LUA, ) if err != nil { panic(err) } if err, ok := <-task.OnComplete(); ok && err != nil { panic(err) } fmt.Printf("RegisterUDF done\n") key, _ := as.NewKey("test", "test", "test") now := time.Now().UnixNano() fmt.Printf("now: %d\n", now) res, err := client.Execute( nil, key, "echoint", "echoint", as.IntegerValue(now), ) if err != nil { panic(err) } fmt.Printf("res: %+v\n", res) if have, want := res, now; have != want { fmt.Printf("oops: have %d, want %d\n", have, want) } } 1,1 Top