Liking cljdoc? Tell your friends :D

objection.core

Objection helps you manage graphs of stateful objects that acquire resources that are not managed by the garbage collector.

It is good for things like, connection pools, threads, thread pools, queues, channels etc.

Register objects and dependencies via register, construct.

Inspect objects with describe, id, data, id-seq, status.

Define singletons with defsingleton and resolve them with singleton.

Objection helps you manage graphs of stateful objects that acquire resources that are not
managed by the garbage collector.

It is good for things like, connection pools, threads, thread pools, queues, channels etc.

Register objects and dependencies via `register`, `construct`.

Inspect objects with `describe`, `id`, `data`, `id-seq`, `status`.

Define singletons with `defsingleton` and resolve them with `singleton`.
raw docstring

aliasclj

(alias x alias)

Aliases an object under the provided key, each alias can only be assigned to one object, so make sure it is unique.

Onced aliased the alias can be used interchangably with the object in objection functions on the object.

Aliases an object under the provided key, each alias can only be assigned to one object, so
make sure it is unique.

Onced aliased the alias can be used interchangably with the object in objection functions on the object.
sourceraw docstring

alter-data!clj

(alter-data! x f)
(alter-data! x f & args)

Applies f to the data for the object (i.e supplied under :data key on registry/construct). Saves and returns the new data.

Applies `f` to the data for the object (i.e supplied under :data key on registry/construct).
Saves and returns the new data.
sourceraw docstring

constructcljmacro

(construct opts & body)

Takes same opts as register, takes a body that constructs an object and returns it.

locks dependencies before running the body, so they cannot be stopped while this object is being constructed.

See-also: register

Takes same opts as `register`, takes a body that constructs an object and returns it.

locks dependencies before running the body, so they cannot be stopped while
this object is being constructed.

See-also: register
sourceraw docstring

construct-callclj

(construct-call opts f)
source

dataclj

(data x)

Returns the data associated with x, which can be a registered object, alias or id.

Returns the data associated with `x`, which can be a registered object, alias or id.
sourceraw docstring

defsingletoncljmacro

(defsingleton k & body)

Defines a singleton that can be returned via (singleton k), if an instance already exists, it is returned - else the body is run to construct the instance.

If you would prefer to return an existing instance without the possibility of constructing the instance if it does not exist, use (object k).

Redefinition of a singleton will stop any existing instances.

Singletons are always implicitly registered after construction and they also receive an alias of the key used in the definition.

To introduce dependencies, stopfn, additional aliases etc, you can register or construct the object in the body of the singleton in the normal way.

Defines a singleton that can be returned via (singleton k), if an instance already exists, it is returned - else the body is run
to construct the instance.

If you would prefer to return an existing instance without the possibility of constructing the instance if it does not exist, use (object k).

Redefinition of a singleton will stop any existing instances.

Singletons are always implicitly registered after construction
and they also receive an alias of the key used in the definition.

To introduce dependencies, stopfn, additional aliases etc, you can register or construct the object in the body
of the singleton in the normal way.
sourceraw docstring

dependclj

(depend x dependency)

Makes x dependent on dependency, both can be registered object instances, aliases or ids. When you (stop! dependency) objection will make sure that x is stopped first.

Makes `x` dependent on `dependency`, both can be registered object instances, aliases or ids.
When you `(stop! dependency)` objection will make sure that `x` is stopped first.
sourceraw docstring

dependenciesclj

(dependencies x)

Returns the ids of dependencies of x.

Returns the ids of dependencies of `x`.
sourceraw docstring

dependentsclj

(dependents x)

Returns the ids of the dependents of x.

Returns the ids of the dependents of `x`.
sourceraw docstring

depends?clj

(depends? x dependency)

Is x dependent on dependency?

Is `x` dependent on dependency?
sourceraw docstring

describeclj

(describe x)

Returns information about x, which can be a registered object, alias or id.

Returns information about `x`, which can be a registered object, alias or id.
sourceraw docstring

IAutoStoppablecljprotocol

A protocol that can be extended to types in order to tell objection how to stop! them if a :stopfn is not provided on registry.

A protocol that can be extended to types in order to tell objection how to stop! them if a :stopfn is not provided
on registry.

-stop!clj

(-stop! this)

Extend to types to provide a stop behaviour for objects of that type.

Extend to types to provide a stop behaviour for objects of that type.
sourceraw docstring

idclj

(id x)

Returns the id of the object if the object is registered.

You can pass the object instance, or an alias of the object.

Returns the id of the object if the object is registered.

You can pass the object instance, or an alias of the object.
sourceraw docstring

id-seqclj

(id-seq)

Returns the seq of registered object ids.

Returns the seq of registered object ids.
sourceraw docstring

needclj

(need x)
(need x error-message)

Tries to resolve x to a registered object, or singleton - throws an exception with the message if not possible.

Tries to resolve `x` to a registered object, or singleton - throws an exception with the message if not possible.
sourceraw docstring

objectclj

(object x)

Returns a registered object, can pass either an id, id-prefix, alias or object instance.

Returns a registered object, can pass either an id, id-prefix, alias or object instance.
sourceraw docstring

put-singleton*clj

(put-singleton* k f meta)
source

registerclj

(register obj)
(register obj opts)

Registers the object with objection and returns it, will assign it an id automatically.

An object can be practically anything, but would be expected to be something like a connection pool or a thread etc.

A registered object is kept alive by objection. Stop the object using the (stop! obj) function. Almost all objection functions can use the object itself, an id, id prefix or alias.

See-also: construct

Opts:

:name - a human friendly name to use for the object in display functions, doesn't have to be unique.

:aliases - a sequence of aliases to apply to the object, each alias can be used interchangebly with the object in objection functions.

:data - user supplied metadata about the object, retrieve later with (data obj).

:deps - a sequence of dependencies, supports passing objection ids, aliases or registered objects.

:stopfn - a function of the object that performs any shutdown logic. Alternatively implement IAutoStoppable for the type of the object.

Registers the object with objection and returns it, will assign it an id automatically.

An object can be practically anything, but would be expected to be something like a connection pool or a thread etc.

A registered object is kept alive by objection. Stop the object using the (stop! obj) function.
Almost all objection functions can use the object itself, an id, id prefix or alias.

See-also: construct

Opts:

`:name` - a human friendly name to use for the object in display functions, doesn't have to be unique.

`:aliases` - a sequence of aliases to apply to the object, each alias can be used interchangebly with the object
 in objection functions.

`:data` - user supplied metadata about the object, retrieve later with (data obj).

`:deps` - a sequence of dependencies, supports passing objection ids, aliases or registered objects.

`:stopfn` - a function of the object that performs any shutdown logic. Alternatively implement IAutoStoppable
 for the type of the object.
sourceraw docstring

rename!clj

(rename! x s)

Changes the :name of x to s. Then name is intended for display purposes only.

Changes the :name of `x` to `s`. Then name is intended for display purposes only.
sourceraw docstring

singletonclj

(singleton k)

Like (object k) but if a singleton is registered under the key k, it will be constructed if necessary in order to return the instance.

Singleton will always return an instance if one has been defined.

Like (object `k`) but if a singleton is registered under the key `k`, it will be constructed if necessary
in order to return the instance.

Singleton will always return an instance if one has been defined.
sourceraw docstring

singleton-keysclj

(singleton-keys)

Returns the keys of each registered singleton.

Returns the keys of each registered singleton.
sourceraw docstring

statusclj

(status)

Prints information about currently registered objects.

Prints information about currently registered objects.
sourceraw docstring

stop!clj

(stop! x)
(stop! x opts)

Runs the stopfn of x or the type specific AutoStoppable impl. e.g on AutoCloseable objects .close will be called.

Removes the object from the registry.

If an exception is thrown when stopping the object, it will remain in the registry, use the :force? option to unregister on error.

Runs the stopfn of `x` or the type specific AutoStoppable impl. e.g on AutoCloseable objects .close will be called.

Removes the object from the registry.

If an exception is thrown when stopping the object, it will remain in the registry, use the :force? option to unregister
on error.
sourceraw docstring

stop-all!clj

(stop-all!)

Stops all current registered objects.

Stops all current registered objects.
sourceraw docstring

undependclj

(undepend x dependency)

Removes a dependency relationship between x and dependency, both of which can be registered object instances, aliases or ids.

Removes a dependency relationship between `x` and `dependency`, both of which can be registered object instances, aliases or ids. 
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close