io.randomseed.utils.bus

added in 1.0.0

Random utils, inter-thread bus.

close

(close wrk)

config

(config wid)(config workers wid)

control-channel

(control-channel wrk)

current-ns-str

data-channel

(data-channel wrk)

empty-outcome

empty-reply

get-command

(get-command wrk)

get-data

(get-data wrk)

get-result

(get-result wrk)

handle-command

(handle-command wrk f)

handle-request

(handle-request wrk req f & handler-args)

id-request->response

(id-request->response wrk req id)(id-request->response wrk req id & args)

Sends a blocking request and waits for any response.

list-workers

(list-workers)(list-workers workers)

new-control-channel

(new-control-channel)

new-data-channel

(new-data-channel)

new-outcome

(new-outcome)(new-outcome req)(new-outcome req res)(new-outcome req res data)

Used to wrap the outcome of request handling and to convert the output to the Outcome object.

new-reply

(new-reply)(new-reply body)(new-reply body data)

Used to enrich the output of a handling function so it can return both: response body and additional data.

new-request

(new-request wrk req)(new-request wrk req id & args)

new-response

(new-response wrk res)(new-response wrk res req)(new-response wrk res req id)

new-worker

(new-worker w id config f)(new-worker w id config f multi?)

new-worker!

(new-worker! id config f)(new-worker! workers id config f)

new-worker-with-wid

(new-worker-with-wid w id config f multi?)

outcome?

(outcome? v)

process-request

(process-request wrk f & args)

Receives a request from the control channel and calls a handler f on worker object, request and args provided. Blocks on receiving (waits for data) and on sending (waits for the channel to have some space for a new message).

If the handler function returns nil or :io.randomseed.utils.bus/no-response, the response should not be created and the returned value is an empty Outcome object.

If the handler returns a Reply object, the response should be generated even if its :body field is nil. This is helpful in cases where nil responses are required.

If the handler returns a Reply object but its :body is set to :io.randomseed.utils.bus/no-response then no response will be generated and the response in the returned Outcome object will be set to nil.

Otherwise an Outcome object will be returned with :request, :response and :data fields.

put-command

(put-command wrk msg)

put-data

(put-data wrk msg)

receive-request

(receive-request wrk)

receive-response

(receive-response wrk)

remove-worker

(remove-worker workers wrk)

remove-worker!

(remove-worker! wrk)(remove-worker! wrokers wrk)

reply?

(reply? v)

request->response

(request->response wrk req)(request->response wrk req & args)

Sends a blocking request and waits for any response.

request?

(request? v)

response?

(response? v)

send-id-request

(send-id-request wrk req id)(send-id-request wrk req id & args)

send-request

(send-request wrk req)(send-request wrk req & args)

send-response

(send-response wrk res)(send-response wrk res req)(send-response wrk res req id & args)

start-worker

(start-worker id config f & args)

stop-worker

(stop-worker wrk)(stop-worker wrk msg-or-fn)

try-process-request

(try-process-request wrk f & args)

Receives a request from the control channel and calls a handler f on worker object, request and args provided. Does not block on receiving (returns immediately when there is no data on the control channel and blocks on sending (waits for the channel to have some space for a new message).

If the handler function returns nil or :io.randomseed.utils.bus/no-response, the response should not be created and the returned value is an empty Outcome object.

If the handler returns a Reply object, the response should be generated even if its :body field is nil. This is helpful in cases where nil responses are required.

If the handler returns a Reply object but its :body is set to :io.randomseed.utils.bus/no-response then no response will be generated and the response in the returned Outcome object will be set to nil.

Otherwise an Outcome object will be returned with :request, :response and :data fields.

try-put-command

(try-put-command wrk msg)

try-put-data

(try-put-data wrk msg)

try-send-id-request

(try-send-id-request wrk req id)(try-send-id-request wrk req id & args)

try-send-request

(try-send-request wrk req)(try-send-request wrk req & args)

try-send-response

(try-send-response wrk res)(try-send-response wrk res req)(try-send-response wrk res req id & args)

update-config

(update-config workers wrk f & args)

update-config!

(update-config! & args)

update-worker

(update-worker workers wrk)(update-worker workers wrk f & args)

update-worker!

(update-worker! & args)

wait-for-command

(wait-for-command wrk)

wait-for-data

(wait-for-data wrk)

wait-for-request

(wait-for-request wrk)

wait-for-response

(wait-for-response wrk)

wait-for-result

(wait-for-result wrk)

worker

(worker v)(worker workers v)

worker-exists?

(worker-exists? v)(worker-exists? workers v)

worker-id

(worker-id v)

worker?

(worker? v)

workers

workers?

(workers? v)