A gRPC server over non-shaded Netty, from a service value and plain functions.
(-> (server {:services [{:service greeter/Greeter
:handlers {:say-hello (fn [req] ...)}}]
:port 8080})
start)
Handler shapes, by method type — requests and responses are protobuf Messages; compose with the generated proto->X / X->proto at the edges:
:unary (fn [request] response) :server-streaming (fn [request send!]) — call send! per message, return to complete :client-streaming (fn [respond!]) -> {:on-next (fn [msg]) ... :on-complete (fn [])} — call respond! once with the response, usually from :on-complete :bidi (fn [send! close!]) -> {:on-next ... :on-complete ...} — send! per message, close! to finish
A thrown exception in any handler becomes Status/INTERNAL with the message attached; throw an io.grpc.StatusRuntimeException to control the status.
opts: :services [{:service Service :handlers {kebab-key fn}} ...] :address SocketAddress | port | {:unix path} | "unix:///path" :port used when :address is absent; default $PORT, else 8080 — the Knative convention :transport :auto (default) | :epoll | :nio — UDS requires epoll :health true (default) — grpc health service, wired for probes :reflection false (default) — server reflection (v1) :executor java.util.concurrent.Executor for handlers :interceptors [io.grpc.ServerInterceptor ...] :tls {:cert-chain File/path :private-key File/path}; absent means h2c (plaintext HTTP/2), which is what Knative speaks
A gRPC server over non-shaded Netty, from a service value and plain
functions.
(-> (server {:services [{:service greeter/Greeter
:handlers {:say-hello (fn [req] ...)}}]
:port 8080})
start)
Handler shapes, by method type — requests and responses are protobuf
Messages; compose with the generated proto->X / X->proto at the edges:
:unary (fn [request] response)
:server-streaming (fn [request send!]) — call send! per message, return to
complete
:client-streaming (fn [respond!]) -> {:on-next (fn [msg]) ...
:on-complete (fn [])}
— call respond! once with the response, usually from
:on-complete
:bidi (fn [send! close!]) -> {:on-next ... :on-complete ...}
— send! per message, close! to finish
A thrown exception in any handler becomes Status/INTERNAL with the message
attached; throw an io.grpc.StatusRuntimeException to control the status.
opts:
:services [{:service Service :handlers {kebab-key fn}} ...]
:address SocketAddress | port | {:unix path} | "unix:///path"
:port used when :address is absent; default $PORT, else 8080 —
the Knative convention
:transport :auto (default) | :epoll | :nio — UDS requires epoll
:health true (default) — grpc health service, wired for probes
:reflection false (default) — server reflection (v1)
:executor java.util.concurrent.Executor for handlers
:interceptors [io.grpc.ServerInterceptor ...]
:tls {:cert-chain File/path :private-key File/path}; absent means
h2c (plaintext HTTP/2), which is what Knative speaks(server {:keys [services address port transport health reflection executor
interceptors tls]
:or {health true}})Build (without starting) a server. Returns {:server io.grpc.Server :health HealthStatusManager-or-nil :address SocketAddress}.
Build (without starting) a server. Returns {:server io.grpc.Server
:health HealthStatusManager-or-nil :address SocketAddress}.(service-definition {:keys [service handlers]})A dynamic ServerServiceDefinition from a service value and a handlers map. Methods without a handler are omitted and answer UNIMPLEMENTED, which is gRPC's own semantics for them.
A dynamic ServerServiceDefinition from a service value and a handlers map. Methods without a handler are omitted and answer UNIMPLEMENTED, which is gRPC's own semantics for them.
(shutdown s)(shutdown {:keys [server] :as s} {:keys [grace-ms]})Graceful by default; :grace-ms bounds the drain, then forces.
Graceful by default; :grace-ms bounds the drain, then forces.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |