Liking cljdoc? Tell your friends :D

clj-grpc.context

What a handler can know about the call it is serving, read from grpc's own io.grpc.Context — the one grpc attaches around every callback of a call, on the virtual-thread executor and on :direct alike. No handler signature changes; a handler that wants the peer asks for it:

(fn [req]
  (log/info "hello from" (context/peer) "as" (:user (context/call)))
  ...)

call is the map the server's Clojure interceptors built and enriched — see clj-grpc.interceptor for its keys. It exists whenever at least one Clojure interceptor is in the server's chain; with none, nothing pays for building it and call answers nil. (fn [call next] (next call)) is the whole cost of opting in. deadline and cancelled? come straight from grpc's context and work either way.

The Context is a ThreadLocal, attached by grpc on the thread that runs the callback. A thread the handler starts itself does not inherit it: wrap the work with (.wrap (Context/current) f) before handing it over, or read what is needed first and pass it along.

What a handler can know about the call it is serving, read from grpc's own
io.grpc.Context — the one grpc attaches around every callback of a call, on
the virtual-thread executor and on :direct alike. No handler signature
changes; a handler that wants the peer asks for it:

    (fn [req]
      (log/info "hello from" (context/peer) "as" (:user (context/call)))
      ...)

`call` is the map the server's Clojure interceptors built and enriched —
see clj-grpc.interceptor for its keys. It exists whenever at least one
Clojure interceptor is in the server's chain; with none, nothing pays for
building it and `call` answers nil. `(fn [call next] (next call))` is the
whole cost of opting in. `deadline` and `cancelled?` come straight from
grpc's context and work either way.

The Context is a ThreadLocal, attached by grpc on the thread that runs the
callback. A thread the handler starts itself does not inherit it: wrap the
work with `(.wrap (Context/current) f)` before handing it over, or read what
is needed first and pass it along.
raw docstring

authorityclj

(authority)

The :authority the client sent, or nil.

The :authority the client sent, or nil.
sourceraw docstring

callclj

(call)

The call map, or nil outside a call or when no Clojure interceptor is installed.

The call map, or nil outside a call or when no Clojure interceptor is
installed.
sourceraw docstring

cancelled?clj

(cancelled?)

Whether the call has been cancelled — by the client, or by its deadline. From grpc's context; needs no interceptor. A long handler polls this to stop working for nobody.

Whether the call has been cancelled — by the client, or by its deadline.
From grpc's context; needs no interceptor. A long handler polls this to
stop working for nobody.
sourceraw docstring

deadlineclj

(deadline)

The call's io.grpc.Deadline, or nil when the client set none. From grpc's context; needs no interceptor.

The call's io.grpc.Deadline, or nil when the client set none. From grpc's
context; needs no interceptor.
sourceraw docstring

(header name)

The last value of one request header, or nil.

The last value of one request header, or nil.
sourceraw docstring

headersclj

(headers)

The request headers, an io.grpc.Metadata — read with clj-grpc.metadata.

The request headers, an io.grpc.Metadata — read with clj-grpc.metadata.
sourceraw docstring

methodclj

(method)

The method's kebab key, :say-hello — the same key as the handlers map.

The method's kebab key, :say-hello — the same key as the handlers map.
sourceraw docstring

peerclj

(peer)

The client's java.net.SocketAddress, or nil when the transport has none.

The client's java.net.SocketAddress, or nil when the transport has none.
sourceraw docstring

serviceclj

(service)

The fully qualified service name, "acme.greeter.Greeter".

The fully qualified service name, "acme.greeter.Greeter".
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close