Skip to content

@codesoul-co/hypha-core / modules/sandbox-provider/registry

模块用法

用于把外部或本地 Provider 绑定到 Hypha Port。Registry 模块公开 1 类、1 接口。

从包入口导入

ts
import {
  SandboxProviderRegistry,
} from '@codesoul-co/hypha-core';

import type {
  SandboxProviderRegistration,
} from '@codesoul-co/hypha-core';

使用要点

  • 1 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。

公共导出

Symbol种类签名说明
SandboxProviderRegistrynew SandboxProviderRegistry(): SandboxProviderRegistryProvider-neutral DI registry. It selects only from explicit Environment fields and never imports a concrete adapter into core.
SandboxProviderRegistration接口interface SandboxProviderRegistrationSandbox Provider Registration 接口,共包含 2 个公开字段或方法。

SandboxProviderRegistry

Provider-neutral DI registry. It selects only from explicit Environment fields and never imports a concrete adapter into core.

声明

text
export declare class SandboxProviderRegistry {
    register(factory: SandboxProviderFactory): void;
    unregister(providerType: SandboxProviderType, providerId: string): boolean;
    list(providerType?: SandboxProviderType): SandboxProviderRegistration[];
    resolve(selection: SandboxProviderSelection): SandboxProviderFactory;
    create(selection: SandboxProviderSelection): Promise<SandboxProvider>;
}

公开成员

成员种类签名说明
constructor构造函数(): SandboxProviderRegistry创建该类的实例。
create方法create(selection: SandboxProviderSelection): Promise<SandboxProvider>公开方法;参数与返回类型以签名列为准。
list方法list(providerType?: SandboxProviderType): SandboxProviderRegistration[]公开方法;参数与返回类型以签名列为准。
register方法register(factory: SandboxProviderFactory): void公开方法;参数与返回类型以签名列为准。
resolve方法resolve(selection: SandboxProviderSelection): SandboxProviderFactory公开方法;参数与返回类型以签名列为准。
unregister方法unregister(providerType: SandboxProviderType, providerId: string): boolean公开方法;参数与返回类型以签名列为准。

SandboxProviderRegistration

Sandbox Provider Registration 接口,共包含 2 个公开字段或方法。

声明

text
export interface SandboxProviderRegistration {
    providerType: SandboxProviderType;
    providerId: string;
}

契约成员

成员种类签名说明
providerId属性providerId: string公开属性;类型、只读和可选状态以签名列为准。
providerType属性providerType: "mock" | "local_process" | "docker" | "remote_sandbox" | "custom"公开属性;类型、只读和可选状态以签名列为准。