Download the PHP package flytachi/winter-cpool without Composer

On this page you can find all versions of the php package flytachi/winter-cpool. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package winter-cpool

Winter CPool

Latest Version on Packagist PHP Version Require

๐Ÿ“– Documentation ยท Quick start ยท API reference

A connection pool that knows nothing about connections.

The pool handles borrowing, returning, capacity, lifetime and liveness; what is being pooled is supplied by an adapter of three methods. A database adapter opens a PDO and probes with SELECT 1; a Redis adapter opens a \Redis and probes with PING. The pool cannot tell them apart, and that is the point.

Built for long-running PHP: under Swoole it hands a separate connection to every coroutine, and everywhere else it degrades to a single shared connection โ€” the correct answer when a process serves one request at a time.


Installation

Requires PHP 8.4+. ext-swoole is optional: with it you get real pooling, without it the same code keeps working through SingleConnection.


The adapter

Everything driver-specific lives here โ€” three methods, nothing else:

validate() must not throw for "dead" โ€” return false. A thrown probe is treated as dead too, so a sloppy adapter still cannot corrupt the pool.


Borrow and return

borrow() gives back a PoolEntry; the connection itself is $entry->resource. Returning is the caller's job, so finally is the shape to use โ€” or wrap it in a facade that returns automatically at the end of a request (which is what the Winter framework does with a coroutine defer).

When every connection is busy and the pool is at its ceiling, borrow() waits. Past connectionTimeout it throws PoolException::exhausted() rather than opening connection number 10 001 โ€” an exhausted pool is a queue, not an outage of the database.

Outside a coroutine

Without an active Swoole runtime there is nothing to pool: a process serves one unit of work at a time. SingleConnection is the same contract with that assumption baked in.

It still honours maxLifetime and re-validates a connection that has been sitting idle, so a long-lived CLI worker does not wake up holding a socket the server closed hours ago.


Policy

Every knob has a default; pass only what you mean to change.

Option Default What it does
maximumPoolSize 10 Ceiling on open connections. Beyond it, borrowers queue
connectionTimeout 15.0 How long a borrower waits before exhausted()
maxLifetime 1800.0 A connection older than this is retired on return
maxLifetimeJitter 0.1 Spreads expiry so a pool does not recycle all at once
aliveBypassWindow 0.5 Skip the liveness probe for a connection used this recently
housekeepingInterval 30.0 How often the background sweep runs
keepaliveTime 0.0 Ping idle connections this often (0 โ€” off)
idleTimeout 0.0 Close connections idle longer than this (0 โ€” off)
minimumIdle 0 Keep at least this many warm

Housekeeping only runs under Swoole, and only when something enables it โ€” a pool with the defaults costs no timer.


What you get from it


Fork safety

A fork() copies file descriptors. A child that closes an inherited socket tears down the connection its parent is still using โ€” so after forking, a child calls abandon(), not close():

Both clear the housekeeping timer, and that part is not optional: a Timer::tick callback holds a reference to the pool, so a pool merely dereferenced would stay alive and keep maintaining connections nobody uses.


Observability

active climbing to maximum while borrowers wait is the signal to raise the ceiling โ€” or to find the code path that borrows without returning.


Documentation

The user-facing documentation lives at winterframe.net/packages/cpool (the link picks your language; RU and EN are both complete).

Start here

Page What it answers
Introduction Why a pool exists, and what this one deliberately does not do
Installation Requirements, and what changes with and without ext-swoole
Quick start Adapter, pool, borrow and release โ€” a working example

Guides

Page What it answers
Writing an adapter The three methods, what validate() should probe, what an adapter must never do

Reference

Page What it answers
API reference Every type, method and exception
Policy Each knob, what it changes and how to pick a value

Contributing

Internal technical notes โ€” the connection state machine, what each policy knob changes, and the reasoning behind decisions that are not obvious from the code โ€” live in docs/. Read those before changing how a connection is borrowed or retired.


License

MIT License. See LICENSE.


All versions of winter-cpool with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package flytachi/winter-cpool contains the following files

Loading the files please wait ...