@codesoul-co/hypha-memory / provider-operational-health
模块用法
用于把外部或本地 Provider 绑定到 Hypha Port。Provider operational health 模块公开 1 类、4 接口、2 类型。
从包入口导入
ts
import {
MemoryOperationalHealthService,
} from '@codesoul-co/hypha-memory';
import type {
MemoryOperationalHealth,
ProviderOperationalProbe,
ProviderOperationalSnapshot,
ProviderRuntimeMetrics,
LivenessStatus,
OperationalStatus,
} from '@codesoul-co/hypha-memory';使用要点
- 6 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用
import type,运行时不应依赖它们。 - 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
公共导出
| Symbol | 种类 | 签名 | 说明 |
|---|---|---|---|
MemoryOperationalHealthService | 类 | new MemoryOperationalHealthService(probes: ProviderOperationalProbe[], now?: () => string): MemoryOperationalHealthService | Memory Operational Health Service 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。 |
MemoryOperationalHealth | 接口 | interface MemoryOperationalHealth | Memory Operational Health 接口,共包含 4 个公开字段或方法。 |
ProviderOperationalProbe | 接口 | interface ProviderOperationalProbe | Provider Operational Probe 接口,共包含 4 个公开字段或方法。 |
ProviderOperationalSnapshot | 接口 | interface ProviderOperationalSnapshot | Provider Operational Snapshot 接口,共包含 4 个公开字段或方法。 |
ProviderRuntimeMetrics | 接口 | interface ProviderRuntimeMetrics | Provider Runtime Metrics 接口,共包含 11 个公开字段或方法。 |
LivenessStatus | 类型 | type LivenessStatus = 'alive' | 'stalled' | Liveness Status 公共类型别名;完整类型表达式见声明。 |
OperationalStatus | 类型 | type OperationalStatus = 'ready' | 'degraded' | 'not_ready' | Operational Status 公共类型别名;完整类型表达式见声明。 |
MemoryOperationalHealthService
Memory Operational Health Service 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。
- 种类: 类
- 导入:
import { MemoryOperationalHealthService } from '@codesoul-co/hypha-memory'; - 源码模块:
provider-operational-health
声明
text
export declare class MemoryOperationalHealthService {
constructor(probes: ProviderOperationalProbe[], now?: () => string);
snapshot(signal?: AbortSignal): Promise<MemoryOperationalHealth>;
}公开成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
constructor | 构造函数 | (probes: ProviderOperationalProbe[], now?: () => string): MemoryOperationalHealthService | 创建该类的实例。 |
snapshot | 方法 | snapshot(signal?: AbortSignal): Promise<MemoryOperationalHealth> | 公开方法;参数与返回类型以签名列为准。 |
MemoryOperationalHealth
Memory Operational Health 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { MemoryOperationalHealth } from '@codesoul-co/hypha-memory'; - 源码模块:
provider-operational-health
声明
text
export interface MemoryOperationalHealth {
readiness: {
status: OperationalStatus;
reasons: string[];
};
liveness: {
status: LivenessStatus;
reasons: string[];
};
providers: ProviderOperationalSnapshot[];
checkedAt: string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
checkedAt | 属性 | checkedAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
liveness | 属性 | liveness: { status: LivenessStatus; reasons: string[]; } | 公开属性;类型、只读和可选状态以签名列为准。 |
providers | 属性 | providers: ProviderOperationalSnapshot[] | 公开属性;类型、只读和可选状态以签名列为准。 |
readiness | 属性 | readiness: { status: OperationalStatus; reasons: string[]; } | 公开属性;类型、只读和可选状态以签名列为准。 |
ProviderOperationalProbe
Provider Operational Probe 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ProviderOperationalProbe } from '@codesoul-co/hypha-memory'; - 源码模块:
provider-operational-health
声明
text
export interface ProviderOperationalProbe {
readonly providerId: string;
readonly required: boolean;
health(signal?: AbortSignal): Promise<ProviderHealth>;
metrics(): Promise<ProviderRuntimeMetrics>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
health | 方法 | health(signal?: AbortSignal): Promise<ProviderHealth> | 公开方法;参数与返回类型以签名列为准。 |
metrics | 方法 | metrics(): Promise<ProviderRuntimeMetrics> | 公开方法;参数与返回类型以签名列为准。 |
providerId | 属性 | readonly providerId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
required | 属性 | readonly required: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
ProviderOperationalSnapshot
Provider Operational Snapshot 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ProviderOperationalSnapshot } from '@codesoul-co/hypha-memory'; - 源码模块:
provider-operational-health
声明
text
export interface ProviderOperationalSnapshot {
providerId: string;
health: ProviderHealth;
metrics: ProviderRuntimeMetrics;
required: boolean;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
health | 属性 | health: ProviderHealth | 公开属性;类型、只读和可选状态以签名列为准。 |
metrics | 属性 | metrics: ProviderRuntimeMetrics | 公开属性;类型、只读和可选状态以签名列为准。 |
providerId | 属性 | providerId: string | 公开属性;类型、只读和可选状态以签名列为准。 |
required | 属性 | required: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
ProviderRuntimeMetrics
Provider Runtime Metrics 接口,共包含 11 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ProviderRuntimeMetrics } from '@codesoul-co/hypha-memory'; - 源码模块:
provider-operational-health
声明
text
export interface ProviderRuntimeMetrics {
poolActive?: number;
poolIdle?: number;
poolLimit?: number;
queueDepth?: number;
queueOldestAgeMs?: number;
retryAttempts?: number;
retryBudgetRemaining?: number;
circuitState?: 'closed' | 'open' | 'half_open';
rateLimitRemaining?: number;
quarantinedOperations?: number;
deadLetterCount?: number;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
circuitState | 属性 | circuitState?: "closed" | "open" | "half_open" | 公开属性;类型、只读和可选状态以签名列为准。 |
deadLetterCount | 属性 | deadLetterCount?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
poolActive | 属性 | poolActive?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
poolIdle | 属性 | poolIdle?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
poolLimit | 属性 | poolLimit?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
quarantinedOperations | 属性 | quarantinedOperations?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
queueDepth | 属性 | queueDepth?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
queueOldestAgeMs | 属性 | queueOldestAgeMs?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
rateLimitRemaining | 属性 | rateLimitRemaining?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
retryAttempts | 属性 | retryAttempts?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
retryBudgetRemaining | 属性 | retryBudgetRemaining?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
LivenessStatus
Liveness Status 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { LivenessStatus } from '@codesoul-co/hypha-memory'; - 源码模块:
provider-operational-health
声明
text
export type LivenessStatus = 'alive' | 'stalled';OperationalStatus
Operational Status 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { OperationalStatus } from '@codesoul-co/hypha-memory'; - 源码模块:
provider-operational-health
声明
text
export type OperationalStatus = 'ready' | 'degraded' | 'not_ready';