refactor(client): simplify local service lifecycle
This commit is contained in:
@@ -1,34 +1,16 @@
|
||||
import { Effect, Schema } from "effect"
|
||||
import { Schema } from "effect"
|
||||
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
|
||||
|
||||
export namespace ServiceStatus {
|
||||
export const State = Schema.Union([
|
||||
Schema.Struct({ type: Schema.Literal("starting") }),
|
||||
Schema.Struct({ type: Schema.Literal("ready") }),
|
||||
Schema.Struct({
|
||||
type: Schema.Literal("stopping"),
|
||||
targetVersion: Schema.String.pipe(Schema.optional),
|
||||
}),
|
||||
Schema.Struct({
|
||||
type: Schema.Literal("failed"),
|
||||
message: Schema.String,
|
||||
action: Schema.String,
|
||||
}),
|
||||
]).annotate({ identifier: "ServiceStatus" })
|
||||
export type State = typeof State.Type
|
||||
|
||||
export const Health = Schema.Struct({
|
||||
healthy: Schema.Literal(true),
|
||||
version: Schema.String,
|
||||
pid: Schema.Int.check(Schema.isGreaterThan(0)),
|
||||
instanceID: Schema.String.pipe(Schema.optional),
|
||||
status: State.pipe(Schema.withDecodingDefaultKey(Effect.succeed({ type: "ready" as const }))),
|
||||
}).annotate({ identifier: "ServiceHealth" })
|
||||
export type Health = typeof Health.Type
|
||||
|
||||
export const StopRequest = Schema.Struct({
|
||||
instanceID: Schema.String,
|
||||
targetVersion: Schema.String.pipe(Schema.optional),
|
||||
}).annotate({ identifier: "ServiceStopRequest" })
|
||||
export type StopRequest = typeof StopRequest.Type
|
||||
|
||||
|
||||
Reference in New Issue
Block a user