The anypool Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The anypool Reference Manual

This is the anypool Reference Manual, version 0.1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 03:13:45 2022 GMT+0.

Table of Contents


1 Introduction

anypool

Build Status

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)

[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 putbacked 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 putbacked 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

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.


Previous: , Up: Systems   [Contents][Index]

2.1 anypool

General-purpose pooling library

Author

Eitaro Fukamachi

License

BSD 2-Clause

Version

0.1.0

Dependencies
  • bordeaux-threads (system).
  • cl-speedy-queue (system).
Source

anypool.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 anypool/src

Source

anypool.asd.

Parent Component

anypool (system).

Child Component

main.lisp (file).


4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

4.1.1 anypool/anypool.asd

Source

anypool.asd.

Parent Component

anypool (system).

ASDF Systems

anypool.


Previous: , Up: Lisp   [Contents][Index]

4.1.2 anypool/src/main.lisp

Source

anypool.asd.

Parent Component

src (module).

Packages

anypool.

Public Interface
Internals

5 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

5.1 anypool

Source

main.lisp.

Nickname

anypool/main

Use List

common-lisp.

Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Public Interface


Next: , Previous: , Up: Public Interface   [Contents][Index]

6.1.1 Special variables

Special Variable: *default-max-idle-count*
Package

anypool.

Source

main.lisp.

Special Variable: *default-max-open-count*
Package

anypool.

Source

main.lisp.


6.1.2 Macros

Macro: with-connection ((conn pool) &body body)
Package

anypool.

Source

main.lisp.


6.1.3 Ordinary functions

Function: fetch (pool)
Package

anypool.

Source

main.lisp.

Function: make-pool (&key name connector disconnector ping max-open-count max-idle-count timeout idle-timeout)
Package

anypool.

Source

main.lisp.

Reader: pool-active-count (instance)
Writer: (setf pool-active-count) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

active-count.

Function: pool-idle-count (pool)
Package

anypool.

Source

main.lisp.

Reader: pool-idle-timeout (instance)
Writer: (setf pool-idle-timeout) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

idle-timeout.

Reader: pool-max-idle-count (instance)
Writer: (setf pool-max-idle-count) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

max-idle-count.

Reader: pool-max-open-count (instance)
Writer: (setf pool-max-open-count) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

max-open-count.

Reader: pool-name (instance)
Writer: (setf pool-name) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

name.

Function: pool-open-count (pool)
Package

anypool.

Source

main.lisp.

Function: putback (conn pool)
Package

anypool.

Source

main.lisp.


6.1.4 Generic functions

Generic Reader: error-max-open-limit (condition)
Package

anypool.

Methods
Reader Method: error-max-open-limit ((condition too-many-open-connection))
Source

main.lisp.

Target Slot

limit.


6.1.5 Standalone methods

Method: print-object ((object pool) stream)
Source

main.lisp.


6.1.6 Conditions

Condition: too-many-open-connection
Package

anypool.

Source

main.lisp.

Direct superclasses

anypool-error.

Direct methods

error-max-open-limit.

Direct slots
Slot: limit
Initargs

:limit

Readers

error-max-open-limit.

Writers

This slot is read-only.


Previous: , Up: Public Interface   [Contents][Index]

6.1.7 Structures

Structure: pool
Package

anypool.

Source

main.lisp.

Direct superclasses

structure-object.

Direct methods

print-object.

Direct slots
Slot: name
Readers

pool-name.

Writers

(setf pool-name).

Slot: connector
Readers

pool-connector.

Writers

(setf pool-connector).

Slot: disconnector
Readers

pool-disconnector.

Writers

(setf pool-disconnector).

Slot: ping
Readers

pool-ping.

Writers

(setf pool-ping).

Slot: max-open-count
Readers

pool-max-open-count.

Writers

(setf pool-max-open-count).

Slot: max-idle-count
Readers

pool-max-idle-count.

Writers

(setf pool-max-idle-count).

Slot: idle-timeout
Readers

pool-idle-timeout.

Writers

(setf pool-idle-timeout).

Slot: timeout
Readers

pool-timeout.

Writers

(setf pool-timeout).

Slot: storage
Readers

pool-storage.

Writers

(setf pool-storage).

Slot: active-count
Type

fixnum

Initform

0

Readers

pool-active-count.

Writers

(setf pool-active-count).

Slot: timeout-in-queue-count
Type

fixnum

Initform

0

Readers

pool-timeout-in-queue-count.

Writers

(setf pool-timeout-in-queue-count).

Slot: lock
Initform

(bordeaux-threads:make-lock "anypool-lock")

Readers

pool-lock.

Writers

(setf pool-lock).

Slot: wait-lock
Initform

(bordeaux-threads:make-lock "anypool-openwait-lock")

Readers

pool-wait-lock.

Writers

(setf pool-wait-lock).

Slot: wait-condvar
Initform

(bordeaux-threads:make-condition-variable :name "anypool-openwait")

Readers

pool-wait-condvar.

Writers

(setf pool-wait-condvar).


6.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.1 Ordinary functions

Function: copy-item (instance)
Package

anypool.

Source

main.lisp.

Function: copy-pool (instance)
Package

anypool.

Source

main.lisp.

Function: dequeue-timeout-resources (pool)
Package

anypool.

Source

main.lisp.

Reader: item-active-p (instance)
Writer: (setf item-active-p) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

active-p.

Reader: item-idle-timer (instance)
Writer: (setf item-idle-timer) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

idle-timer.

Reader: item-object (instance)
Writer: (setf item-object) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

object.

Function: item-p (object)
Package

anypool.

Source

main.lisp.

Reader: item-timeout-p (instance)
Writer: (setf item-timeout-p) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

timeout-p.

Function: make-idle-timer (item timeout-fn)
Package

anypool.

Source

main.lisp.

Function: make-item (object)
Package

anypool.

Source

main.lisp.

Function: make-queue* (size)
Package

anypool.

Source

main.lisp.

Reader: pool-connector (instance)
Writer: (setf pool-connector) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

connector.

Reader: pool-disconnector (instance)
Writer: (setf pool-disconnector) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

disconnector.

Reader: pool-lock (instance)
Writer: (setf pool-lock) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

lock.

Function: pool-p (object)
Package

anypool.

Source

main.lisp.

Reader: pool-ping (instance)
Writer: (setf pool-ping) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

ping.

Reader: pool-storage (instance)
Writer: (setf pool-storage) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

storage.

Reader: pool-timeout (instance)
Writer: (setf pool-timeout) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

timeout.

Reader: pool-timeout-in-queue-count (instance)
Writer: (setf pool-timeout-in-queue-count) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

timeout-in-queue-count.

Reader: pool-wait-condvar (instance)
Writer: (setf pool-wait-condvar) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

wait-condvar.

Reader: pool-wait-lock (instance)
Writer: (setf pool-wait-lock) (instance)
Package

anypool.

Source

main.lisp.

Target Slot

wait-lock.

Function: queue-peek* (queue)
Package

anypool.

Source

main.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.2 Conditions

Condition: anypool-error
Package

anypool.

Source

main.lisp.

Direct superclasses

error.

Direct subclasses

too-many-open-connection.


Previous: , Up: Internals   [Contents][Index]

6.2.3 Structures

Structure: item
Package

anypool.

Source

main.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: object
Readers

item-object.

Writers

(setf item-object).

Slot: idle-timer
Readers

item-idle-timer.

Writers

(setf item-idle-timer).

Slot: active-p
Readers

item-active-p.

Writers

(setf item-active-p).

Slot: timeout-p
Readers

item-timeout-p.

Writers

(setf item-timeout-p).


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
C   D   E   F   G   I   M   P   Q   W  
Index Entry  Section

(
(setf item-active-p): Private ordinary functions
(setf item-idle-timer): Private ordinary functions
(setf item-object): Private ordinary functions
(setf item-timeout-p): Private ordinary functions
(setf pool-active-count): Public ordinary functions
(setf pool-connector): Private ordinary functions
(setf pool-disconnector): Private ordinary functions
(setf pool-idle-timeout): Public ordinary functions
(setf pool-lock): Private ordinary functions
(setf pool-max-idle-count): Public ordinary functions
(setf pool-max-open-count): Public ordinary functions
(setf pool-name): Public ordinary functions
(setf pool-ping): Private ordinary functions
(setf pool-storage): Private ordinary functions
(setf pool-timeout): Private ordinary functions
(setf pool-timeout-in-queue-count): Private ordinary functions
(setf pool-wait-condvar): Private ordinary functions
(setf pool-wait-lock): Private ordinary functions

C
copy-item: Private ordinary functions
copy-pool: Private ordinary functions

D
dequeue-timeout-resources: Private ordinary functions

E
error-max-open-limit: Public generic functions
error-max-open-limit: Public generic functions

F
fetch: Public ordinary functions
Function, (setf item-active-p): Private ordinary functions
Function, (setf item-idle-timer): Private ordinary functions
Function, (setf item-object): Private ordinary functions
Function, (setf item-timeout-p): Private ordinary functions
Function, (setf pool-active-count): Public ordinary functions
Function, (setf pool-connector): Private ordinary functions
Function, (setf pool-disconnector): Private ordinary functions
Function, (setf pool-idle-timeout): Public ordinary functions
Function, (setf pool-lock): Private ordinary functions
Function, (setf pool-max-idle-count): Public ordinary functions
Function, (setf pool-max-open-count): Public ordinary functions
Function, (setf pool-name): Public ordinary functions
Function, (setf pool-ping): Private ordinary functions
Function, (setf pool-storage): Private ordinary functions
Function, (setf pool-timeout): Private ordinary functions
Function, (setf pool-timeout-in-queue-count): Private ordinary functions
Function, (setf pool-wait-condvar): Private ordinary functions
Function, (setf pool-wait-lock): Private ordinary functions
Function, copy-item: Private ordinary functions
Function, copy-pool: Private ordinary functions
Function, dequeue-timeout-resources: Private ordinary functions
Function, fetch: Public ordinary functions
Function, item-active-p: Private ordinary functions
Function, item-idle-timer: Private ordinary functions
Function, item-object: Private ordinary functions
Function, item-p: Private ordinary functions
Function, item-timeout-p: Private ordinary functions
Function, make-idle-timer: Private ordinary functions
Function, make-item: Private ordinary functions
Function, make-pool: Public ordinary functions
Function, make-queue*: Private ordinary functions
Function, pool-active-count: Public ordinary functions
Function, pool-connector: Private ordinary functions
Function, pool-disconnector: Private ordinary functions
Function, pool-idle-count: Public ordinary functions
Function, pool-idle-timeout: Public ordinary functions
Function, pool-lock: Private ordinary functions
Function, pool-max-idle-count: Public ordinary functions
Function, pool-max-open-count: Public ordinary functions
Function, pool-name: Public ordinary functions
Function, pool-open-count: Public ordinary functions
Function, pool-p: Private ordinary functions
Function, pool-ping: Private ordinary functions
Function, pool-storage: Private ordinary functions
Function, pool-timeout: Private ordinary functions
Function, pool-timeout-in-queue-count: Private ordinary functions
Function, pool-wait-condvar: Private ordinary functions
Function, pool-wait-lock: Private ordinary functions
Function, putback: Public ordinary functions
Function, queue-peek*: Private ordinary functions

G
Generic Function, error-max-open-limit: Public generic functions

I
item-active-p: Private ordinary functions
item-idle-timer: Private ordinary functions
item-object: Private ordinary functions
item-p: Private ordinary functions
item-timeout-p: Private ordinary functions

M
Macro, with-connection: Public macros
make-idle-timer: Private ordinary functions
make-item: Private ordinary functions
make-pool: Public ordinary functions
make-queue*: Private ordinary functions
Method, error-max-open-limit: Public generic functions
Method, print-object: Public standalone methods

P
pool-active-count: Public ordinary functions
pool-connector: Private ordinary functions
pool-disconnector: Private ordinary functions
pool-idle-count: Public ordinary functions
pool-idle-timeout: Public ordinary functions
pool-lock: Private ordinary functions
pool-max-idle-count: Public ordinary functions
pool-max-open-count: Public ordinary functions
pool-name: Public ordinary functions
pool-open-count: Public ordinary functions
pool-p: Private ordinary functions
pool-ping: Private ordinary functions
pool-storage: Private ordinary functions
pool-timeout: Private ordinary functions
pool-timeout-in-queue-count: Private ordinary functions
pool-wait-condvar: Private ordinary functions
pool-wait-lock: Private ordinary functions
print-object: Public standalone methods
putback: Public ordinary functions

Q
queue-peek*: Private ordinary functions

W
with-connection: Public macros

Jump to:   (  
C   D   E   F   G   I   M   P   Q   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
A   C   D   I   L   M   N   O   P   S   T   W  
Index Entry  Section

*
*default-max-idle-count*: Public special variables
*default-max-open-count*: Public special variables

A
active-count: Public structures
active-p: Private structures

C
connector: Public structures

D
disconnector: Public structures

I
idle-timeout: Public structures
idle-timer: Private structures

L
limit: Public conditions
lock: Public structures

M
max-idle-count: Public structures
max-open-count: Public structures

N
name: Public structures

O
object: Private structures

P
ping: Public structures

S
Slot, active-count: Public structures
Slot, active-p: Private structures
Slot, connector: Public structures
Slot, disconnector: Public structures
Slot, idle-timeout: Public structures
Slot, idle-timer: Private structures
Slot, limit: Public conditions
Slot, lock: Public structures
Slot, max-idle-count: Public structures
Slot, max-open-count: Public structures
Slot, name: Public structures
Slot, object: Private structures
Slot, ping: Public structures
Slot, storage: Public structures
Slot, timeout: Public structures
Slot, timeout-in-queue-count: Public structures
Slot, timeout-p: Private structures
Slot, wait-condvar: Public structures
Slot, wait-lock: Public structures
Special Variable, *default-max-idle-count*: Public special variables
Special Variable, *default-max-open-count*: Public special variables
storage: Public structures

T
timeout: Public structures
timeout-in-queue-count: Public structures
timeout-p: Private structures

W
wait-condvar: Public structures
wait-lock: Public structures

Jump to:   *  
A   C   D   I   L   M   N   O   P   S   T   W