Skip to content

Commit

Permalink
refactor: change node kind native to syscall and divide signals and s…
Browse files Browse the repository at this point in the history
…yscalls
  • Loading branch information
siyul-park committed Dec 21, 2024
1 parent 11fcefb commit 4ee58f0
Show file tree
Hide file tree
Showing 22 changed files with 537 additions and 506 deletions.
32 changes: 24 additions & 8 deletions cmd/pkg/uniflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,24 @@ import (
const configFile = ".uniflow.toml"

const (
topicSpecs = "specs"
topicSecrets = "secrets"
topicCharts = "charts"

opCreateSpecs = "specs.create"
opReadSpecs = "specs.read"
opUpdateSpecs = "specs.update"
opDeleteSpecs = "specs.delete"
opWatchSpecs = "specs.watch"

opCreateSecrets = "secrets.create"
opReadSecrets = "secrets.read"
opUpdateSecrets = "secrets.update"
opDeleteSecrets = "secrets.delete"
opWatchSecrets = "secrets.watch"

opCreateCharts = "charts.create"
opReadCharts = "charts.read"
opUpdateCharts = "charts.update"
opDeleteCharts = "charts.delete"
opWatchCharts = "charts.watch"
)

func init() {
Expand Down Expand Up @@ -100,28 +101,43 @@ func main() {
languages.Store(javascript.Language, javascript.NewCompiler())
languages.Store(typescript.Language, typescript.NewCompiler())

operators := map[string]any{
signals := map[string]any{
topicSpecs: system.WatchResource(specStore),
topicSecrets: system.WatchResource(secretStore),
topicCharts: system.WatchResource(chartStore),
}
syscalls := map[string]any{
opCreateSpecs: system.CreateResource(specStore),
opReadSpecs: system.ReadResource(specStore),
opUpdateSpecs: system.UpdateResource(specStore),
opDeleteSpecs: system.DeleteResource(specStore),
opWatchSpecs: system.WatchResource(specStore),
opCreateSecrets: system.CreateResource(secretStore),
opReadSecrets: system.ReadResource(secretStore),
opUpdateSecrets: system.UpdateResource(secretStore),
opDeleteSecrets: system.DeleteResource(secretStore),
opWatchSecrets: system.WatchResource(secretStore),
opCreateCharts: system.CreateResource(chartStore),
opReadCharts: system.ReadResource(chartStore),
opUpdateCharts: system.UpdateResource(chartStore),
opDeleteCharts: system.DeleteResource(chartStore),
opWatchCharts: system.WatchResource(chartStore),
}

systemAddToScheme := system.AddToScheme()

for topic, signal := range signals {
if err := systemAddToScheme.SetSignal(topic, signal); err != nil {
log.Fatal(err)
}
}
for opcode, syscall := range syscalls {
if err := systemAddToScheme.SetSyscall(opcode, syscall); err != nil {
log.Fatal(err)
}
}

schemeBuilder.Register(control.AddToScheme(languages, cel.Language))
schemeBuilder.Register(io.AddToScheme(io.NewOSFileSystem()))
schemeBuilder.Register(network.AddToScheme())
schemeBuilder.Register(system.AddToScheme(operators))
schemeBuilder.Register(systemAddToScheme)

hookBuilder.Register(network.AddToHook())
hookBuilder.Register(system.AddToHook())
Expand Down
5 changes: 3 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ To retrieve charts:

## Integrating HTTP API

To modify node specifications via the HTTP API, set up workflows accordingly. You can use the `native` node provided in the [core extensions](../ext/README.md):
To modify node specifications via the HTTP API, set up workflows accordingly. You can use the `syscall` node provided in
the [core extensions](../ext/README.md):

```yaml
kind: native
kind: syscall
opcode: specs.create # or specs.read, specs.update, specs.delete
```
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ pong#

## HTTP API 통합

HTTP API를 통해 노드 명세를 수정하려면, 관련 워크플로우를 설정해야 합니다. 이를 위해 [기본 확장](../ext/README_kr.md)에 포함된 `native` 노드를 사용할 수 있습니다:
HTTP API를 통해 노드 명세를 수정하려면, 관련 워크플로우를 설정해야 합니다. 이를 위해 [기본 확장](../ext/README_kr.md)에 포함된 `syscall` 노드를 사용할 수 있습니다:

```yaml
kind: native
kind: syscall
opcode: specs.create # 또는 specs.read, specs.update, specs.delete
```
Expand Down
48 changes: 24 additions & 24 deletions examples/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
- kind: syscall
opcode: specs.create
- kind: snippet
language: javascript
Expand All @@ -192,7 +192,7 @@
values?.map((value) => ({ [key]: value })) || []
);
}
- kind: native
- kind: syscall
opcode: specs.read
- kind: snippet
language: javascript
Expand All @@ -210,7 +210,7 @@
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
- kind: syscall
opcode: specs.update
- kind: snippet
language: javascript
Expand All @@ -233,7 +233,7 @@
values?.map((value) => ({ [key]: value })) || []
);
}
- kind: native
- kind: syscall
opcode: specs.delete
- kind: snippet
language: javascript
Expand All @@ -250,7 +250,7 @@
- kind: snippet
language: cel
code: 'has(self.params) ? self.params : null'
- kind: native
- kind: syscall
opcode: specs.read
- kind: snippet
language: javascript
Expand All @@ -277,7 +277,7 @@
export default function ({ body, params }) {
return { ...body, ...params };
}
- kind: native
- kind: syscall
opcode: specs.update
- kind: snippet
language: javascript
Expand All @@ -301,7 +301,7 @@
- kind: snippet
language: cel
code: 'has(self.params) ? self.params : null'
- kind: native
- kind: syscall
opcode: specs.delete
- kind: snippet
language: javascript
Expand All @@ -327,7 +327,7 @@

- kind: signal
name: signal
opcode: specs.watch
topic: specs
ports:
out:
- name: session
Expand Down Expand Up @@ -372,7 +372,7 @@
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
- kind: syscall
opcode: secrets.create
- kind: snippet
language: javascript
Expand All @@ -395,7 +395,7 @@
values?.map((value) => ({ [key]: value })) || []
);
}
- kind: native
- kind: syscall
opcode: secrets.read
- kind: snippet
language: javascript
Expand All @@ -413,7 +413,7 @@
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
- kind: syscall
opcode: secrets.update
- kind: snippet
language: javascript
Expand All @@ -436,7 +436,7 @@
values?.map((value) => ({ [key]: value })) || []
);
}
- kind: native
- kind: syscall
opcode: secrets.delete
- kind: snippet
language: javascript
Expand All @@ -453,7 +453,7 @@
- kind: snippet
language: cel
code: 'has(self.params) ? self.params : null'
- kind: native
- kind: syscall
opcode: secrets.read
- kind: snippet
language: javascript
Expand All @@ -480,7 +480,7 @@
export default function ({ body, params }) {
return { ...body, ...params };
}
- kind: native
- kind: syscall
opcode: secrets.update
- kind: snippet
language: javascript
Expand All @@ -507,7 +507,7 @@
export default function ({ body, params }) {
return { ...body, ...params };
}
- kind: native
- kind: syscall
opcode: secrets.delete
- kind: snippet
language: javascript
Expand All @@ -527,7 +527,7 @@

- kind: signal
name: signal
opcode: secrets.watch
topic: secrets
ports:
out:
- name: session
Expand Down Expand Up @@ -572,7 +572,7 @@
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
- kind: syscall
opcode: charts.create
- kind: snippet
language: javascript
Expand All @@ -595,7 +595,7 @@
values?.map((value) => ({ [key]: value })) || []
);
}
- kind: native
- kind: syscall
opcode: charts.read
- kind: snippet
language: javascript
Expand All @@ -613,7 +613,7 @@
- kind: snippet
language: cel
code: 'has(self.body) ? self.body : null'
- kind: native
- kind: syscall
opcode: charts.update
- kind: snippet
language: javascript
Expand All @@ -636,7 +636,7 @@
values?.map((value) => ({ [key]: value })) || []
);
}
- kind: native
- kind: syscall
opcode: charts.delete
- kind: snippet
language: javascript
Expand All @@ -653,7 +653,7 @@
- kind: snippet
language: cel
code: 'has(self.params) ? self.params : null'
- kind: native
- kind: syscall
opcode: charts.read
- kind: snippet
language: javascript
Expand All @@ -680,7 +680,7 @@
export default function ({ body, params }) {
return { ...body, ...params };
}
- kind: native
- kind: syscall
opcode: charts.update
- kind: snippet
language: javascript
Expand All @@ -707,7 +707,7 @@
export default function ({ body, params }) {
return { ...body, ...params };
}
- kind: native
- kind: syscall
opcode: charts.delete
- kind: snippet
language: javascript
Expand All @@ -727,7 +727,7 @@

- kind: signal
name: signal
opcode: charts.watch
topic: charts
ports:
out:
- name: session
Expand Down
3 changes: 2 additions & 1 deletion ext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ Facilitates smooth execution of network-related tasks across various protocols.

Manages and optimizes system components.

- **[Native Node](./docs/native_node.md)**: Performs function calls within the system and returns results as packets.
- **[Signal Node](./docs/signal_node.md)**: Detects and responds to events occurring within the system.
- **[Syscall Node](./docs/syscall_node.md)**: Executes system-level function calls and delivers the results.
3 changes: 2 additions & 1 deletion ext/README_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@

시스템 구성 요소를 관리하고 최적화합니다.

- **[Native 노드](./docs/native_node_kr.md)**: 시스템 내부에서 함수 호출을 수행하고 결과를 패킷으로 반환합니다.
- **[Signal 노드](./docs/signal_node_kr.md)**: 시스템 내부에서 발생하는 이벤트를 감지하고 대응합니다.
- **[Syscall 노드](./docs/syscall_node_kr.md)**: 시스템 내부 함수 호출을 수행하여 결과를 제공합니다.
2 changes: 1 addition & 1 deletion ext/docs/signal_node.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ processing real-time events or system-level signals within the workflow.

```yaml
- kind: signal
opcode: specs.watch
opcode: specs
ports:
out:
- name: next
Expand Down
2 changes: 1 addition & 1 deletion ext/docs/signal_node_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

```yaml
- kind: signal
opcode: specs.watch
opcode: specs
ports:
out:
- name: next
Expand Down
7 changes: 4 additions & 3 deletions ext/docs/native_node.md → ext/docs/syscall_node.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Native Node
# Syscall Node

**The Native Node** performs function call operations within the system. This node processes system calls based on the `opcode`, passing input packets to the function for execution and returning the result.
**The Syscall Node** performs function call operations within the system. This node processes system calls based on the
`opcode`, passing input packets to the function for execution and returning the result.

## Specification

Expand All @@ -23,7 +24,7 @@
- name: specs_create
port: in

- kind: native
- kind: syscall
name: specs_create
opcode: specs.create
```
6 changes: 3 additions & 3 deletions ext/docs/native_node_kr.md → ext/docs/syscall_node_kr.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Native 노드
# Syscall 노드

**Native 노드**는 시스템 내부에서 함수 호출 작업을 수행하는 노드입니다. 이 노드는 `opcode`를 기반으로 시스템 호출을 처리하며, 입력 패킷을 함수에 전달하여 실행하고, 그 결과를 반환합니다.
**Syscall 노드**는 시스템 내부에서 함수 호출 작업을 수행하는 노드입니다. 이 노드는 `opcode`를 기반으로 시스템 호출을 처리하며, 입력 패킷을 함수에 전달하여 실행하고, 그 결과를 반환합니다.

## 명세

Expand All @@ -23,7 +23,7 @@
- name: specs_create
port: in

- kind: native
- kind: syscall
name: specs_create
opcode: specs.create
```
Loading

0 comments on commit 4ee58f0

Please sign in to comment.