The anypool Reference Manual
Table of Contents
The anypool Reference Manual
This is the anypool Reference Manual, version 0.1.0,
generated automatically by Declt version 3.0 "Montgomery Scott"
on Tue Dec 22 11:41:15 2020 GMT+0.
1 Introduction
anypool

General-purpose connection pooling library.
WARNING
This software is still ALPHA quality. The APIs will be likely to change.
Usage
(ql:quickload '(:anypool :dbi))
(use-package :anypool)
(defvar *connection-pool*
(make-pool :name "dbi-connections"
:connector (lambda ()
(dbi:connect :postgres
:database-name "webapp"
:username "fukamachi" :password "1ove1isp"))
:disconnector #'dbi:disconnect
:ping #'dbi:ping
:max-open-count 10
:max-idle-count 2))
(fetch *connection-pool*)
;=> #<DBD.POSTGRES:DBD-POSTGRES-CONNECTION {10054E07C3}>
(pool-open-count *connection-pool*)
;=> 1
(pool-idle-count *connection-pool*)
;=> 0
(putback *** *connection-pool*)
; No value
(pool-open-count *connection-pool*)
;=> 1
(pool-idle-count *connection-pool*)
;=> 1
;; Using `with-connection` macro.
(with-connection (mito:*connection* *connection-pool*)
(mito:find-dao 'user :name "fukamachi"))
API
[Constructor] make-pool (&key name connector disconnector ping max-open-count max-idle-count timeout idle-timeout)
:name
: The name of a new pool. This is used to print the object.
:connector
(Required): A function to make and return a new connection object. It takes no arguments.
:disconnector
: A function to disconnect a given object. It takes a single argument which is made by :connector
.
:ping
: A function to check if the given object is still available. It takes a single argument.
:max-open-count
: The maximum number of concurrently open connections. The default is 4
and can be configured with *default-max-open-count*
.
:max-idle-count
: The maximum number of idle/pooled connections. The default is 2
and can be configured with *default-max-idle-count*
.
:timeout
: The milliseconds to wait in fetch
when the number of open connection reached to the maximum. If nil
, it waits forever. The default is nil
.
:idle-timeout
: The milliseconds to disconnect idle resources after they're putback
ed to the pool. If nil
, it won't disconnect automatically. The default is nil
.
[Accessor] pool-max-open-count (pool)
Return the maximum number of concurrently open connections. If the number of open connections reached to the limit, fetch
waits until a connection is available.
[Accessor] (setf pool-max-open-count) (new-max-open-count pool)
Set the maximum number of concurrently open connections.
[Accessor] pool-max-idle-count (pool)
Return the maximum number of idle/pooled connections. If the number of idle connections reached to the limit, extra connections will be disconnected in putback
.
[Accessor] (setf pool-max-idle-count) (new-max-idle-count pool)
Set the maximum number of idle/pooled connections.
[Accessor] pool-idle-timeout (pool)
Return the milliseconds to disconnect idle resources after they're putback
ed to the pool. If nil
, this feature is disabled.
[Accessor] (setf pool-idle-timeout) (new-idle-timeout pool)
Set the milliseconds to disconnect idle resources after they're putback
ed to the pool. If nil
, this feature is disabled.
[Accessor] pool-open-count (pool)
Return the number of currently open connections. The count is the sum of pool-active-count
and pool-idle-count
.
[Accessor] pool-active-count (pool)
Return the number of currently in use connections.
[Accessor] pool-idle-count (pool)
Return the number of currently idle connections.
[Function] fetch (pool)
Return an available resource from the pool
. If no open resources available, it makes a new one with a function specified to make-pool
as :connector
.
No open resource available and can't open due to the max-open-count
, this function waits for :timeout
milliseconds. If :timeout
specified to nil
, this waits forever until a new one turns to available.
[Function] putback (object pool)
Send an in-use connection back to pool
to make it reusable by other threads. If the number of idle connections is reached to pool-max-idle-count
, the connection will be disconnected immediately.
Author
- Eitaro Fukamachi (e.arrows@gmail.com)
Copyright
Copyright (c) 2020 Eitaro Fukamachi (e.arrows@gmail.com)
License
Licensed under the BSD 2-Clause License.
2 Systems
The main system appears first, followed by any subsystem dependency.
2.1 anypool
- Author
Eitaro Fukamachi
- License
BSD 2-Clause
- Description
General-purpose pooling library
- Version
0.1.0
- Dependencies
- bordeaux-threads
- cl-speedy-queue
- Source
anypool.asd (file)
- Component
src (module)
3 Modules
Modules are listed depth-first from the system components tree.
3.1 anypool/src
- Parent
anypool (system)
- Location
src/
- Component
main.lisp (file)
4 Files
Files are sorted by type and then listed depth-first from the systems
components trees.
4.1 Lisp
4.1.1 anypool.asd
- Location
anypool.asd
- Systems
anypool (system)
4.1.2 anypool/src/main.lisp
- Parent
src (module)
- Location
src/main.lisp
- Packages
anypool
- Exported Definitions
-
- Internal Definitions
-
5 Packages
Packages are listed by definition order.
5.1 anypool
- Source
main.lisp (file)
- Nickname
anypool/main
- Use List
common-lisp
- Exported Definitions
-
- Internal Definitions
-
6 Definitions
Definitions are sorted by export status, category, package, and then by
lexicographic order.
6.1 Exported definitions
6.1.1 Special variables
- Special Variable: *default-max-idle-count*
-
- Package
anypool
- Source
main.lisp (file)
- Special Variable: *default-max-open-count*
-
- Package
anypool
- Source
main.lisp (file)
6.1.2 Macros
- Macro: with-connection (CONN POOL) &body BODY
-
- Package
anypool
- Source
main.lisp (file)
6.1.3 Functions
- Function: fetch POOL
-
- Package
anypool
- Source
main.lisp (file)
- Function: make-pool &key NAME CONNECTOR DISCONNECTOR PING MAX-OPEN-COUNT MAX-IDLE-COUNT TIMEOUT IDLE-TIMEOUT &aux STORAGE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-active-count INSTANCE
-
- Function: (setf pool-active-count) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-idle-count POOL
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-idle-timeout INSTANCE
-
- Function: (setf pool-idle-timeout) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-max-idle-count INSTANCE
-
- Function: (setf pool-max-idle-count) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-max-open-count INSTANCE
-
- Function: (setf pool-max-open-count) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-name INSTANCE
-
- Function: (setf pool-name) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-open-count POOL
-
- Package
anypool
- Source
main.lisp (file)
- Function: putback CONN POOL
-
- Package
anypool
- Source
main.lisp (file)
6.1.4 Generic functions
- Generic Function: error-max-open-limit CONDITION
-
- Package
anypool
- Methods
- Method: error-max-open-limit (CONDITION too-many-open-connection)
-
- Source
main.lisp (file)
6.1.5 Conditions
- Condition: too-many-open-connection ()
-
- Package
anypool
- Source
main.lisp (file)
- Direct superclasses
anypool-error (condition)
- Direct methods
error-max-open-limit (method)
- Direct slots
- Slot: limit
-
- Initargs
:limit
- Readers
error-max-open-limit (generic function)
6.1.6 Structures
- Structure: pool ()
-
- Package
anypool
- Source
main.lisp (file)
- Direct superclasses
structure-object (structure)
- Direct methods
print-object (method)
- Direct slots
- Slot: name
-
- Readers
pool-name (function)
- Writers
(setf pool-name) (function)
- Slot: connector
-
- Readers
pool-connector (function)
- Writers
(setf pool-connector) (function)
- Slot: disconnector
-
- Readers
pool-disconnector (function)
- Writers
(setf pool-disconnector) (function)
- Slot: ping
-
- Readers
pool-ping (function)
- Writers
(setf pool-ping) (function)
- Slot: max-open-count
-
- Readers
pool-max-open-count (function)
- Writers
(setf pool-max-open-count) (function)
- Slot: max-idle-count
-
- Readers
pool-max-idle-count (function)
- Writers
(setf pool-max-idle-count) (function)
- Slot: idle-timeout
-
- Readers
pool-idle-timeout (function)
- Writers
(setf pool-idle-timeout) (function)
- Slot: timeout
-
- Readers
pool-timeout (function)
- Writers
(setf pool-timeout) (function)
- Slot: storage
-
- Readers
pool-storage (function)
- Writers
(setf pool-storage) (function)
- Slot: active-count
-
- Type
fixnum
- Initform
0
- Readers
pool-active-count (function)
- Writers
(setf pool-active-count) (function)
- Slot: timeout-in-queue-count
-
- Type
fixnum
- Initform
0
- Readers
pool-timeout-in-queue-count (function)
- Writers
(setf pool-timeout-in-queue-count) (function)
- Slot: lock
-
- Initform
(bordeaux-threads:make-lock "anypool-lock")
- Readers
pool-lock (function)
- Writers
(setf pool-lock) (function)
- Slot: wait-lock
-
- Initform
(bordeaux-threads:make-lock "anypool-openwait-lock")
- Readers
pool-wait-lock (function)
- Writers
(setf pool-wait-lock) (function)
- Slot: wait-condvar
-
- Initform
(bordeaux-threads:make-condition-variable :name "anypool-openwait")
- Readers
pool-wait-condvar (function)
- Writers
(setf pool-wait-condvar) (function)
6.2 Internal definitions
6.2.1 Functions
- Function: copy-item INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: copy-pool INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: dequeue-timeout-resources POOL
-
- Package
anypool
- Source
main.lisp (file)
- Function: item-idle-timer INSTANCE
-
- Function: (setf item-idle-timer) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: item-object INSTANCE
-
- Function: (setf item-object) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: item-p OBJECT
-
- Package
anypool
- Source
main.lisp (file)
- Function: item-timeout-p INSTANCE
-
- Function: (setf item-timeout-p) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: make-idle-timer ITEM TIMEOUT-FN
-
- Package
anypool
- Source
main.lisp (file)
- Function: make-item OBJECT
-
- Package
anypool
- Source
main.lisp (file)
- Function: make-queue* SIZE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-connector INSTANCE
-
- Function: (setf pool-connector) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-disconnector INSTANCE
-
- Function: (setf pool-disconnector) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-lock INSTANCE
-
- Function: (setf pool-lock) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-p OBJECT
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-ping INSTANCE
-
- Function: (setf pool-ping) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-storage INSTANCE
-
- Function: (setf pool-storage) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-timeout INSTANCE
-
- Function: (setf pool-timeout) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-timeout-in-queue-count INSTANCE
-
- Function: (setf pool-timeout-in-queue-count) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-wait-condvar INSTANCE
-
- Function: (setf pool-wait-condvar) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: pool-wait-lock INSTANCE
-
- Function: (setf pool-wait-lock) VALUE INSTANCE
-
- Package
anypool
- Source
main.lisp (file)
- Function: queue-peek* QUEUE
-
- Package
anypool
- Source
main.lisp (file)
6.2.2 Conditions
- Condition: anypool-error ()
-
- Package
anypool
- Source
main.lisp (file)
- Direct superclasses
error (condition)
- Direct subclasses
too-many-open-connection (condition)
6.2.3 Structures
- Structure: item ()
-
- Package
anypool
- Source
main.lisp (file)
- Direct superclasses
structure-object (structure)
- Direct slots
- Slot: object
-
- Readers
item-object (function)
- Writers
(setf item-object) (function)
- Slot: idle-timer
-
- Readers
item-idle-timer (function)
- Writers
(setf item-idle-timer) (function)
- Slot: timeout-p
-
- Readers
item-timeout-p (function)
- Writers
(setf item-timeout-p) (function)
Appendix A Indexes
A.1 Concepts
A.2 Functions
| Index Entry | | Section |
|
( | | |
| (setf item-idle-timer) : | | Internal functions |
| (setf item-object) : | | Internal functions |
| (setf item-timeout-p) : | | Internal functions |
| (setf pool-active-count) : | | Exported functions |
| (setf pool-connector) : | | Internal functions |
| (setf pool-disconnector) : | | Internal functions |
| (setf pool-idle-timeout) : | | Exported functions |
| (setf pool-lock) : | | Internal functions |
| (setf pool-max-idle-count) : | | Exported functions |
| (setf pool-max-open-count) : | | Exported functions |
| (setf pool-name) : | | Exported functions |
| (setf pool-ping) : | | Internal functions |
| (setf pool-storage) : | | Internal functions |
| (setf pool-timeout) : | | Internal functions |
| (setf pool-timeout-in-queue-count) : | | Internal functions |
| (setf pool-wait-condvar) : | | Internal functions |
| (setf pool-wait-lock) : | | Internal functions |
|
C | | |
| copy-item : | | Internal functions |
| copy-pool : | | Internal functions |
|
D | | |
| dequeue-timeout-resources : | | Internal functions |
|
E | | |
| error-max-open-limit : | | Exported generic functions |
| error-max-open-limit : | | Exported generic functions |
|
F | | |
| fetch : | | Exported functions |
| Function, (setf item-idle-timer) : | | Internal functions |
| Function, (setf item-object) : | | Internal functions |
| Function, (setf item-timeout-p) : | | Internal functions |
| Function, (setf pool-active-count) : | | Exported functions |
| Function, (setf pool-connector) : | | Internal functions |
| Function, (setf pool-disconnector) : | | Internal functions |
| Function, (setf pool-idle-timeout) : | | Exported functions |
| Function, (setf pool-lock) : | | Internal functions |
| Function, (setf pool-max-idle-count) : | | Exported functions |
| Function, (setf pool-max-open-count) : | | Exported functions |
| Function, (setf pool-name) : | | Exported functions |
| Function, (setf pool-ping) : | | Internal functions |
| Function, (setf pool-storage) : | | Internal functions |
| Function, (setf pool-timeout) : | | Internal functions |
| Function, (setf pool-timeout-in-queue-count) : | | Internal functions |
| Function, (setf pool-wait-condvar) : | | Internal functions |
| Function, (setf pool-wait-lock) : | | Internal functions |
| Function, copy-item : | | Internal functions |
| Function, copy-pool : | | Internal functions |
| Function, dequeue-timeout-resources : | | Internal functions |
| Function, fetch : | | Exported functions |
| Function, item-idle-timer : | | Internal functions |
| Function, item-object : | | Internal functions |
| Function, item-p : | | Internal functions |
| Function, item-timeout-p : | | Internal functions |
| Function, make-idle-timer : | | Internal functions |
| Function, make-item : | | Internal functions |
| Function, make-pool : | | Exported functions |
| Function, make-queue* : | | Internal functions |
| Function, pool-active-count : | | Exported functions |
| Function, pool-connector : | | Internal functions |
| Function, pool-disconnector : | | Internal functions |
| Function, pool-idle-count : | | Exported functions |
| Function, pool-idle-timeout : | | Exported functions |
| Function, pool-lock : | | Internal functions |
| Function, pool-max-idle-count : | | Exported functions |
| Function, pool-max-open-count : | | Exported functions |
| Function, pool-name : | | Exported functions |
| Function, pool-open-count : | | Exported functions |
| Function, pool-p : | | Internal functions |
| Function, pool-ping : | | Internal functions |
| Function, pool-storage : | | Internal functions |
| Function, pool-timeout : | | Internal functions |
| Function, pool-timeout-in-queue-count : | | Internal functions |
| Function, pool-wait-condvar : | | Internal functions |
| Function, pool-wait-lock : | | Internal functions |
| Function, putback : | | Exported functions |
| Function, queue-peek* : | | Internal functions |
|
G | | |
| Generic Function, error-max-open-limit : | | Exported generic functions |
|
I | | |
| item-idle-timer : | | Internal functions |
| item-object : | | Internal functions |
| item-p : | | Internal functions |
| item-timeout-p : | | Internal functions |
|
M | | |
| Macro, with-connection : | | Exported macros |
| make-idle-timer : | | Internal functions |
| make-item : | | Internal functions |
| make-pool : | | Exported functions |
| make-queue* : | | Internal functions |
| Method, error-max-open-limit : | | Exported generic functions |
|
P | | |
| pool-active-count : | | Exported functions |
| pool-connector : | | Internal functions |
| pool-disconnector : | | Internal functions |
| pool-idle-count : | | Exported functions |
| pool-idle-timeout : | | Exported functions |
| pool-lock : | | Internal functions |
| pool-max-idle-count : | | Exported functions |
| pool-max-open-count : | | Exported functions |
| pool-name : | | Exported functions |
| pool-open-count : | | Exported functions |
| pool-p : | | Internal functions |
| pool-ping : | | Internal functions |
| pool-storage : | | Internal functions |
| pool-timeout : | | Internal functions |
| pool-timeout-in-queue-count : | | Internal functions |
| pool-wait-condvar : | | Internal functions |
| pool-wait-lock : | | Internal functions |
| putback : | | Exported functions |
|
Q | | |
| queue-peek* : | | Internal functions |
|
W | | |
| with-connection : | | Exported macros |
|
A.3 Variables
| Index Entry | | Section |
|
* | | |
| *default-max-idle-count* : | | Exported special variables |
| *default-max-open-count* : | | Exported special variables |
|
A | | |
| active-count : | | Exported structures |
|
C | | |
| connector : | | Exported structures |
|
D | | |
| disconnector : | | Exported structures |
|
I | | |
| idle-timeout : | | Exported structures |
| idle-timer : | | Internal structures |
|
L | | |
| limit : | | Exported conditions |
| lock : | | Exported structures |
|
M | | |
| max-idle-count : | | Exported structures |
| max-open-count : | | Exported structures |
|
N | | |
| name : | | Exported structures |
|
O | | |
| object : | | Internal structures |
|
P | | |
| ping : | | Exported structures |
|
S | | |
| Slot, active-count : | | Exported structures |
| Slot, connector : | | Exported structures |
| Slot, disconnector : | | Exported structures |
| Slot, idle-timeout : | | Exported structures |
| Slot, idle-timer : | | Internal structures |
| Slot, limit : | | Exported conditions |
| Slot, lock : | | Exported structures |
| Slot, max-idle-count : | | Exported structures |
| Slot, max-open-count : | | Exported structures |
| Slot, name : | | Exported structures |
| Slot, object : | | Internal structures |
| Slot, ping : | | Exported structures |
| Slot, storage : | | Exported structures |
| Slot, timeout : | | Exported structures |
| Slot, timeout-in-queue-count : | | Exported structures |
| Slot, timeout-p : | | Internal structures |
| Slot, wait-condvar : | | Exported structures |
| Slot, wait-lock : | | Exported structures |
| Special Variable, *default-max-idle-count* : | | Exported special variables |
| Special Variable, *default-max-open-count* : | | Exported special variables |
| storage : | | Exported structures |
|
T | | |
| timeout : | | Exported structures |
| timeout-in-queue-count : | | Exported structures |
| timeout-p : | | Internal structures |
|
W | | |
| wait-condvar : | | Exported structures |
| wait-lock : | | Exported structures |
|
A.4 Data types