Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions diagnostic/build-283afced.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"generated_at": "2026-06-25T14:52:37.556186+00:00",
"commit": "283afced",
"diagnostic_logd": "diagnostic/build-283afced.logd",
"diagnostic_logd_error": null,
"message_blocker": null,
"chunked": false,
"chunk_size_bytes": null,
"password": "8ec9fd7fdd710eb6db5f",
"decrypt_command": "encryptly unpack diagnostic/build-283afced.logd <outdir> --password 8ec9fd7fdd710eb6db5f",
"total_modules": 1,
"passed": 1,
"failed": 0,
"modules": [
{
"name": "market",
"status": "PASS",
"elapsed_seconds": 0.764,
"artifact": "/root/.openclaw/workspace/bounties/TentOfTrials/market/market",
"output": ""
}
],
"pr_note": "Include the encrypted diagnostic logd artifact(s): diagnostic/build-283afced.logd. The encrypted .logd is the required diagnostic content for PR review; this JSON file is metadata. Maintainers may ask you to remove these diagnostic artifacts before merging."
}
Binary file added diagnostic/build-283afced.logd
Binary file not shown.
31 changes: 31 additions & 0 deletions docs/OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,37 @@ The health check returns a 200 OK response with a JSON body:
}
```

Market gateway readiness can be checked before routing traffic to the
service:

```bash
curl -i http://localhost:8080/health/ready
```

When the gateway is ready, the endpoint returns `200 OK`:

```json
{
"status": "ready"
}
```

When the gateway is shutting down or otherwise marked unhealthy, the endpoint
returns `503 Service Unavailable`:

```json
{
"status": "not ready"
}
```

Local and CI checks can validate the behavior without external credentials:

```bash
cd market
go test ./gateway -run TestReadinessEndpoint
```

### Prometheus Metrics

Each service exposes Prometheus metrics at `/metrics` on the same port as the
Expand Down
57 changes: 57 additions & 0 deletions market/gateway/api_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package gateway

import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
)

func TestReadinessEndpointReturnsReady(t *testing.T) {
gateway := NewGateway(DefaultGatewayConfig())
server := httptest.NewServer(gateway.buildHandler())
defer server.Close()

resp, err := http.Get(server.URL + "/health/ready")
if err != nil {
t.Fatalf("GET /health/ready: %v", err)
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
t.Fatalf("status = %d, want %d", resp.StatusCode, http.StatusOK)
}

var body map[string]string
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
t.Fatalf("decode response body: %v", err)
}
if body["status"] != "ready" {
t.Fatalf("status body = %q, want %q", body["status"], "ready")
}
}

func TestReadinessEndpointReturnsNotReadyWhenGatewayUnhealthy(t *testing.T) {
gateway := NewGateway(DefaultGatewayConfig())
gateway.health.Store(false)
server := httptest.NewServer(gateway.buildHandler())
defer server.Close()

resp, err := http.Get(server.URL + "/health/ready")
if err != nil {
t.Fatalf("GET /health/ready: %v", err)
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusServiceUnavailable {
t.Fatalf("status = %d, want %d", resp.StatusCode, http.StatusServiceUnavailable)
}

var body map[string]string
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
t.Fatalf("decode response body: %v", err)
}
if body["status"] != "not ready" {
t.Fatalf("status body = %q, want %q", body["status"], "not ready")
}
}