add first commit
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
[[workers]]
|
||||
type = "example"
|
||||
module = "plugins.example"
|
||||
factory = "create_workers"
|
||||
count = 3
|
||||
config = { type = "example" }
|
||||
@@ -0,0 +1,16 @@
|
||||
# add 接口 — 按请求类型分节
|
||||
# subject 会带上方法后缀: example.add.GET / example.add.POST
|
||||
|
||||
[GET]
|
||||
cacheable = true
|
||||
summary = "Add two numbers"
|
||||
docstring = "Add two numbers via GET query params"
|
||||
params = ["a: float", "b: float"]
|
||||
response_model = { result = { type = "float", required = true }, operation = { type = "str", default = "add" }, timestamp = { type = "float", required = false, default = 0.0 } }
|
||||
|
||||
[POST]
|
||||
cacheable = true
|
||||
summary = "Add two numbers (POST)"
|
||||
docstring = "Add two numbers via POST JSON body"
|
||||
params = ["a: float", "b: float"]
|
||||
response_model = { result = { type = "float", required = true }, operation = { type = "str", default = "add" }, timestamp = { type = "float", required = false, default = 0.0 } }
|
||||
@@ -0,0 +1,13 @@
|
||||
[worker]
|
||||
name = "example"
|
||||
version = "0.1.0"
|
||||
description = "chongming worker example — demonstrates new config features"
|
||||
config_version = "1.0"
|
||||
defaults = { method = "GET", ttl = 30, timeout = 2.0, auth_required = true, cacheable = false }
|
||||
|
||||
[worker.registration]
|
||||
type = "register"
|
||||
service = "example"
|
||||
worker_type = "calc-workers"
|
||||
router_prefix = "/calc"
|
||||
tags = ["example"]
|
||||
@@ -0,0 +1,7 @@
|
||||
# divide 接口
|
||||
|
||||
[GET]
|
||||
summary = "Divide two numbers"
|
||||
docstring = "Divide two numbers via GET query params (a / b). Returns error if b == 0."
|
||||
params = ["a: float", "b: float"]
|
||||
response_model = { result = { type = "float", required = false, default = 0.0 }, operation = { type = "str", default = "divide" }, timestamp = { type = "float", required = false, default = 0.0 }, error = { type = "str", required = false, default = "" } }
|
||||
@@ -0,0 +1,7 @@
|
||||
# multiply 接口
|
||||
|
||||
[GET]
|
||||
summary = "Multiply two numbers"
|
||||
docstring = "Multiply two numbers via GET query params (a * b)"
|
||||
params = ["a: float", "b: float"]
|
||||
response_model = { result = { type = "float", required = true }, operation = { type = "str", default = "multiply" }, timestamp = { type = "float", required = false, default = 0.0 } }
|
||||
@@ -0,0 +1,7 @@
|
||||
# subtract 接口
|
||||
|
||||
[GET]
|
||||
summary = "Subtract two numbers"
|
||||
docstring = "Subtract two numbers via GET query params (a - b)"
|
||||
params = ["a: float", "b: float"]
|
||||
response_model = { result = { type = "float", required = true }, operation = { type = "str", default = "subtract" }, timestamp = { type = "float", required = false, default = 0.0 } }
|
||||
Reference in New Issue
Block a user