コンテンツにスキップ

エントリ種別リファレンス

Wippyで利用可能なすべてのエントリ種別の完全なリファレンス。

エントリはnamespace:name形式で相互参照します。レジストリはこれらの参照に基づいて依存関係を自動的に接続し、リソースが正しい順序で初期化されることを保証します。

種別説明
function.luaLua関数エントリポイント
process.lua長時間実行Luaプロセス
workflow.luaTemporalワークフロー(決定論的)
library.lua共有Luaライブラリ
module.luaLuaモジュールインターフェース
function.lua.bcプリコンパイル済み関数バイトコード
library.lua.bcプリコンパイル済みライブラリバイトコード
process.lua.bcプリコンパイル済みプロセスバイトコード
workflow.lua.bcプリコンパイル済みワークフローバイトコード
- name: handler
kind: function.lua
source: file://handler.lua
method: main
modules:
- http
- json
imports:
utils: app.lib:helpers # 別のエントリをモジュールとしてインポート
importsを使用して他のLuaエントリを参照します。コード内でrequire("alias_name")を通じて利用可能になります。
種別説明
http.serviceHTTPサーバー(ポートをバインド)
http.routerルートプレフィックスとミドルウェア
http.endpointHTTPエンドポイント(メソッド + パス)
http.static静的ファイル配信
# HTTPサーバー
- name: gateway
kind: http.service
addr: ":8080"
lifecycle:
auto_start: true
# ミドルウェア付きルーター
- name: api
kind: http.router
meta:
server: gateway
prefix: /api
middleware:
- cors
- rate_limit
# エンドポイント
- name: users_list
kind: http.endpoint
meta:
router: app:api
method: GET
path: /users
func: list_handler

Lua API: HTTPモジュールを参照

local http = require("http")
local req = http.request()
local resp = http.response()
resp:status(200):json({users = get_users()})
種別説明
db.sql.sqliteSQLiteデータベース
db.sql.postgresPostgreSQLデータベース
db.sql.mysqlMySQLデータベース
- name: database
kind: db.sql.sqlite
file: "./data/app.db"
lifecycle:
auto_start: true
# テスト用インメモリ
- name: testdb
kind: db.sql.sqlite
file: ":memory:"
- name: database
kind: db.sql.postgres
host: localhost
port: 5432
database: dbname
username: user
password: pass
options:
sslmode: disable
pool:
max_open: 25
max_idle: 5
max_lifetime: "30m"
lifecycle:
auto_start: true
- name: database
kind: db.sql.mysql
host: localhost
port: 3306
database: dbname
username: user
password: pass
options:
parseTime: "true"
lifecycle:
auto_start: true

*_env サフィックスのバリアント、TLSオプション、接続プールの調整についてはDatabaseを参照してください。

Lua API: SQLモジュールを参照

local sql = require("sql")
local db, err = sql.get("app:database")
local rows, err = db:query("SELECT * FROM users WHERE id = ?", user_id)
db:execute("INSERT INTO logs (msg) VALUES (?)", message)
種別説明
store.memoryインメモリキーバリューストア
store.sqlSQLバックエンドキーバリューストア
store.kv.raftクラスタレプリケート、強整合性 KV(共有 Raft)
store.kv.crdtクラスタレプリケート、最終的整合性 KV(ゴシップ/CRDT)
# メモリストア
- name: cache
kind: store.memory
lifecycle:
auto_start: true
# SQLバックエンドストア
- name: persistent_store
kind: store.sql
database: app:database
table: kv_store
lifecycle:
auto_start: true
# クラスタレプリケートストア(クラスタリングが必要)
- name: deployments
kind: store.kv.raft
namespace: deploy

store.kv.* 種別はクラスタリングが有効である必要があります。整合性のトレードオフについてはストアを参照。

Lua API: ストアモジュールを参照

local store = require("store")
local s, err = store.get("app:cache")
s:set("user:123", user_data, 3600) -- TTL(秒)
local data = s:get("user:123")
種別説明
queue.driver.memoryインメモリキュードライバ
queue.driver.amqpAMQP (RabbitMQ) ドライバ
queue.driver.sqsAWS SQS ドライバ
queue.queueキュー宣言
queue.consumerキューコンシューマ
# ドライバ
- name: queue_driver
kind: queue.driver.memory
lifecycle:
auto_start: true
# キュー
- name: jobs
kind: queue.queue
driver: queue_driver
# コンシューマ
- name: job_consumer
kind: queue.consumer
queue: app:jobs
func: job_handler
concurrency: 4
prefetch: 10
lifecycle:
auto_start: true

Lua API: キューモジュールを参照

local queue = require("queue")
-- メッセージを公開
queue.publish("app:jobs", {task = "process", id = 123})
-- コンシューマハンドラ内で現在のメッセージにアクセス
local msg = queue.message()
local data = msg:body_json()
コンシューマのfuncは各メッセージに対して呼び出されます。ハンドラ内でqueue.message()を使用して現在のメッセージにアクセスします。
種別説明
process.hostプロセス実行ホスト
process.service監督されたプロセス(process.luaをラップ)
terminal.hostターミナル/CLIホスト
# プロセスホスト(プロセスが実行される場所)
- name: processes
kind: process.host
host:
workers: 32 # ワーカーgoroutine(デフォルト: NumCPU)
queue_size: 1024 # グローバルキュー容量
local_queue_size: 256 # ワーカーごとのキュー
lifecycle:
auto_start: true
# プロセス定義
- name: worker_process
kind: process.lua
source: file://worker.lua
method: main
# 監督されたプロセスサービス
- name: worker
kind: process.service
process: app:worker_process
host: app:processes
input: ["arg1", "arg2"]
lifecycle:
auto_start: true
restart:
max_attempts: 10
- name: terminal
kind: terminal.host
lifecycle:
auto_start: true
プロセスを自動再起動付きの監督されたサービスとして実行する必要がある場合はprocess.serviceを使用します。processフィールドはprocess.luaエントリを参照します。
種別説明
temporal.clientTemporalクライアント接続
temporal.workerTemporalワーカー
- name: temporal_client
kind: temporal.client
address: "localhost:7233"
namespace: "default"
auth:
type: none # none, api_key, mtls
lifecycle:
auto_start: true
- name: temporal_worker
kind: temporal.worker
client: temporal_client
task_queue: "main-queue"
lifecycle:
auto_start: true
種別説明
config.awsAWS設定
cloudstorage.s3S3バケットアクセス
- name: aws
kind: config.aws
region: "us-east-1"
access_key_id_env: "AWS_ACCESS_KEY_ID"
secret_access_key_env: "AWS_SECRET_ACCESS_KEY"
- name: uploads
kind: cloudstorage.s3
config: app:aws
bucket: "my-uploads"
endpoint: "" # オプション、S3互換サービス用

Lua API: クラウドストレージモジュールを参照

local cloudstorage = require("cloudstorage")
local storage, err = cloudstorage.get("app:uploads")
storage:upload_object("files/doc.pdf", file_content)
local url = storage:presigned_get_url("files/doc.pdf", {expires = "1h"})
MinIOやDigitalOcean SpacesなどのS3互換サービスに接続するにはendpointを使用します。
種別説明
fs.directoryディレクトリアクセス
fs.embed読み取り専用組み込みファイルシステム
- name: data_dir
kind: fs.directory
directory: "./data"
auto_init: true # 存在しない場合は作成
mode: "0755" # パーミッション

Lua API: ファイルシステムモジュールを参照

local fs = require("fs")
local filesystem, err = fs.get("app:data_dir")
local file = filesystem:open("output.txt", "w")
file:write("Hello, World!")
file:close()
種別説明
env.storage.memoryインメモリ環境変数ストレージ
env.storage.fileファイルベース環境変数ストレージ
env.storage.osOS環境変数
env.storage.static読み取り専用の静的キーバリューストレージ
env.storage.router環境変数ルーター(複数ストレージ)
env.variable環境変数
- name: os_env
kind: env.storage.os
- name: file_env
kind: env.storage.file
file_path: ".env"
auto_create: true
- name: defaults
kind: env.storage.static
values:
PUBLIC_API_HOST: "https://api.example.com"
APP_ENV: "production"
- name: app_env
kind: env.storage.router
storages:
- app:os_env
- app:file_env
- app:defaults

Lua API: Envモジュールを参照

local env = require("env")
local api_key = env.get("API_KEY")
env.set("CACHE_TTL", "3600")
ルーターはストレージを順番に試行します。読み取りは最初のマッチが勝ちます。書き込みは最初の書き込み可能なストレージに送られます。
種別説明
template.jet個別のJetテンプレート
template.setテンプレートセット設定
# エンジン設定付きテンプレートセット
- name: templates
kind: template.set
engine:
development_mode: false
extensions:
- ".jet"
- ".html.jet"
# 個別テンプレート
- name: email_template
kind: template.jet
source: file://templates/email.jet
set: app:templates

Lua API: テンプレートモジュールを参照

local templates = require("templates")
local set, err = templates.get("app:templates")
local html = set:render("email", {
user = "Alice",
message = "Welcome!"
})
種別説明
security.policy条件付きセキュリティポリシー
security.policy.expr式ベースのポリシー
security.token_storeトークンストレージ
# 条件ベースのポリシー
- name: admin_policy
kind: security.policy
policy:
actions: "*"
resources: "*"
effect: allow
conditions:
- field: "actor.meta.role"
operator: eq
value: "admin"
# 式ベースのポリシー
- name: owner_policy
kind: security.policy.expr
policy:
actions: "*"
resources: "*"
effect: allow
expression: 'actor.id == meta.owner_id || actor.meta.role == "admin"'

Lua API: セキュリティモジュールを参照

local security = require("security")
-- アクション前に権限をチェック
if security.can("delete", "users", {user_id = id}) then
delete_user(id)
end
-- 現在のアクターを取得
local actor = security.actor()
ポリシーは順番に評価されます。最初にマッチしたポリシーがアクセスを決定します。より具体的なポリシーを一般的なポリシーの前に配置してください。
種別説明
contract.definitionメソッド仕様を持つインターフェース
contract.bindingコントラクトメソッドを関数実装にマップ
# コントラクトインターフェースを定義
- name: greeter
kind: contract.definition
methods:
- name: greet
description: 挨拶メッセージを返す
- name: greet_with_name
description: パーソナライズされた挨拶を返す
input_schemas:
- format: "application/schema+json"
definition: {"type": "string"}
output_schemas:
- format: "application/schema+json"
definition: {"type": "string"}
# 実装関数
- name: greeter_greet
kind: function.lua
source: file://greeter_greet.lua
method: main
- name: greeter_greet_name
kind: function.lua
source: file://greeter_greet_name.lua
method: main
# コントラクトメソッドを実装にバインド
- name: greeter_impl
kind: contract.binding
contracts:
- contract: app:greeter
default: true
methods:
greet: app:greeter_greet
greet_with_name: app:greeter_greet_name

Luaからの使用:

local contract = require("contract")
-- IDでバインディングを開く
local greeter, err = contract.open("app:greeter_impl")
-- メソッドを呼び出す
local result = greeter:greet()
local personalized = greeter:greet_with_name("Alice")
-- インスタンスがコントラクトを実装しているかチェック
local is_greeter = contract.is(greeter, "app:greeter")

Lua API: コントラクトモジュールを参照

1つのバインディングをdefault: trueとしてマークすると、バインディングIDを指定せずにコントラクトを開くときに使用されます(context_requiredフィールドが設定されていない場合のみ動作)。
種別説明
exec.nativeネイティブコマンド実行
exec.dockerDockerコンテナ実行
- name: native_exec
kind: exec.native
default_work_dir: "/app"
command_whitelist:
- "ls"
- "cat"
- name: docker_exec
kind: exec.docker
image: "python:3.11-slim"
default_work_dir: "/workspace"
auto_remove: true
memory_limit: 536870912 # 512MB
command_whitelist:
- "python"
種別説明
function.watWebAssembly関数(WATテキスト形式)
function.wasmWebAssembly関数(バイナリ)
process.wasmWebAssemblyプロセス
- name: sum
kind: function.wasm
source: file://sum.wasm
transport: payload # または wasi-http

WASM概要を参照。

種別説明
networkベースネットワークオーバーレイ
network.socks5SOCKS5プロキシオーバーレイ
network.i2pI2Pネットワークオーバーレイ
network.tailscaleTailscaleオーバーレイ

http.service からは network: 経由で、funcs/process からは network オプション経由で、http_client からは overlay_network オプション経由で参照されます。ネットワークを参照。

種別説明
registry.entryエントリ記述子(内部)
ns.definition名前空間定義
ns.requirement名前空間要件宣言
ns.dependency名前空間依存関係

これらはレジストリローダーが_index.yamlのフロントマターと依存関係宣言から生成します。通常、作者が直接定義することはありません — version:namespace:、依存ブロックが解決された結果として現れます。

ほとんどのエントリはライフサイクル設定をサポートします:

- name: service
kind: some.kind
lifecycle:
auto_start: true # 自動起動
start_timeout: 10s # 最大起動時間
stop_timeout: 10s # 最大シャットダウン時間
stable_threshold: 5s # 安定とみなす時間
depends_on:
- app:database
restart: # リトライポリシー
initial_delay: 1s
max_delay: 90s
backoff_factor: 2.0
max_attempts: 0 # 0 = 無限
エントリが正しい順序で起動することを保証するにはdepends_onを使用します。スーパーバイザは依存先のエントリを起動する前に、依存関係が安定するのを待ちます。

エントリはnamespace:name形式で参照されます:

# 定義
namespace: app.users
entries:
- name: handler
kind: function.lua
# 別のエントリからの参照
func: app.users:handler

エントリの上書き {id=“overriding-entries”}

Section titled “エントリの上書き {id=“overriding-entries”}”

任意のエントリのフィールド(その kind を含む)は、ソース YAML を編集することなく、override: 設定セクションまたは -o CLI フラグを使って起動時に上書きできます。キーは namespace:entry:path 形式を使用します。

override:
app:gateway:addr: ":9090" # data field (a bare path targets data.*)
app:worker:meta.priority: high # meta field
app:db:kind: db.sql.postgres # the entry's typed kind
app:db:data.kind: custom # a payload field literally named "kind"
パス対象
kindエントリの型付き kind(空でない文字列である必要があります)
data.<field> または素の <field>エントリの data ペイロード内のフィールド
meta.<field>エントリのメタデータ内のフィールド

同じ上書きを CLI からも適用できます。

Terminal window
wippy run -o app:db:kind=db.sql.postgres -o app:gateway:addr=:9090

CLI(-o)の値は形状に応じて型変換されます(true/false は bool、数値は数値、それ以外は文字列)。override: セクションの値は YAML の型を保持します。エントリではなくグローバルな設定セクションを上書きするには、--set を使用します。