mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-14 17:40:44 +08:00
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
63 lines
2 KiB
TypeScript
63 lines
2 KiB
TypeScript
import { defineSchema, defineTable } from "convex/server";
|
|
import { v } from "convex/values";
|
|
|
|
const actorRole = v.union(v.literal("ci"), v.literal("maintainer"));
|
|
const credentialStatus = v.union(v.literal("active"), v.literal("disabled"));
|
|
const leaseEventType = v.union(
|
|
v.literal("acquire"),
|
|
v.literal("acquire_failed"),
|
|
v.literal("release"),
|
|
);
|
|
const adminEventType = v.union(v.literal("add"), v.literal("disable"), v.literal("disable_failed"));
|
|
|
|
export default defineSchema({
|
|
credential_sets: defineTable({
|
|
kind: v.string(),
|
|
status: credentialStatus,
|
|
payload: v.any(),
|
|
createdAtMs: v.number(),
|
|
updatedAtMs: v.number(),
|
|
lastLeasedAtMs: v.number(),
|
|
note: v.optional(v.string()),
|
|
lease: v.optional(
|
|
v.object({
|
|
ownerId: v.string(),
|
|
actorRole,
|
|
leaseToken: v.string(),
|
|
acquiredAtMs: v.number(),
|
|
heartbeatAtMs: v.number(),
|
|
expiresAtMs: v.number(),
|
|
}),
|
|
),
|
|
})
|
|
.index("by_kind_status", ["kind", "status"])
|
|
.index("by_kind_lastLeasedAtMs", ["kind", "lastLeasedAtMs"]),
|
|
|
|
lease_events: defineTable({
|
|
kind: v.string(),
|
|
eventType: leaseEventType,
|
|
actorRole,
|
|
ownerId: v.string(),
|
|
occurredAtMs: v.number(),
|
|
credentialId: v.optional(v.id("credential_sets")),
|
|
code: v.optional(v.string()),
|
|
message: v.optional(v.string()),
|
|
})
|
|
.index("by_occurredAtMs", ["occurredAtMs"])
|
|
.index("by_kind_occurredAtMs", ["kind", "occurredAtMs"])
|
|
.index("by_credential_occurredAtMs", ["credentialId", "occurredAtMs"]),
|
|
|
|
admin_events: defineTable({
|
|
eventType: adminEventType,
|
|
actorRole,
|
|
actorId: v.string(),
|
|
occurredAtMs: v.number(),
|
|
credentialId: v.optional(v.id("credential_sets")),
|
|
kind: v.optional(v.string()),
|
|
code: v.optional(v.string()),
|
|
message: v.optional(v.string()),
|
|
})
|
|
.index("by_occurredAtMs", ["occurredAtMs"])
|
|
.index("by_kind_occurredAtMs", ["kind", "occurredAtMs"])
|
|
.index("by_credential_occurredAtMs", ["credentialId", "occurredAtMs"]),
|
|
});
|