severin.core

A library for implementing resource pools.

create!

(create! pool uri)
Tries to retrieve and recycle an already created resource from `pool`. If
no resource can be found a new one is created.

dispose!

(dispose! pool uri resource)(dispose! pool resource)
Places a resource back in `pool` or disposes it when maximum size is
reached.

FactoryProtocol

protocol

members

-create!

(-create! this uri)
Creates a new resource from a URI.

-dispose!

(-dispose! this resource)
Disposes a resource.

-recycle!

(-recycle! this resource uri)
Recycles an existing resource and assigns a URI.

-valid?

(-valid? this resource)
Tests if a resource is still valid.

make-factory

multimethod

Creates a factory from a URI by dispatching on the scheme.

make-pool

(make-pool & {:keys [max-size], :or {max-size 10}})
Returns a new Ref with an empty hash map as initial value.

URI->KeyProtocol

protocol

members

-uri->key

(-uri->key this uri)
Converts a URI to a keyword.

URIProtocol

protocol

members

-uri

(-uri this)
Returns the URI of a resource.

with-pool

macro

(with-pool pool bindings & body)
binding => [name uri ...]
Evaluates `body` in a try expression with names bound to the values of the
created resources. The finally clause calls `dispose!` on each name.