feat: add durable business task outbox example and fault recovery

This commit is contained in:
2026-09-17 23:13:48 +08:00
parent 2b8213a4f7
commit 522fe2ef3e
27 changed files with 2195 additions and 7 deletions

View File

@@ -83,6 +83,14 @@ export ORBIT_TEST_RECEIVER_DSN="root:$TASK_DB_PASSWORD@tcp(127.0.0.1:$TASK_DB_PO
(cd examples/result-inbox && GOWORK=off ORBIT_RECEIVER_DSN="$ORBIT_TEST_RECEIVER_DSN" ORBIT_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_CREDENTIALS_FILE="$TASK_TEST_DIR/worker.credentials.json" "$TASK_GO" run ./cmd/receiver demo)
# 发送方业务表独立建库;示例不向核心SDK加入数据库依赖。
ORBIT_MYSQL_DSN="$ORBIT_TEST_MYSQL_DSN" "$TASK_TEST_DIR/orbit-admin" bootstrap --application sdk-sender --namespace default --environment test --queue outbox --output "$TASK_TEST_DIR/sender.credentials.json"
"$TASK_DOCKER" exec "$TASK_TEST_NAME" sh -c 'MYSQL_PWD="$MYSQL_ROOT_PASSWORD" mysql -uroot --protocol=tcp -e "CREATE DATABASE orbit_sender_test CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_bin"'
export ORBIT_TEST_SENDER_DSN="root:$TASK_DB_PASSWORD@tcp(127.0.0.1:$TASK_DB_PORT)/orbit_sender_test"
(cd examples/task-outbox && GOWORK=off ORBIT_SENDER_DSN="$ORBIT_TEST_SENDER_DSN" "$TASK_GO" run ./cmd/sender init)
(cd examples/task-outbox && GOWORK=off ORBIT_TEST_SENDER_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_TEST_SENDER_CREDENTIALS_FILE="$TASK_TEST_DIR/sender.credentials.json" "$TASK_GO" test -race -count=1 -run Integration -v ./...)
(cd examples/task-outbox && GOWORK=off ORBIT_SENDER_DSN="$ORBIT_TEST_SENDER_DSN" ORBIT_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_CREDENTIALS_FILE="$TASK_TEST_DIR/sender.credentials.json" "$TASK_GO" run ./cmd/sender demo)
# 应用配额场景使用独立应用与两个命名空间,普通 Worker 凭据不扩权。
ORBIT_MYSQL_DSN="$ORBIT_TEST_MYSQL_DSN" "$TASK_TEST_DIR/orbit-admin" bootstrap --application sdk-app-resources --namespace first --environment test --queue first --resource-access --output "$TASK_TEST_DIR/app.credentials.json"
TASK_APP_ID=$(sed -n 's/.*"application_id":"\([^"]*\)".*/\1/p' "$TASK_TEST_DIR/app.credentials.json")