create-bulkhead
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-bulkhead" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-321e83752aabf482f6f45d554441e6438ae51c210d6a7bf5668c5922f53e8299. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Generate a Bulkhead pattern implementation for PHP 8.4 that achieves resource isolation via semaphore-based concurrency limits and thread-pool isolation, and includes unit tests.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates Bulkhead pattern for PHP 8.4. Creates resource isolation with semaphore-based concurrency limiting and thread pool isolation. Includes unit tests.
- Audience
- | Scenario | Example | |----------|---------| | External API calls | Limit concurrent requests to payment gateway | | Database connections | Pool size limiting | | CPU-intensive work | Limit by CPU cores | | Multi-instance | Redis-based coordination |
- Testing
- Not tested
Browse files
Frontmatter
name: create-bulkhead
description: Generates Bulkhead pattern for PHP 8.4. Creates resource isolation with semaphore-based concurrency limiting and thread pool isolation. Includes unit tests.Bulkhead Pattern Generator
Creates Bulkhead pattern infrastructure for resource isolation and fault containment.
When to Use
| Scenario | Example |
|---|---|
| External API calls | Limit concurrent requests to payment gateway |
| Database connections | Pool size limiting |
| CPU-intensive work | Limit by CPU cores |
| Multi-instance | Redis-based coordination |
Component Characteristics
BulkheadInterface
- Common interface for all isolation strategies
- Acquire and release semantics
- Capacity monitoring
Strategies
- Semaphore Bulkhead: Limits concurrent executions
- Thread Pool Bulkhead: Isolates execution with dedicated pool
- Queue-based Bulkhead: Limits with waiting queue
BulkheadFullException
- Thrown when bulkhead capacity exhausted
- Contains bulkhead name and capacity info
Generation Process
Step 1: Generate Core Components
Path: src/Infrastructure/Resilience/Bulkhead/
BulkheadInterface.php— Common interfaceBulkheadConfig.php— Configuration value objectBulkheadFullException.php— Exception with capacity info
Step 2: Generate Bulkhead Implementation
Choose based on use case:
SemaphoreBulkhead.php— Local semaphore-based limitingDistributedSemaphoreBulkhead.php— Redis-based for multi-instance
Step 3: Generate Registry (Optional)
BulkheadRegistry.php— Manages multiple bulkheads
Step 4: Generate Tests
SemaphoreBulkheadTest.php— Bulkhead behavior testsBulkheadConfigTest.php— Configuration tests
File Placement
| Component | Path |
|---|---|
| All Classes | src/Infrastructure/Resilience/Bulkhead/ |
| Unit Tests | tests/Unit/Infrastructure/Resilience/Bulkhead/ |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Interface | BulkheadInterface |
BulkheadInterface |
| Semaphore | SemaphoreBulkhead |
SemaphoreBulkhead |
| Distributed | DistributedSemaphoreBulkhead |
DistributedSemaphoreBulkhead |
| Config | BulkheadConfig |
BulkheadConfig |
| Registry | BulkheadRegistry |
BulkheadRegistry |
| Exception | BulkheadFullException |
BulkheadFullException |
| Test | {ClassName}Test |
SemaphoreBulkheadTest |
Quick Template Reference
BulkheadInterface
interface BulkheadInterface
{
public function execute(callable $operation): mixed;
public function tryAcquire(): bool;
public function release(): void;
public function getAvailablePermits(): int;
public function getActiveCount(): int;
public function getName(): string;
}
BulkheadConfig
final readonly class BulkheadConfig
{
public function __construct(
public int $maxConcurrentCalls = 10,
public int $maxWaitDuration = 0,
public bool $fairness = true
) {}
public static function default(): self;
public static function forCpuBound(int $cpuCores): self;
public static function forIoBound(int $cpuCores): self;
public static function forExternalService(int $maxConnections): self;
}
Usage Example
// Create limiter
$bulkhead = new SemaphoreBulkhead(
name: 'payment-gateway',
config: BulkheadConfig::forExternalService(maxConnections: 20),
logger: $logger
);
// Execute with isolation
try {
$result = $bulkhead->execute(fn() => $client->charge($request));
} catch (BulkheadFullException $e) {
return Result::serviceOverloaded();
}
Use Case Selection
| Use Case | Bulkhead Type | Config |
|---|---|---|
| External API calls | Semaphore | Limited by API rate limits |
| Database connections | Semaphore | Limited by pool size |
| CPU-intensive work | Semaphore | Limited by CPU cores |
| Multi-instance | Distributed | Redis-based coordination |
| Mixed workloads | Registry | Per-service configuration |
Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|---|---|---|
| Global Bulkhead | Single point of contention | Per-service bulkheads |
| No Release | Permit leak | Always release in finally |
| Wrong Size | Too small = rejected, too large = no protection | Right-size per service |
| No Metrics | Can't monitor usage | Track acquired/rejected |
| Infinite Wait | Thread starvation | Set maxWaitDuration |
| No Fallback | Hard failure on full | Provide degraded response |
References
For complete PHP templates and examples, see:
references/templates.md— BulkheadInterface, Config, SemaphoreBulkhead, DistributedSemaphoreBulkhead, Registryreferences/examples.md— PaymentGatewayAdapter, ConnectionPool, OrderService examples and tests
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 PHP 8.4 的 Bulkhead 模式生成,解决资源隔离和故障隔离的实际问题
- 涵盖外部 API 调用、数据库连接、CPU 密集型任务等高频使用场景
- 包含完整的单元测试,提升代码可靠性
Highlights
- description 明确描述功能,触发词完整且边界清晰
- 详细列出使用场景和组件特性,便于用户理解适用性
Highlights
- 结构清晰,分步骤说明生成流程,包含命名规范、模板参考、使用示例
- frontmatter 完整,文档组织良好,易于理解和执行
Highlights
- 工具来源明确(PHP 8.4),参数说明清晰
- 涵盖主要异常处理(BulkheadFullException),有使用示例和测试说明
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.