io.randomseed.utils.bus
added in 1.0.0
Random utils, inter-thread bus.
->Outcome
(->Outcome request response data)Positional factory function for class io.randomseed.utils.bus.Outcome.
->Reply
(->Reply body data)Positional factory function for class io.randomseed.utils.bus.Reply.
->Request
(->Request id to body args)Positional factory function for class io.randomseed.utils.bus.Request.
->Response
(->Response id from body request)Positional factory function for class io.randomseed.utils.bus.Response.
->Worker
(->Worker id fn control data result config)Positional factory function for class io.randomseed.utils.bus.Worker.
->Workers
(->Workers ids db)Positional factory function for class io.randomseed.utils.bus.Workers.
bus?
(bus? v)True if v is a Workers record or a derefable holding Workers (e.g. the global workers atom).
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.
map->Outcome
(map->Outcome m__8001__auto__)Factory function for class io.randomseed.utils.bus.Outcome, taking a map of keywords to field values.
map->Reply
(map->Reply m__8001__auto__)Factory function for class io.randomseed.utils.bus.Reply, taking a map of keywords to field values.
map->Request
(map->Request m__8001__auto__)Factory function for class io.randomseed.utils.bus.Request, taking a map of keywords to field values.
map->Response
(map->Response m__8001__auto__)Factory function for class io.randomseed.utils.bus.Response, taking a map of keywords to field values.
map->Worker
(map->Worker m__8001__auto__)Factory function for class io.randomseed.utils.bus.Worker, taking a map of keywords to field values.
map->Workers
(map->Workers m__8001__auto__)Factory function for class io.randomseed.utils.bus.Workers, taking a map of keywords to field values.
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-response
(new-response wrk res)(new-response wrk res req)(new-response wrk res req id)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.
request->response
(request->response wrk req)(request->response wrk req & args)Sends a blocking request and waits for any response.
send-response
(send-response wrk res)(send-response wrk res req)(send-response wrk res req id & _args)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-send-id-request
(try-send-id-request wrk req id)(try-send-id-request wrk req id & args)try-send-response
(try-send-response wrk res)(try-send-response wrk res req)(try-send-response wrk res req id & _args)