Recycle Api Documentation

Version: 0.1.0-SNAPSHOT

recycle.core

*timeout*

dynamic

Maximum number of milliseconds to wait for a response from a service. This variable by default is nil, meaning the value used when creating the service is used.

?

(? service & args)

Alias for ask. Send args to service and return the result the service has for that invocation.

ask

(ask service & args)

Send args to service and return the result the service has for that invocation.

key

(key service)

Returns the key that identifies service.

service

(service spec)

Create a service using the spec map as a blueprint. The spec map may contain any of the following keys (all of the are optional):

:key - keyword that identifies the service

:map-config - function that modifies the config arg that is supplied to the :start function when starting the service.

:start - function that receives a config arg, starts the service, and returns its instance. By default a function that ignores the config arg and returns nil is used.

:stop - function that receives the instance of the service and stops it. By default a function that ignores the instance arg and returns nil is used.

:receive - function that receives the instance of the service, a variable number of args identifying the message sent to the service, and that dispatches the action corresponding to that message.

:timeout - maximum number of milliseconds to wait for a response from the service. It can be overriden also with the special variable timeout. By default is 1 minute.

:buf-or-n - core.async buffer or size of buffer to use for the service communication channel. By default is 1024.

service-map

(service-map spec)

Create a service using the spec map as a blueprint. The spec map is a map of keywords identifying services to service-specs. Returns a service that will: - start (in any order) each service in the map when started

  • stop (in any order) each service in the map when stopped

  • route messages to each service when asked, the first arg in ask identifies the service key in the map and the rest are used to ask the service

start

(start service config)

Starts service using config as the configuration. If service cannot start throws an ex-info. Returns nil.

started?

(started? service)

Check if service is started. Returns true if it is, false if it’s not.

stop

(stop service)

Stops service. If service cannot stop throws an ex-info. Returns nil.

stopped?

(stopped? service)

Check if service is stopped. Returns true if it is, false if it’s not.