create-object-pool

Generate an object-pool pattern implementation for PHP 8.4. Creates a reusable container for expensive resources such as connections to improve reuse and reduce creation overhead. Includes unit tests.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

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-object-pool" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-450e95a0aec7c6117fda248cddb2ec7e918ac9fe277c1061586d05a1ae9155d4. 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 an object-pool pattern implementation for PHP 8.4. Creates a reusable container for expensive resources such as connections to improve reuse and reduce creation overhead. Includes unit tests.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates Object Pool pattern for PHP 8.4. Creates reusable object containers for expensive resources like connections. Includes unit tests.
Audience
| Scenario | Example | |----------|---------| | Expensive creation | Database connections | | Limited resources | HTTP client handles | | Connection reuse | Socket connections | | Memory management | Large object caching |
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: create-object-pool
description: Generates Object Pool pattern for PHP 8.4. Creates reusable object containers for expensive resources like connections. Includes unit tests.

Object Pool Pattern Generator

Creates Object Pool pattern infrastructure for managing reusable expensive objects.

When to Use

Scenario Example
Expensive creation Database connections
Limited resources HTTP client handles
Connection reuse Socket connections
Memory management Large object caching

Component Characteristics

PoolInterface

  • Acquire/release semantics
  • Pool lifecycle management
  • Capacity configuration

Pool Implementation

  • Manages available objects
  • Creates on demand
  • Recycles returned objects

Poolable Objects

  • Resettable state
  • Validate before reuse
  • Track usage metrics

Generation Process

Step 1: Generate Core Pool Components

Path: src/Infrastructure/Pool/

  1. PoolInterface.php — Generic pool contract with acquire/release
  2. PoolConfig.php — Configuration value object (min/max size, timeouts)
  3. PoolableInterface.php — Contract for poolable objects (reset, isValid, close)
  4. ObjectPool.php — Generic pool implementation
  5. PooledObject.php — Wrapper tracking usage metrics
  6. PoolExhaustedException.php — Exception for exhausted pool
  7. InvalidPoolObjectException.php — Exception for invalid objects

Step 2: Generate Specialized Pool (if needed)

Path: src/Infrastructure/{Domain}/

  1. {Type}Pool.php — Specialized pool (ConnectionPool, HttpClientPool)
  2. Poolable{Type}.php — Poolable implementation for specific resource

Step 3: Generate Tests

Path: tests/Unit/Infrastructure/Pool/

  1. ObjectPoolTest.php — Core pool functionality tests
  2. {Type}PoolTest.php — Specialized pool tests

File Placement

Component Path
Pool Interface src/Infrastructure/Pool/
Pool Implementation src/Infrastructure/Pool/
Specialized Pools src/Infrastructure/{Domain}/
Unit Tests tests/Unit/Infrastructure/Pool/

Naming Conventions

Component Pattern Example
Interface PoolInterface PoolInterface
Implementation ObjectPool ObjectPool
Poolable Interface PoolableInterface PoolableInterface
Config PoolConfig PoolConfig
Wrapper PooledObject PooledObject
Specialized Pool {Type}Pool ConnectionPool
Test {ClassName}Test ObjectPoolTest

Quick Template Reference

PoolInterface

/**
 * @template T
 */
interface PoolInterface
{
    /** @return T */
    public function acquire(): mixed;
    /** @param T $object */
    public function release(mixed $object): void;
    public function getAvailableCount(): int;
    public function getActiveCount(): int;
    public function getMaxSize(): int;
    public function clear(): void;
}

PoolableInterface

interface PoolableInterface
{
    public function reset(): void;
    public function isValid(): bool;
    public function close(): void;
}

PoolConfig

final readonly class PoolConfig
{
    public function __construct(
        public int $minSize = 0,
        public int $maxSize = 10,
        public int $maxWaitTimeMs = 5000,
        public int $idleTimeoutSeconds = 300,
        public bool $validateOnAcquire = true,
        public bool $validateOnRelease = false
    );

    public static function default(): self;
    public static function forDatabase(): self;
    public static function forHttpClients(): self;
}

Usage Example

// Create pool
$pool = new ObjectPool(
    name: 'database',
    factory: fn() => $connectionFactory->create(),
    config: PoolConfig::forDatabase(),
    logger: $logger
);

// Acquire and release
$connection = $pool->acquire();
try {
    $result = $connection->query('SELECT ...');
} finally {
    $pool->release($connection);
}

// Or use helper
$result = $connectionPool->execute(fn($conn) => $conn->query('SELECT ...'));

Anti-patterns to Avoid

Anti-pattern Problem Solution
No Validation Returning broken objects Validate on acquire
No Reset State leaks between uses Call reset() on release
No Timeout Infinite wait Set maxWaitTime
Unbounded Pool Memory exhaustion Set maxSize
Not Releasing Pool exhaustion Use try/finally
Wrong Scope Per-request pools Use singleton/shared pool

References

For complete PHP templates and examples, see:

  • references/templates.md — All component templates
  • references/examples.md — ConnectionPool, HttpClientPool examples and tests

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供完整的 PHP 8.4 对象池模式生成方案,包含接口、实现、配置、异常处理和单元测试
  • 适用于数据库连接、HTTP 客户端等昂贵资源管理,具有明确的实用价值和广泛适用性
Trigger Precision95/100

Highlights

  • description 明确描述了功能目标和核心用途,触发词精准完整,边界清晰
Structure and Standards95/100

Highlights

  • 文档结构清晰完整,包含使用场景、组件特性、生成步骤、文件布局、命名规范、模板参考、使用示例和反模式等多个维度
  • 步骤划分明确,有端到端示例,frontmatter 完整规范
Execution Reliability85/100

Areas to improve

  • 缺少具体执行入口 Reported severity: Minor

    文档提供了完整的代码模板和生成路径,但未明确说明如何实际执行生成(缺少具体命令或入口点)

    Recommendation: 建议补充具体的执行命令或入口点说明,如 CLI 命令、API 调用方式等

Highlights

  • 提供了完整的 PoolConfig 参数配置,覆盖主要异常情况处理
  • 包含使用示例和最佳实践指导,确保正确使用
Evidence Verifiability (mean of the first four)90/100

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.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

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.