Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
913b2fceea | ||
|
|
fbb33e444b |
6
docs/fx_node.md
Normal file
6
docs/fx_node.md
Normal file
@@ -0,0 +1,6 @@
|
||||
fx support Observerity for Node/JavaScript function natively.
|
||||
|
||||
```
|
||||
ui: http://<host>:<port>/swagger-stats/ux
|
||||
promethus: http://<host>:<port>/swagger-stats/metrics
|
||||
```
|
||||
48
examples/functions/demo/Makefile
vendored
Normal file
48
examples/functions/demo/Makefile
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
up:
|
||||
fx up -n ping.go.0 -p 12341 --force fx.go
|
||||
fx up -n ping.java.0 -p 12342 --force fx.java
|
||||
fx up -n ping.js.0 -p 12343 --force fx.js
|
||||
fx up -n ping.pl.0 -p 12344 --force fx.pl
|
||||
fx up -n ping.py.0 -p 12345 --force fx.py
|
||||
fx up -n ping.rb.0 -p 12346 --force fx.rb
|
||||
fx up -n ping.rs.0 -p 12347 --force fx.rs
|
||||
fx up -n ping.cr.0 -p 12348 --force fx.cr
|
||||
fx up -n ping.d.0 -p 12349 --force fx.d
|
||||
down:
|
||||
fx down ping.go.0
|
||||
fx down ping.java.0
|
||||
fx down ping.js.0
|
||||
fx down ping.pl.0
|
||||
fx down ping.py.0
|
||||
fx down ping.rb.0
|
||||
fx down ping.rs.0
|
||||
fx down ping.cr.0
|
||||
fx down ping.d.0
|
||||
l:
|
||||
fx list
|
||||
t:
|
||||
@curl 127.0.0.1:12341
|
||||
@echo ""
|
||||
@curl 127.0.0.1:12343
|
||||
@echo ""
|
||||
@curl 127.0.0.1:12344
|
||||
@echo ""
|
||||
@curl 127.0.0.1:12345
|
||||
@echo ""
|
||||
@curl 127.0.0.1:12346
|
||||
@echo ""
|
||||
@curl 127.0.0.1:12348
|
||||
@echo ""
|
||||
@curl 127.0.0.1:12349
|
||||
@echo ""
|
||||
@curl -X POST -H 'Content-Type: application/json' 127.0.0.1:12342 -d '{"a": 1, "b": 1 }'
|
||||
@echo ""
|
||||
@curl -X POST -H 'Content-Type: application/json' 127.0.0.1:12347 -d '{"a": 1, "b": 2 }'
|
||||
@echo ""
|
||||
@curl -X POST -H 'Content-Type: application/json' 127.0.0.1:12349 -d '{"a": 1, "b": 3 }'
|
||||
@echo ""
|
||||
b:
|
||||
ab -n 10000 -c 10 http://127.0.0.1:12343/
|
||||
m:
|
||||
open http://127.0.0.1:12343/swagger-stats/ux
|
||||
open http://127.0.0.1:12343/swagger-stats/metrics
|
||||
63
examples/functions/demo/demo.cast
vendored
Normal file
63
examples/functions/demo/demo.cast
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{"version": 2, "width": 204, "height": 64, "timestamp": 1602561588, "env": {"SHELL": "/bin/zsh", "TERM": "xterm-256color"}}
|
||||
[1.881844, "o", "\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r\u001b]2;minhuang@FVFXG11WHV2J: ~/projects/fx/examples/functions/demo\u0007\u001b]1;..unctions/demo\u0007"]
|
||||
[2.04323, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[01;32m➜ \u001b[36mdemo\u001b[00m \u001b[01;34mgit:(\u001b[31mdemo\u001b[34m) \u001b[33m✗\u001b[00m "]
|
||||
[2.043443, "o", "\u001b[K"]
|
||||
[2.043636, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
|
||||
[2.85694, "o", "f"]
|
||||
[3.022723, "o", "\bfg"]
|
||||
[3.167563, "o", "\u001b[?1l\u001b>"]
|
||||
[3.167764, "o", "\u001b[?2004l\r\r\n"]
|
||||
[3.16933, "o", "\u001b]2;fg\u0007\u001b]1;fg\u0007"]
|
||||
[3.169498, "o", "fg: no current job\r\n\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r"]
|
||||
[3.169535, "o", "\u001b]2;minhuang@FVFXG11WHV2J: ~/projects/fx/examples/functions/demo\u0007"]
|
||||
[3.169994, "o", "\u001b]1;..unctions/demo\u0007"]
|
||||
[3.326735, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[01;31m➜ \u001b[36mdemo\u001b[00m \u001b[01;34mgit:(\u001b[31mdemo\u001b[34m) \u001b[33m✗\u001b[00m \u001b[K"]
|
||||
[3.326893, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
|
||||
[4.239502, "o", "v"]
|
||||
[4.355434, "o", "\bvi"]
|
||||
[5.162926, "o", "\b\bv \b"]
|
||||
[5.314817, "o", "\b \b"]
|
||||
[5.601643, "o", "f"]
|
||||
[5.69716, "o", "\bfg"]
|
||||
[5.833094, "o", "\u001b[?1l\u001b>"]
|
||||
[5.833277, "o", "\u001b[?2004l\r\r\n"]
|
||||
[5.833948, "o", "\u001b]2;fg\u0007\u001b]1;fg\u0007"]
|
||||
[5.834301, "o", "fg: no current job\r\n\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r\u001b]2;minhuang@FVFXG11WHV2J: ~/projects/fx/examples/functions/demo\u0007\u001b]1;..unctions/demo\u0007"]
|
||||
[5.957947, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[01;31m➜ \u001b[36mdemo\u001b[00m \u001b[01;34mgit:(\u001b[31mdemo\u001b[34m) \u001b[33m✗\u001b[00m \u001b[K"]
|
||||
[5.958194, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
|
||||
[6.547304, "o", "f"]
|
||||
[6.707392, "o", "\bfg"]
|
||||
[6.8212, "o", "\u001b[?1l\u001b>"]
|
||||
[6.821279, "o", "\u001b[?2004l"]
|
||||
[6.82149, "o", "\r\r\n"]
|
||||
[6.822082, "o", "\u001b]2;fg\u0007\u001b]1;fg\u0007"]
|
||||
[6.82219, "o", "fg: no current job\r\n"]
|
||||
[6.822268, "o", "\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r"]
|
||||
[6.82273, "o", "\u001b]2;minhuang@FVFXG11WHV2J: ~/projects/fx/examples/functions/demo\u0007\u001b]1;..unctions/demo\u0007"]
|
||||
[6.963467, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[01;31m➜ \u001b[36mdemo\u001b[00m \u001b[01;34mgit:(\u001b[31mdemo\u001b[34m) \u001b[33m✗\u001b[00m \u001b[K"]
|
||||
[6.963641, "o", "\u001b[?1h\u001b="]
|
||||
[6.963776, "o", "\u001b[?2004h"]
|
||||
[13.288488, "o", "f"]
|
||||
[13.364954, "o", "\bfg"]
|
||||
[13.511865, "o", "\u001b[?1l\u001b>"]
|
||||
[13.512049, "o", "\u001b[?2004l\r\r\n"]
|
||||
[13.512809, "o", "\u001b]2;fg\u0007\u001b]1;fg\u0007"]
|
||||
[13.513361, "o", "fg: no current job\r\n\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r\u001b]2;minhuang@FVFXG11WHV2J: ~/projects/fx/examples/functions/demo\u0007\u001b]1;..unctions/demo\u0007"]
|
||||
[13.745801, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[01;31m➜ \u001b[36mdemo\u001b[00m \u001b[01;34mgit:(\u001b[31mdemo\u001b[34m) \u001b[33m✗\u001b[00m \u001b[K"]
|
||||
[13.746011, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
|
||||
[13.969195, "o", "f"]
|
||||
[14.102194, "o", "\bfg"]
|
||||
[14.236118, "o", "\u001b[?1l\u001b>"]
|
||||
[14.236332, "o", "\u001b[?2004l\r\r\n"]
|
||||
[14.237195, "o", "\u001b]2;fg\u0007\u001b]1;fg\u0007"]
|
||||
[14.237358, "o", "fg: no current job\r\n\u001b[1m\u001b[7m%\u001b[27m\u001b[1m\u001b[0m \r \r"]
|
||||
[14.237948, "o", "\u001b]2;minhuang@FVFXG11WHV2J: ~/projects/fx/examples/functions/demo\u0007\u001b]1;..unctions/demo\u0007"]
|
||||
[14.410771, "o", "\r\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[01;31m➜ \u001b[36mdemo\u001b[00m \u001b[01;34mgit:(\u001b[31mdemo\u001b[34m) \u001b[33m✗\u001b[00m \u001b[K"]
|
||||
[14.410938, "o", "\u001b[?1h\u001b=\u001b[?2004h"]
|
||||
[14.812678, "o", "e"]
|
||||
[15.058809, "o", "\bex"]
|
||||
[15.147778, "o", "i"]
|
||||
[15.356224, "o", "t"]
|
||||
[15.604192, "o", "\u001b[?1l\u001b>"]
|
||||
[15.604361, "o", "\u001b[?2004l\r\r\n"]
|
||||
[15.606869, "o", "\u001b]2;exit\u0007\u001b]1;exit\u0007"]
|
||||
3
examples/functions/demo/fx.cr
vendored
Normal file
3
examples/functions/demo/fx.cr
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
def fx(ctx)
|
||||
"hello world, crystal"
|
||||
end
|
||||
6
examples/functions/demo/fx.d
vendored
Normal file
6
examples/functions/demo/fx.d
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import std.json;
|
||||
|
||||
long executeFx(JSONValue input)
|
||||
{
|
||||
return input["a"].integer + input["b"].integer;
|
||||
}
|
||||
9
examples/functions/demo/fx.go
vendored
Normal file
9
examples/functions/demo/fx.go
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func fx(ctx *gin.Context) {
|
||||
ctx.JSON(200, gin.H{
|
||||
"message": "hello world, Go",
|
||||
})
|
||||
}
|
||||
11
examples/functions/demo/fx.java
vendored
Normal file
11
examples/functions/demo/fx.java
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
package fx;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Fx {
|
||||
public int handle(JSONObject input) {
|
||||
String a = input.get("a").toString();
|
||||
String b = input.get("b").toString();
|
||||
return Integer.parseInt(a) + Integer.parseInt(b);
|
||||
}
|
||||
}
|
||||
8
examples/functions/demo/fx.jl
vendored
Normal file
8
examples/functions/demo/fx.jl
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
struct Input
|
||||
a::Number
|
||||
b::Number
|
||||
end
|
||||
|
||||
fx = function(input::Input)
|
||||
return input.a + input.b
|
||||
end
|
||||
3
examples/functions/demo/fx.js
vendored
Normal file
3
examples/functions/demo/fx.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = (ctx) => {
|
||||
ctx.body = 'hello world, JavaScript'
|
||||
}
|
||||
5
examples/functions/demo/fx.pl
vendored
Normal file
5
examples/functions/demo/fx.pl
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
sub fx {
|
||||
return 'hello world, Perl'
|
||||
}
|
||||
|
||||
1;
|
||||
2
examples/functions/demo/fx.py
vendored
Normal file
2
examples/functions/demo/fx.py
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
def fx(request):
|
||||
return "hello world, Python"
|
||||
3
examples/functions/demo/fx.rb
vendored
Normal file
3
examples/functions/demo/fx.rb
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
def fx(ctx)
|
||||
ctx[:response].body = "hello world, Ruby"
|
||||
end
|
||||
18
examples/functions/demo/fx.rs
vendored
Normal file
18
examples/functions/demo/fx.rs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
pub mod fns {
|
||||
#[derive(Serialize)]
|
||||
pub struct Response {
|
||||
pub result: i32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Request {
|
||||
pub a: i32,
|
||||
pub b: i32,
|
||||
}
|
||||
|
||||
pub fn func(req: Request) -> Response {
|
||||
Response {
|
||||
result: req.a + req.b,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user