Liking cljdoc? Tell your friends :D

otplike.gen-server

gen-server behaviour and related functions.

gen-server behaviour and related functions.
raw docstring

callclj

(call server request)
(call server request timeout-ms)

The same as call! but returns async value.

The same as `call!` but returns async value.
sourceraw docstring

call!cljmacro

(call! server request)
(call! server request timeout-ms)

Makes a synchronous call to a server by sending a request and waiting until a reply arrives or a time-out occurs. The handle-call callback of the gen-server is called to handle the request.

server can be a pid or a registered name.

request is any form that is passed as the request arguments to handle-call.

timeout-ms is an integer greater than zero that specifies how many milliseconds to wait for a reply, or the keyword :infinity to wait indefinitely. Defaults to 5000. If no reply is received within the specified time, the function call fails. If the caller catches the failure and continues running, and the server is just late with the reply, it can arrive at any time later into the message queue of the caller. The caller must in this case be prepared for this and discard any such garbage messages that are two element tuples with a reference as the first element.

The return value is defined in the return value of handle-call.

The call can fail for many reasons, including time-out and the called gen-server process dying before or during the call.

Makes a synchronous call to a `server` by sending a `request` and
waiting until a reply arrives or a time-out occurs. The `handle-call`
callback of the gen-server is called to handle the request.

`server` can be a pid or a registered name.

`request` is any form that is passed as the `request` arguments to
`handle-call`.

`timeout-ms` is an integer greater than zero that specifies how many
milliseconds to wait for a reply, or the keyword `:infinity` to wait
indefinitely. Defaults to 5000. If no reply is received within the
specified time, the function call fails.
If the caller catches the failure and continues running, and the server
is just late with the reply, it can arrive at any time later into the
message queue of the caller. The caller must in this case be prepared
for this and discard any such garbage messages that are two element
tuples with a reference as the first element.

The return value is defined in the return value of `handle-call`.

The call can fail for many reasons, including time-out and the called
gen-server process dying before or during the call.
sourceraw docstring

castclj

(cast server request)

Sends an asynchronous request to the server and returns immediately, ignoring if the server process does not exist. The handle-cast callback of the gen-server is called to handle the request.

request is any form that is passed as the request argument to handle-cast.

Sends an asynchronous request to the `server` and returns immediately,
ignoring if the `server` process does not exist. The `handle-cast`
callback of the gen-server is called to handle the request.

`request` is any form that is passed as the `request` argument to
`handle-cast`.
sourceraw docstring

IGenServercljprotocol

handle-callclj

(handle-call _ request from state)

handle-castclj

(handle-cast _ request state)

handle-infoclj

(handle-info _ request state)

initclj

(init _ args)

terminateclj

(terminate _ reason state)
source

replyclj

(reply [mref pid :as _from] response)

This function can be used to explicitly send a reply to a client that called call* or, when the reply cannot be defined in the return value of handle-call. This allows processing call* requests asynchronously.

Client must be the from argument provided to the handle-call callback. reply is given back to the client as the return value of call*.

The return value is not further defined, and is always to be ignored.

This function can be used to explicitly send a reply to a client
that called `call*` or, when the reply cannot be defined in the
return value of `handle-call`. This allows processing `call*` requests
asynchronously.

Client must be the `from` argument provided to the `handle-call`
callback. `reply` is given back to the client as the return value
of `call*`.

The return value is not further defined, and is always to be ignored.
sourceraw docstring

startclj

(start server)
(start server args)
(start server args options)
(start reg-name server args options)

The same as start! but returns async value.

The same as `start!` but returns async value.
sourceraw docstring

start!cljmacro

(start! server)
(start! server args)
(start! server args options)
(start! reg-name server args options)

Starts the server, passing args to server's init function.

Arguments: server-impl - IGenServer implementation, or map, or namespace. args - any form that is passed as the argument to init function.

Options: :timeout - time in milliseconds gen-server is allowed to spend initializing or it is terminated and the start function returns [:error :timeout]. :spawn-opt - options used to spawn the gen-server process (see process/spawn-opt)

Returns: [:ok pid] if server started successfully, [:error :no-init] if server implementation doesn't provide init function, [:error [:bad-return-value value]] if init returns a bad value, [:error reason] otherwise.

Throws on invalid arguments, or when the name is already registered.

Starts the server, passing `args` to server's `init` function.

Arguments:
`server-impl` - `IGenServer` implementation, or map, or namespace.
`args` - any form that is passed as the argument to init function.

Options:
`:timeout` - time in milliseconds gen-server is allowed to spend
  initializing  or it is terminated and the start function returns
  `[:error :timeout]`.
`:spawn-opt` - options used to spawn the gen-server process (see
  `process/spawn-opt`)

Returns:
`[:ok pid]` if server started successfully,
`[:error :no-init]` if server implementation doesn't provide `init`
function,
`[:error [:bad-return-value value]]` if `init` returns a bad value,
`[:error reason]` otherwise.

Throws on invalid arguments, or when the name is already registered.
sourceraw docstring

(start-link server)
(start-link server args)
(start-link server args options)
(start-link reg-name server args options)

The same as start-link! but returns async value.

The same as `start-link!` but returns async value.
sourceraw docstring

start-link!cljmacro

(start-link! server)
(start-link! server args)
(start-link! server args options)
(start-link! reg-name server args options)

The same as start! but atomically links caller to started process.

The same as `start!` but atomically links caller to started process.
sourceraw docstring

(start-link-ns)
(start-link-ns args)
(start-link-ns args options)
(start-link-ns reg-name args options)

The same as start-link-ns! but returns async value.

The same as `start-link-ns!` but returns async value.
sourceraw docstring

(start-link-ns!)
(start-link-ns! args)
(start-link-ns! args options)
(start-link-ns! reg-name args options)

The same as start-ns! but atomically links caller to started process.

The same as `start-ns!` but atomically links caller to started
process.
sourceraw docstring

start-nscljmacro

(start-ns)
(start-ns args)
(start-ns args options)
(start-ns reg-name args options)

The same as start-ns! but returns async value.

The same as `start-ns!` but returns async value.
sourceraw docstring

start-ns!cljmacro

(start-ns!)
(start-ns! args)
(start-ns! args options)
(start-ns! reg-name args options)

Starts the server, taking current ns as an implementation source. See start! for more info.

Starts the server, taking current ns as an implementation source.
See `start!` for more info.
sourceraw docstring

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

× close