一键导入
horse-multi-instance
Guidelines for instantiating and configuring independent Horse server instances (THorseInstance) running concurrently on different ports.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guidelines for instantiating and configuring independent Horse server instances (THorseInstance) running concurrently on different ports.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guidelines and workflows for developing and maintaining regular expressions and optional parameter routing features in the Horse framework.
Guidelines for registering, executing, and optimizing native high-precision telemetry hooks (AddOnTelemetry) in the Horse Web Framework.
Guide for setting up thread-safe database connection pooling (FireDAC / UniDAC) in multithreaded Horse applications.
Guide for managing request-scoped contextual services and IoC (dependency injection) in Delphi and Lazarus.
Guide to using standard Horse middlewares (CORS, Jhonson, compression, basic-auth, logger) and pipeline registration order.
Guidelines for setting up endpoints, defining path parameters, route wildcards, and structuring HTTP controllers.
| name | horse-multi-instance |
| description | Guidelines for instantiating and configuring independent Horse server instances (THorseInstance) running concurrently on different ports. |
Use THorseInstance when your application needs to expose multiple separate HTTP interfaces (e.g., a public REST API on port 8080 and an admin/telemetry dashboard on port 9090) within the same process.
Each THorseInstance allocates its own isolated:
onRequest, preParsing, preValidation, onSend, onResponse)Always create and configure THorseInstance explicitly, registering endpoints and middlewares directly on the instance:
var
FPublicApi: THorseInstance;
FAdminPanel: THorseInstance;
begin
// 1. Public API configuration
FPublicApi := THorseInstance.Create;
FPublicApi.Use(Jhonson); // Middleware registered only for FPublicApi
FPublicApi.Get('/api/v1/ping', DoPingHandler);
// 2. Admin Panel configuration
FAdminPanel := THorseInstance.Create;
FAdminPanel.Get('/admin/metrics', DoMetricsHandler);
end;
Since listeners enter blocking execution loops (depending on the provider and application shape), you must start the physical socket listening in separate threads:
// Start Instance 1 in a background thread
TThread.CreateAnonymousThread(
procedure
begin
FPublicApi.Listen(9001);
end).Start;
// Start Instance 2 in a background thread
TThread.CreateAnonymousThread(
procedure
begin
FAdminPanel.Listen(9002);
end).Start;
When shutting down, stop listening on each instance before freeing the objects:
FPublicApi.StopListen;
FAdminPanel.StopListen;
FPublicApi.Free;
FAdminPanel.Free;
THorseInstance relies on instance-specific configuration or request-scoped services (Req.Services).THorse facade class. It is automatically routed to a default instance under the hood.procedure begin end) for route handlers. Use standard global procedures instead.