MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / newJsEventTask

Function newJsEventTask

db/event.go:107–124  ·  view source on GitHub ↗

Compiles a JavaScript event function to a jsEventTask object.

(ctx context.Context, funcSource string)

Source from the content-addressed store, hash-verified

105
106// Compiles a JavaScript event function to a jsEventTask object.
107func newJsEventTask(ctx context.Context, funcSource string) (sgbucket.JSServerTask, error) {
108 eventTask := &jsEventTask{}
109 err := eventTask.InitWithLogging(funcSource, 0,
110 func(s string) {
111 base.ErrorfCtx(ctx, base.KeyJavascript.String()+": Webhook %s", base.UD(s))
112 },
113 func(s string) { base.InfofCtx(ctx, base.KeyJavascript, "Webhook %s", base.UD(s)) })
114 if err != nil {
115 return nil, err
116 }
117
118 eventTask.After = func(result otto.Value, err error) (interface{}, error) {
119 nativeValue, _ := result.Export()
120 return nativeValue, err
121 }
122
123 return eventTask, nil
124}
125
126//////// JSEventFunction
127

Callers 1

NewJSEventFunctionFunction · 0.85

Calls 4

ErrorfCtxFunction · 0.92
UDFunction · 0.92
InfofCtxFunction · 0.92
StringMethod · 0.65

Tested by

no test coverage detected