From 6ed02a8368c55008985ee276b8de1340fb7193a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Mon, 18 Mar 2024 02:49:02 +0000 Subject: [PATCH] 3 tweaks: LState: IncludeGoStackTraces peerdb.RowColumns: start indexing at 1 Time: rename `unix` to `unix_seconds`, expose `unix` as returning a floating point number of seconds since unix epoch --- flow/connectors/kafka/kafka.go | 2 +- flow/pua/peerdb.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/flow/connectors/kafka/kafka.go b/flow/connectors/kafka/kafka.go index 920d14c872..f007922f46 100644 --- a/flow/connectors/kafka/kafka.go +++ b/flow/connectors/kafka/kafka.go @@ -137,7 +137,7 @@ func (c *KafkaConnector) SyncRecords(ctx context.Context, req *model.SyncRecords var fn *lua.LFunction var ls *lua.LState if req.Script != "" { - ls = lua.NewState(lua.Options{SkipOpenLibs: true}) + ls = lua.NewState(lua.Options{SkipOpenLibs: true, IncludeGoStackTrace: true}) defer ls.Close() ls.SetContext(wgCtx) for _, pair := range []struct { diff --git a/flow/pua/peerdb.go b/flow/pua/peerdb.go index bbcf9cc508..44dade8a89 100644 --- a/flow/pua/peerdb.go +++ b/flow/pua/peerdb.go @@ -147,7 +147,7 @@ func LuaRowColumns(ls *lua.LState) int { _, row := LuaRow.Check(ls, 1) tbl := ls.CreateTable(len(row.ColToValIdx), 0) for col, idx := range row.ColToValIdx { - tbl.RawSetInt(idx, lua.LString(col)) + tbl.RawSetInt(idx+1, lua.LString(col)) } ls.Push(tbl) return 1 @@ -507,8 +507,10 @@ func LuaTimeIndex(ls *lua.LState) int { ls.Push(LuaI64.New(ls, tm.UnixMicro())) case "unix_milli": ls.Push(LuaI64.New(ls, tm.UnixMilli())) - case "unix": + case "unix_second": ls.Push(LuaI64.New(ls, tm.Unix())) + case "unix": + ls.Push(lua.LNumber(float64(tm.Unix()) + float64(tm.Nanosecond())/1e9)) case "year": ls.Push(lua.LNumber(tm.Year())) case "month":