Skip to content

jisung-02/aether

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

86 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

✨ Aether

English Documentation πŸ‡ΊπŸ‡Έ


Gleam 기반 μ„œλ²„ ν”„λ ˆμž„μ›Œν¬

AetherλŠ” Gleam으둜 μž‘μ„±λœ μ„œλ²„ ν”„λ ˆμž„μ›Œν¬μ΄μž ν•™μŠ΅μš© λ„€νŠΈμ›Œν‚Ή μŠ€νƒμž…λ‹ˆλ‹€. μ €μˆ˜μ€€ TCP/UDP μ†ŒμΌ“ λž˜νΌλΆ€ν„° HTTP/1.x νŒŒμ„œ/λΉŒλ”, HTTP/2 ν”„λ ˆμ΄λ°κ³Ό HPACK, νŒŒμ΄ν”„λΌμΈ μ‘°ν•©, λΌμš°ν„°, JSON 직렬화와 content negotiationκΉŒμ§€ ν•œ μ €μž₯μ†Œ μ•ˆμ—μ„œ λ‹€λ£Ήλ‹ˆλ‹€.

ν˜„μž¬ μ½”λ“œλ² μ΄μŠ€λŠ” λ‹€μŒ 두 μΆ•μœΌλ‘œ κ΅¬μ„±λ©λ‹ˆλ‹€.

  • ν”„λ ˆμž„μ›Œν¬ λͺ¨λ“ˆ: src/aether/**
  • μ‹€ν–‰ μ˜ˆμ œμ™€ 톡합 μ§„μž…μ : src/aether/examples/**, src/aether.gleam

이 ν”„λ‘œμ νŠΈλŠ” κ²½ν¬λŒ€ν•™κ΅ 컴퓨터곡학과 ν’€μŠ€νƒ μ„œλΉ„μŠ€ λ„€νŠΈμ›Œν‚Ή μˆ˜μ—… 과제둜 μ œμž‘λ˜μ—ˆμŠ΅λ‹ˆλ‹€.


🌟 핡심 κΈ°λŠ₯

  • νƒ€μž… μ•ˆμ „ν•œ μš”μ²­/응닡 μ²˜λ¦¬μ™€ Result 기반 였λ₯˜ λͺ¨λΈ
  • TCP/UDP μ†ŒμΌ“ 좔상화, μ˜΅μ…˜ ꡬ성, μ—λŸ¬ λ§€ν•‘, μ—°κ²° 관리
  • HTTP/1.x μš”μ²­ νŒŒμ‹±, 응닡 생성, URL 인코딩/λ””μ½”λ”©, νŒŒμ΄ν”„λΌμΈ μŠ€ν…Œμ΄μ§€
  • HTTP/2 ν”„λ ˆμž„ νŒŒμ‹±/생성, HPACK, 슀트림 관리, 흐름 μ œμ–΄
  • ν”„λ‘œν† μ½œ λ ˆμ§€μŠ€νŠΈλ¦¬, 검증기, νŒŒμ΄ν”„λΌμΈ λΉŒλ”
  • νŒ¨ν„΄ λ§€μΉ­ λΌμš°ν„°, 라우트 κ·Έλ£Ή, path/query νŒŒλΌλ―Έν„° 처리
  • JSON 직렬화와 Accept 헀더 기반 content negotiation
  • ν•˜λ‚˜μ˜ ν¬νŠΈμ—μ„œ HTTP/1.1 + h2c λ˜λŠ” TLS + ALPN(h2, http/1.1) 예제 μ„œλ²„

πŸ“Š ν˜„μž¬ μ½”λ“œλ² μ΄μŠ€ μŠ€λƒ…μƒ·

ν•­λͺ© κ°’
src/aether Gleam λͺ¨λ“ˆ 70개
src 전체 파일 74개
test 파일 53개
src μ½”λ“œ 라인 29,555
test μ½”λ“œ 라인 18,813
둜컬 검증 κ²°κ³Ό gleam test 1308 passing

μœ„ μˆ˜μΉ˜λŠ” ν˜„μž¬ μ €μž₯μ†Œ 트리λ₯Ό κΈ°μ€€μœΌλ‘œ κ³„μ‚°ν–ˆμŠ΅λ‹ˆλ‹€.


πŸ›οΈ μ•„ν‚€ν…μ²˜ κ°œμš”

Network

  • tcp, udp, socket, transport
  • connection, connection_manager, connection_supervisor
  • connection_config, socket_options, socket_error

Protocol

  • HTTP/1.x: request/response model, parser, builder, stage, URL utilities
  • HTTP/2: frame layer, connection state, stream management, flow control
  • HPACK: encoder, decoder, table, huffman, integer, string
  • TCP ν•™μŠ΅μš© ν”„λ‘œν† μ½œ 계측: header, parser, builder, checksum, state, stage, mode
  • ν”„λ‘œν† μ½œ μ‘°ν•©: protocol, registry, validator, pipeline_builder

Application

  • pipeline/*둜 μ‘°ν•© κ°€λŠ₯ν•œ 처리 단계 ꡬ성
  • router/*둜 path pattern, route group, params 기반 λΌμš°νŒ…
  • serialization/json, serialization/negotiation으둜 응닡 직렬화와 ν˜‘μƒ 처리

Examples

  • src/aether.gleam: HTTP/1.x / HTTP/2 데λͺ¨ μ‹€ν–‰
  • src/aether/examples/server_main.gleam: λ©€ν‹°ν”„λ‘œν† μ½œ CRUD μ„œλ²„
  • src/aether/examples/http1/*: HTTP/1.x CRUD λΌμš°ν„°μ™€ ν•Έλ“€λŸ¬
  • src/aether/examples/http2/*: HTTP/2 ν”„λ ˆμž„ 레벨 CRUD 예제
  • src/aether/examples/multiprotocol/*: h2c / TLS ALPN λŸ°νƒ€μž„ ꡬ성과 μ„œλ²„ 바인딩

πŸ“¦ λͺ¨λ“ˆ ꡬ쑰

Entry Points

  • src/aether.gleam
  • src/aether/examples/server_main.gleam

Core

  • src/aether/core/data.gleam
  • src/aether/core/message.gleam

Examples

  • src/aether/examples/common/store.gleam
  • src/aether/examples/common/user.gleam
  • src/aether/examples/http1/handlers.gleam
  • src/aether/examples/http1/http2_handlers.gleam
  • src/aether/examples/http1/server.gleam
  • src/aether/examples/http2/handlers.gleam
  • src/aether/examples/http2/server.gleam
  • src/aether/examples/multiprotocol/runtime.gleam
  • src/aether/examples/multiprotocol/server.gleam

Network

  • src/aether/network/connection.gleam
  • src/aether/network/connection_config.gleam
  • src/aether/network/connection_manager.gleam
  • src/aether/network/connection_supervisor.gleam
  • src/aether/network/socket.gleam
  • src/aether/network/socket_error.gleam
  • src/aether/network/socket_options.gleam
  • src/aether/network/tcp.gleam
  • src/aether/network/transport.gleam
  • src/aether/network/udp.gleam

Pipeline

  • src/aether/pipeline/compose.gleam
  • src/aether/pipeline/error.gleam
  • src/aether/pipeline/executor.gleam
  • src/aether/pipeline/pipeline.gleam
  • src/aether/pipeline/stage.gleam

Protocol Common

  • src/aether/protocol/pipeline_builder.gleam
  • src/aether/protocol/protocol.gleam
  • src/aether/protocol/registry.gleam
  • src/aether/protocol/validator.gleam

Protocol HTTP

  • src/aether/protocol/http/builder.gleam
  • src/aether/protocol/http/parser.gleam
  • src/aether/protocol/http/request.gleam
  • src/aether/protocol/http/response.gleam
  • src/aether/protocol/http/stage.gleam
  • src/aether/protocol/http/unified.gleam
  • src/aether/protocol/http/url.gleam

Protocol HTTP/2

  • src/aether/protocol/http2/connection.gleam
  • src/aether/protocol/http2/error.gleam
  • src/aether/protocol/http2/flow_control.gleam
  • src/aether/protocol/http2/frame.gleam
  • src/aether/protocol/http2/frame_builder.gleam
  • src/aether/protocol/http2/frame_parser.gleam
  • src/aether/protocol/http2/preface.gleam
  • src/aether/protocol/http2/stage.gleam
  • src/aether/protocol/http2/stream.gleam
  • src/aether/protocol/http2/stream_manager.gleam

Protocol HPACK

  • src/aether/protocol/http2/hpack/decoder.gleam
  • src/aether/protocol/http2/hpack/encoder.gleam
  • src/aether/protocol/http2/hpack/huffman.gleam
  • src/aether/protocol/http2/hpack/integer.gleam
  • src/aether/protocol/http2/hpack/string.gleam
  • src/aether/protocol/http2/hpack/table.gleam

Protocol TCP

  • src/aether/protocol/tcp/builder.gleam
  • src/aether/protocol/tcp/checksum.gleam
  • src/aether/protocol/tcp/connection.gleam
  • src/aether/protocol/tcp/header.gleam
  • src/aether/protocol/tcp/mode.gleam
  • src/aether/protocol/tcp/parser.gleam
  • src/aether/protocol/tcp/stage.gleam
  • src/aether/protocol/tcp/state.gleam

Router

  • src/aether/router/group.gleam
  • src/aether/router/params.gleam
  • src/aether/router/pattern.gleam
  • src/aether/router/router.gleam

Serialization

  • src/aether/serialization/json.gleam
  • src/aether/serialization/negotiation.gleam

Utilities

  • src/aether/util/benchmark.gleam
  • src/aether/util/time.gleam

Erlang FFI

  • src/aether_examples_runtime_ffi.erl
  • src/aether_tcp_ffi.erl
  • src/aether_udp_ffi.erl

πŸ› οΈ 기술 μŠ€νƒ

μ»΄ν¬λ„ŒνŠΈ νŒ¨ν‚€μ§€ 버전 λ²”μœ„ μ—­ν• 
ν‘œμ€€ 라이브러리 gleam_stdlib >= 0.44.0 and < 2.0.0 κΈ°λ³Έ μžλ£Œκ΅¬μ‘°μ™€ μœ ν‹Έλ¦¬ν‹°
Erlang 연동 gleam_erlang >= 1.0.0 and < 2.0.0 BEAM/OTP 연동
HTTP νƒ€μž… gleam_http >= 4.0.0 and < 5.0.0 HTTP λ©”μ„œλ“œ/νƒ€μž…
JSON gleam_json >= 2.0.0 and < 4.0.0 JSON 처리
OTP gleam_otp >= 1.0.0 and < 2.0.0 μ•‘ν„°/μŠˆνΌλ°”μ΄μ € νŒ¨ν„΄
μ €μˆ˜μ€€ λ„€νŠΈμ›Œν‚Ή glisten >= 8.0.1 and < 9.0.0 μ†ŒμΌ“κ³Ό λ¦¬μŠ€λ„ˆ
HTTP μ„œλ²„ mist >= 5.0.0 and < 6.0.0 HTTP μ„œλ²„ 톡합
ν…ŒμŠ€νŠΈ gleeunit >= 1.8.0 and < 2.0.0 ν…ŒμŠ€νŠΈ λŸ¬λ„ˆ

πŸš€ μ‹œμž‘ν•˜κΈ°

사전 μš”κ΅¬μ‚¬ν•­

  • Gleam >= 1.11.0
  • Erlang/OTP >= 26
  • Git

μ„€μΉ˜

git clone https://github.com/jisung-02/aether.git
cd aether
gleam build

자주 μ“°λŠ” λͺ…λ Ή

# 전체 λΉŒλ“œ
gleam build

# 데λͺ¨ μ‹€ν–‰ (src/aether.gleam)
gleam run

# λ©€ν‹°ν”„λ‘œν† μ½œ CRUD μ„œλ²„ μ‹€ν–‰
gleam run -m aether/examples/server_main

# ν…ŒμŠ€νŠΈ
gleam test

# 포맷 검사
gleam format --check src test

🌐 λ©€ν‹°ν”„λ‘œν† μ½œ μ„œλ²„ μ‹€ν–‰

src/aether/examples/server_main.gleam은 ν•˜λ‚˜μ˜ λ¦¬μŠ€λ„ˆμ—μ„œ μ•„λž˜ 두 λͺ¨λ“œλ₯Ό μ§€μ›ν•©λ‹ˆλ‹€.

  • κΈ°λ³Έ λͺ¨λ“œ: HTTP/1.1 + h2c
  • TLS λͺ¨λ“œ: HTTP/1.1 + HTTP/2 with ALPN

ν™˜κ²½ λ³€μˆ˜

λ³€μˆ˜ μ„€λͺ… κΈ°λ³Έκ°’
AETHER_PORT μ„œλ²„ 포트 3000(κΈ°λ³Έ), TLS μ‚¬μš© μ‹œ 3443
AETHER_TLS_CERT TLS μΈμ¦μ„œ 경둜 λ―Έμ„€μ •
AETHER_TLS_KEY TLS κ°œμΈν‚€ 경둜 λ―Έμ„€μ •

AETHER_TLS_CERT와 AETHER_TLS_KEYλŠ” λ‘˜ λ‹€ μžˆμ–΄μ•Ό TLS λͺ¨λ“œκ°€ ν™œμ„±ν™”λ©λ‹ˆλ‹€.

Cleartext HTTP/1.1 + h2c

gleam run -m aether/examples/server_main

curl http://localhost:3000/api/users
curl --http2-prior-knowledge http://localhost:3000/api/users

TLS + ALPN

AETHER_TLS_CERT=./cert.pem \
AETHER_TLS_KEY=./key.pem \
gleam run -m aether/examples/server_main

curl -k --http1.1 https://localhost:3443/api/users
curl -k --http2 https://localhost:3443/api/users

예제 μ—”λ“œν¬μΈνŠΈ

  • GET /api/users
  • GET /api/users/:id
  • POST /api/users
  • PUT /api/users/:id
  • DELETE /api/users/:id
  • GET /api/http2/users
  • GET /api/http2/users/:id
  • POST /api/http2/users
  • PUT /api/http2/users/:id
  • DELETE /api/http2/users/:id

🧩 λΌμš°ν„° 예제

μ•„λž˜ μ˜ˆμ œλŠ” ν˜„μž¬ λΌμš°ν„° API에 λ§žλŠ” μ΅œμ†Œ κ΅¬μ„±μž…λ‹ˆλ‹€.

import aether/core/data.{type Data}
import aether/protocol/http/request
import aether/protocol/http/response
import aether/router/params
import aether/router/router

fn health(
  _req: request.ParsedRequest,
  _params: params.Params,
  _data: Data,
) -> Result(response.HttpResponse, router.RouteError) {
  Ok(response.text_response(200, "ok"))
}

pub fn app() -> router.Router {
  router.new()
  |> router.get("/health", health)
}

Path/query νŒŒλΌλ―Έν„°λŠ” aether/router/paramsμ—μ„œ μ½μŠ΅λ‹ˆλ‹€.

case params.get_int(route_params, "id") {
  Some(id) -> // use id
  None -> // invalid or missing
}

μ‹€μ œ μ„œλ²„μ™€ Mist 톡합 μ˜ˆμ‹œλŠ” src/aether/examples/server_main.gleam을 μ°Έκ³ ν•˜λ©΄ λ©λ‹ˆλ‹€.


πŸš€ HTTP/2 ν”„λ ˆμž„ 처리 예제

ν˜„μž¬ HTTP/2 μ—°κ²° APIλŠ” μ•„λž˜ νλ¦„μœΌλ‘œ μ‚¬μš©ν•©λ‹ˆλ‹€.

import aether/protocol/http2/connection

pub fn handle_request(incoming_frame) {
  let conn = connection.new_server()

  case connection.handle_frame(conn, incoming_frame) {
    connection.RequestComplete(conn, stream_id, headers, body) -> {
      let #(conn, response_frames) = connection.build_response(
        conn,
        stream_id,
        200,
        [#("content-type", "application/json")],
        body,
      )

      // send response_frames
    }
    connection.SendFrames(conn, frames) -> {
      // send control frames
    }
    connection.HandleOk(conn) -> {
      // state updated, nothing to send
    }
    connection.HandleError(conn, error) -> {
      // connection-level error handling
    }
  }
}

πŸ“‹ ν˜„μž¬ κ΅¬ν˜„ μƒνƒœ

ν•­λͺ© μƒνƒœ λΉ„κ³ 
TCP/UDP μ†ŒμΌ“ 계측 βœ… κ΅¬ν˜„ λ‹¨μœ„/톡합 ν…ŒμŠ€νŠΈ 포함
μ—°κ²° 관리 βœ… κ΅¬ν˜„ manager/supervisor 포함
HTTP/1.x νŒŒμ‹±/λΉŒλ”© βœ… κ΅¬ν˜„ parser, builder, stage 제곡
HTTP/2 ν”„λ ˆμ΄λ° βœ… κ΅¬ν˜„ frame/frame_parser/frame_builder
HPACK βœ… κ΅¬ν˜„ encoder/decoder/table/huffman 포함
슀트림 관리/흐름 μ œμ–΄ βœ… κ΅¬ν˜„ stream_manager, flow_control
h2c + TLS/ALPN 예제 μ„œλ²„ βœ… κ΅¬ν˜„ examples/multiprotocol/*
λΌμš°ν„° βœ… κ΅¬ν˜„ route group, params, mount 지원
JSON 직렬화 βœ… κ΅¬ν˜„ serialization/json
Content negotiation βœ… κ΅¬ν˜„ serialization/negotiation
graceful shutdown timeout ⚠️ λΆ€λΆ„ κ΅¬ν˜„ connection_manager에 placeholder 쑴재
benchmark μΈ‘μ • 정확도 ⚠️ λΆ€λΆ„ κ΅¬ν˜„ util/benchmark에 TODO 쑴재
WebSocket ❌ λ―Έκ΅¬ν˜„ README μ°¨μ›μ—μ„œ 별도 제곡 μ—†μŒ
HTTP/2 Server Push ❌ λ―Έκ΅¬ν˜„ README μ°¨μ›μ—μ„œ 별도 제곡 μ—†μŒ

πŸ§ͺ 개발 및 검증

GitHub ActionsλŠ” μ•„λž˜ λͺ…령을 κΈ°μ€€μœΌλ‘œ κ²€μ¦ν•©λ‹ˆλ‹€.

gleam test
gleam format --check src test

ν˜„μž¬ μ›Œν¬ν”Œλ‘œμš° κΈ°μ€€ CI 버전은 Gleam 1.12.0, Erlang/OTP 27.1.2μž…λ‹ˆλ‹€.

μ†ŒμΌ“ 톡합 ν…ŒμŠ€νŠΈκ°€ ν¬ν•¨λ˜μ–΄ μžˆμœΌλ―€λ‘œ, μ‹€ν–‰ ν™˜κ²½μ— 따라 λ„€νŠΈμ›Œν¬ κΆŒν•œμ΄ ν•„μš”ν•  수 μžˆμŠ΅λ‹ˆλ‹€.


🀝 κΈ°μ—¬ν•˜κΈ°

κΈ°μ—¬ μ „ ꢌμž₯ 절차:

gleam format
gleam test

PR ν…œν”Œλ¦Ώμ€ .github/pull_request_template.mdλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.


πŸ“„ λΌμ΄μ„ μŠ€

MIT License

About

A Gleam-based server framework focused on explicitness and independence between layers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors