Skip to content

Commit

Permalink
feat: support single resource CRUD
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Dec 1, 2024
1 parent 5c6e00d commit 54002a8
Show file tree
Hide file tree
Showing 16 changed files with 498 additions and 362 deletions.
157 changes: 3 additions & 154 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,160 +32,9 @@ To optimize execution, two key processes—compilation and runtime—are employe

The engine does not expose an API for directly modifying node specifications. Instead, it focuses on loading, compiling, and activating nodes to make them executable.

Users can update node specifications by using a Command-Line Interface (CLI) or defining workflows that provide an HTTP API for modifications. Typically, these workflows are defined in the `system` namespace.

```yaml
- kind: listener
name: listener
protocol: http
port: '{{ .PORT }}'
ports:
out:
- name: router
port: in
error:
- name: catch
port: in

- kind: router
name: router
routes:
- method: POST
path: /v1/specs
port: out[0]
- method: GET
path: /v1/specs
port: out[1]
- method: PATCH
path: /v1/specs
port: out[2]
- method: DELETE
path: /v1/specs
port: out[3]
ports:
out[0]:
- name: specs_create
port: in
out[1]:
- name: specs_read
port: in
out[2]:
- name: specs_update
port: in
out[3]:
- name: specs_delete
port: in

- kind: block
name: specs_create
specs:
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
opcode: specs.create
- kind: snippet
language: javascript
code: |
export default function (args) {
return {
body: args,
status: 201
};
}
- kind: block
name: specs_read
specs:
- kind: snippet
language: json
code: 'null'
- kind: native
opcode: specs.read
- kind: snippet
language: javascript
code: |
export default function (args) {
return {
body: args,
status: 200
};
}
- kind: block
name: specs_update
specs:
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
opcode: specs.update
- kind: snippet
language: javascript
code: |
export default function (args) {
return {
body: args,
status: 200
};
}
- kind: block
name: specs_delete
specs:
- kind: snippet
language: json
code: 'null'
- kind: native
opcode: specs.delete
- kind: snippet
language: javascript
code: |
export default function (args) {
return {
status: 204
};
}
- kind: switch
name: catch
matches:
- when: self == "unsupported type" || self == "unsupported value"
port: out[0]
- when: 'true'
port: out[1]
ports:
out[0]:
- name: status_400
port: in
out[1]:
- name: status_500
port: in

- kind: snippet
name: status_400
language: javascript
code: |
export default function (args) {
return {
body: {
error: args.error()
},
status: 400
};
}
- kind: snippet
name: status_500
language: json
code: |
{
"body": {
"error": "Internal Server Error"
},
"status": 500
}
```
Users can update node specifications by using a Command-Line Interface (CLI) or
defining [workflows](../examples/system.yaml) that provide an HTTP API for modifications. Typically, these workflows are
defined in the `system` namespace.

This approach ensures runtime stability while allowing flexible system expansion.

Expand Down
156 changes: 2 additions & 154 deletions docs/architecture_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,160 +30,8 @@

### 워크플로우 수정

엔진은 사용자에게 노드 명세 변경을 위한 API를 제공하지 않으며, 노드를 로드하고 컴파일하여 실행하는 데 집중합니다. 노드 명세를 수정할 필요가 있을 때는 Command-Line Interface(CLI)나 직접 정의한 워크플로우를 통해 HTTP API로 명세를 업데이트할 수 있습니다. 이러한 워크플로우는 보통 `system` 네임스페이스에 정의됩니다.

```yaml
- kind: listener
name: listener
protocol: http
port: '{{ .PORT }}'
ports:
out:
- name: router
port: in
error:
- name: catch
port: in

- kind: router
name: router
routes:
- method: POST
path: /v1/specs
port: out[0]
- method: GET
path: /v1/specs
port: out[1]
- method: PATCH
path: /v1/specs
port: out[2]
- method: DELETE
path: /v1/specs
port: out[3]
ports:
out[0]:
- name: specs_create
port: in
out[1]:
- name: specs_read
port: in
out[2]:
- name: specs_update
port: in
out[3]:
- name: specs_delete
port: in

- kind: block
name: specs_create
specs:
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
opcode: specs.create
- kind: snippet
language: javascript
code: |
export default function (args) {
return {
body: args,
status: 201
};
}
- kind: block
name: specs_read
specs:
- kind: snippet
language: json
code: 'null'
- kind: native
opcode: specs.read
- kind: snippet
language: javascript
code: |
export default function (args) {
return {
body: args,
status: 200
};
}
- kind: block
name: specs_update
specs:
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
opcode: specs.update
- kind: snippet
language: javascript
code: |
export default function (args) {
return {
body: args,
status: 200
};
}
- kind: block
name: specs_delete
specs:
- kind: snippet
language: json
code: 'null'
- kind: native
opcode: specs.delete
- kind: snippet
language: javascript
code: |
export default function (args) {
return {
status: 204
};
}
- kind: switch
name: catch
matches:
- when: self == "unsupported type" || self == "unsupported value"
port: out[0]
- when: 'true'
port: out[1]
ports:
out[0]:
- name: status_400
port: in
out[1]:
- name: status_500
port: in

- kind: snippet
name: status_400
language: javascript
code: |
export default function (args) {
return {
body: {
error: args.error()
},
status: 400
};
}
- kind: snippet
name: status_500
language: json
code: |
{
"body": {
"error": "Internal Server Error"
},
"status": 500
}
```
엔진은 사용자에게 노드 명세 변경을 위한 API를 제공하지 않으며, 노드를 로드하고 컴파일하여 실행하는 데 집중합니다. 노드 명세를 수정할 필요가 있을 때는 Command-Line Interface(CLI)나 직접
정의한 [워크플로우](../examples/system.yaml)를 통해 HTTP API로 명세를 업데이트할 수 있습니다. 이러한 워크플로우는 보통 `system` 네임스페이스에 정의됩니다.

이 접근 방식은 안정적인 런타임 환경을 유지하면서 시스템을 유연하게 확장할 수 있도록 합니다.

Expand Down
Loading

0 comments on commit 54002a8

Please sign in to comment.