io.randomseed.utils.bus
added in 1.0.0
Random utils, inter-thread bus.
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.
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)