1- @startuml HTTP Binding
1+ @startuml OpenFunction in Sync Runtime
22
33box Function Process in Local Environment or Container
44control ENTRYPOINT
@@ -9,7 +9,6 @@ participant Express [
99 ----
1010 "" Express ""
1111]
12- participant Interceptor
1312participant "User Function" as UserFunction
1413participant DaprClient
1514end box
@@ -22,22 +21,14 @@ ENTRYPOINT -> Main ** : execute
2221note over ENTRYPOINT , Main : Pass through __CLI arguments__ and \ncontainer __environment variables__
2322
2423Main -> Main : load user function file
25- note left : ""function (req, res) {} ""
24+ note left : ""function (ctx, data) ""
2625
2726Main -> Server ** : create
2827note over Main , Server : Hand over __user function__, __function type__ \nand __context__ parsed from env variables
2928
3029Server -> Express ** : new
3130
32- Server -> Express : use init middleware
33- note over Server , Express : Store context in ""res.locals.context""
34-
35- Server -> Interceptor ** : new
36- Server -> Express : use interceptor
37- |||
38- Server -> Express : use others middlewares
39- |||
40- Server -> UserFunction ** : wrap user function
31+ Server -> UserFunction ** : wrap user function in ""function (req, res)""
4132note over Server , UserFunction : Use Node.js ""Domain"" to run function and catch exceptions
4233Server -> Express : bind wrapper to "/*" route
4334
@@ -48,27 +39,28 @@ Server -> Express : bind wrapper to "/*" route
4839[-> Express ++ : HTTP request to "/"
4940
5041Express -> UserFunction ++ : execute user function
51- UserFunction --> Express -- : return execution result "data"
5242
53- alt "" runtime "" = ""knative "" and ""outputs "" is not empty
54- Express -> Interceptor ++ : invoke interceptor
5543
56- Interceptor -> Interceptor : load context
57- Interceptor -> DaprClient ** : new
44+ alt output to Dapr
45+ UserFunction -> DaprClient ** : new
5846
5947 loop each OpenFunction Output
60- Interceptor -> DaprClient ++ : send "data"
48+ UserFunction -> DaprClient ++ : send "data" asynchronously
6149
62- DaprClient -> DaprSidecar ++ : invoke binding or publication with "data"
50+ DaprClient -> DaprSidecar ++ : invoke binding \nor pub with "data"
6351 DaprSidecar --> DaprClient -- : return result
6452
65- DaprClient --> Interceptor -- : forward result
6653 end
6754
68- Interceptor -> DaprClient !!
69- Interceptor --> Express -- : return "data" as response
55+ UserFunction -> DaprClient !!
56+ end
57+
58+ alt response via Express
59+ UserFunction -> UserFunction : invoke ""ctx.res"" \n(and ""ctx.req"") methods
7060end
7161
62+ UserFunction --> Express -- : wrapper ends response
63+
7264[<- Express -- : send response
7365
7466...
0 commit comments