Skip to content

Commit

Permalink
refactor: change name gateway to upgrader
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Jan 9, 2025
1 parent b1433c7 commit e3a8bae
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 39 deletions.
4 changes: 2 additions & 2 deletions examples/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
- kind: block
name: specs_watch
specs:
- kind: gateway
- kind: upgrader
name: websocket
protocol: websocket

Expand Down Expand Up @@ -477,7 +477,7 @@
- kind: block
name: values_watch
specs:
- kind: gateway
- kind: upgrader
name: websocket
protocol: websocket

Expand Down
8 changes: 4 additions & 4 deletions examples/wsproxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
port: out[0]
ports:
out[0]:
- name: gateway
- name: upgrader
port: io
- name: proxy
port: io

- kind: gateway
name: gateway
- kind: upgrader
name: upgrader
protocol: websocket
ports:
out:
Expand All @@ -45,5 +45,5 @@
url: wss://echo.websocket.org/
ports:
out:
- name: gateway
- name: upgrader
port: in
2 changes: 1 addition & 1 deletion ext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Facilitates smooth execution of network-related tasks across various protocols.

- **[HTTP Node](./docs/http_node.md)**: Processes HTTP requests and returns responses, suitable for web service communication.
- **[WebSocket Node](./docs/websocket_node.md)**: Establishes WebSocket connections and handles message sending and receiving.
- **[Gateway Node](./docs/gateway_node.md)**: Upgrades HTTP connections to WebSocket for real-time data communication.
- **[Upgrade Node](./docs/upgrade_node.md)**: Upgrades HTTP connections to WebSocket for real-time data communication.
- **[Listener Node](./docs/listener_node.md)**: Receives network requests on specified protocols and ports.
- **[Router Node](./docs/router_node.md)**: Routes input packets to multiple output ports based on conditions.

Expand Down
2 changes: 1 addition & 1 deletion ext/README_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

- **[HTTP 노드](./docs/http_node_kr.md)**: HTTP 요청을 처리하고 응답을 반환하여 웹 서비스와 통신합니다.
- **[WebSocket 노드](./docs/websocket_node_kr.md)**: WebSocket 연결을 설정하고 메시지를 송수신합니다.
- **[Gateway 노드](./docs/gateway_node_kr.md)**: HTTP 연결을 WebSocket으로 업그레이드하여 실시간 데이터 통신을 지원합니다.
- **[Upgrade 노드](./docs/upgrade_node_kr.md)**: HTTP 연결을 WebSocket으로 업그레이드하여 실시간 데이터 통신을 지원합니다.
- **[Listener 노드](./docs/listener_node_kr.md)**: 지정된 프로토콜과 포트에서 네트워크 요청을 수신합니다.
- **[Router 노드](./docs/router_node_kr.md)**: 입력 패킷을 조건에 따라 여러 출력 포트로 라우팅합니다.

Expand Down
13 changes: 7 additions & 6 deletions ext/docs/gateway_node.md → ext/docs/upgrader_node.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Gateway Node
# Upgrade Node

**The Gateway Node** provides the capability to upgrade network protocols to other protocols, primarily converting HTTP connections to WebSocket connections to support real-time data communication.
**The Upgrade Node** provides the capability to upgrade network protocols to other protocols, primarily converting HTTP
connections to WebSocket connections to support real-time data communication.

## Specification

Expand Down Expand Up @@ -47,13 +48,13 @@
port: out[0]
ports:
out[0]:
- name: gateway
- name: upgrader
port: io
- name: proxy
port: io

- kind: gateway
name: gateway
- kind: upgrader
name: upgrader
protocol: websocket
ports:
out:
Expand All @@ -65,6 +66,6 @@
url: wss://echo.websocket.org/
ports:
out:
- name: gateway
- name: upgrader
port: in
```
12 changes: 6 additions & 6 deletions ext/docs/gateway_node_kr.md → ext/docs/upgrader_node_kr.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gateway 노드
# Upgrade 노드

**Gateway 노드**는 네트워크 프로토콜을 다른 프로토콜로 업그레이드하는 기능을 제공하며, 주로 HTTP 연결을 WebSocket 연결로 변환하여 실시간 데이터 통신을 지원합니다.
**Upgrade 노드**는 네트워크 프로토콜을 다른 프로토콜로 업그레이드하는 기능을 제공하며, 주로 HTTP 연결을 WebSocket 연결로 변환하여 실시간 데이터 통신을 지원합니다.

## 명세

Expand Down Expand Up @@ -47,13 +47,13 @@
port: out[0]
ports:
out[0]:
- name: gateway
- name: upgrader
port: io
- name: proxy
port: io

- kind: gateway
name: gateway
- kind: upgrader
name: upgrader
protocol: websocket
ports:
out:
Expand All @@ -65,6 +65,6 @@
url: wss://echo.websocket.org/
ports:
out:
- name: gateway
- name: upgrader
port: in
```
8 changes: 4 additions & 4 deletions ext/docs/websocket_node.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
port: out[0]
ports:
out[0]:
- name: gateway
- name: upgrader
port: io
- name: proxy
port: io

- kind: gateway
name: gateway
- kind: upgrader
name: upgrader
protocol: websocket
ports:
out:
Expand All @@ -59,6 +59,6 @@
url: wss://echo.websocket.org/
ports:
out:
- name: gateway
- name: upgrader
port: in
```
8 changes: 4 additions & 4 deletions ext/docs/websocket_node_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
port: out[0]
ports:
out[0]:
- name: gateway
- name: upgrader
port: io
- name: proxy
port: io

- kind: gateway
name: gateway
- kind: upgrader
name: upgrader
protocol: websocket
ports:
out:
Expand All @@ -59,6 +59,6 @@
url: wss://echo.websocket.org/
ports:
out:
- name: gateway
- name: upgrader
port: in
```
2 changes: 1 addition & 1 deletion ext/pkg/network/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func AddToScheme() scheme.Register {
{KindListener, NewListenNodeCodec(), &ListenNodeSpec{}},
{KindRouter, NewRouteNodeCodec(), &RouteNodeSpec{}},
{KindWebSocket, NewWebSocketNodeCodec(), &WebSocketNodeSpec{}},
{KindGateway, NewGatewayNodeCodec(), &GatewayNodeSpec{}},
{KindUpgrader, NewUpgradeNodeCodec(), &UpgradeNodeSpec{}},
}

for _, def := range definitions {
Expand Down
2 changes: 1 addition & 1 deletion ext/pkg/network/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestAddToScheme(t *testing.T) {
err := AddToScheme().AddToScheme(s)
assert.NoError(t, err)

tests := []string{KindHTTP, KindListener, KindRouter, KindWebSocket, KindGateway}
tests := []string{KindHTTP, KindListener, KindRouter, KindWebSocket, KindUpgrader}

for _, tt := range tests {
t.Run(tt, func(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions ext/pkg/network/gateway.go → ext/pkg/network/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/siyul-park/uniflow/pkg/types"
)

// GatewayNodeSpec defines the specifications for creating a GatewayNode.
type GatewayNodeSpec struct {
// UpgradeNodeSpec defines the specifications for creating a UpgradeNode.
type UpgradeNodeSpec struct {
spec.Meta `map:",inline"`
Protocol string `map:"protocol" validate:"required"`
Timeout time.Duration `map:"timeout,omitempty"`
Expand All @@ -32,13 +32,13 @@ type WebSocketUpgradeNode struct {
mu sync.RWMutex
}

const KindGateway = "gateway"
const KindUpgrader = "upgrader"

var _ node.Node = (*WebSocketUpgradeNode)(nil)

// NewGatewayNodeCodec creates a new codec for GatewayNodeSpec.
func NewGatewayNodeCodec() scheme.Codec {
return scheme.CodecWithType(func(spec *GatewayNodeSpec) (node.Node, error) {
// NewUpgradeNodeCodec creates a new codec for UpgradeNodeSpec.
func NewUpgradeNodeCodec() scheme.Codec {
return scheme.CodecWithType(func(spec *UpgradeNodeSpec) (node.Node, error) {
switch spec.Protocol {
case ProtocolWebsocket:
n := NewWebSocketUpgradeNode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"github.com/stretchr/testify/assert"
)

func TestGatewayNodeCodec_Compile(t *testing.T) {
codec := NewGatewayNodeCodec()
func TestUpgradeNodeCodec_Compile(t *testing.T) {
codec := NewUpgradeNodeCodec()

spec := &GatewayNodeSpec{
spec := &UpgradeNodeSpec{
Protocol: ProtocolWebsocket,
Timeout: time.Second,
Buffer: 64,
Expand Down

0 comments on commit e3a8bae

Please sign in to comment.