thrift-clj.core

Thrift/Clojure Integration

->clj

(->clj v)

->thrift

(->thrift v)

blocking-server-transport

(blocking-server-transport port {:keys [bind client-timeout]})
Create blocking server transport on the given port.

connect!

(connect! client-class transport & {:keys [protocol]})
Create new Client of the given Class that connects to the given
service.

defservice

macro

(defservice id service-cls & implementation)
Define var containing the service.

disconnect!

(disconnect! client)
Close Client Transport.

fast-framed

(fast-framed t & {:keys [max-frame-length initial-buffer-size]})
Wrap transport with fast framed transport (compatible with `framed`, but using
persistent byte buffers).

framed

(framed t & {:keys [max-frame-length]})
Wrap transport with framed transport (prefixes messages with 4 byte frame size).

http

(http url & {:keys [connect-timeout read-timeout custom-headers]})
Create HTTP transport.

import

macro

(import & specs)

import-all

macro

(import-all & packages)
Load all Thrift Entities in the given packages.

import-all-clients

macro

(import-all-clients & packages)
Import all services that reside in a package with one of the given prefixes.

import-all-services

macro

(import-all-services & packages)
Import all services that reside in a package with one of the given prefixes.

import-all-types

macro

(import-all-types & packages)
Import all types that reside in a package with one of the given prefixes.

import-clients

macro

(import-clients & services)
Import the given Thrift Clients making them accessible via `defservice`.
There are three types of specification formats:

- `package.Class`: load exactly this client, using the name `Class`
- `[package Class1 Class2 ...]`: load the given client from the package, using class names
  as type names
- `[package.Class :as N]`: load the given client, using the name `N`

import-iface

macro

(import-iface & services)
Import the given Thrift Iface without creating Services/Clients to handle it.

import-services

macro

(import-services & services)
Import the given Thrift Services making them accessible via `defservice`.
There are three types of specification formats:

- `package.Class`: load exactly this service, using the name `Class`
- `[package Class1 Class2 ...]`: load the given services from the package, using class names
  as type names
- `[package.Class :as N]`: load the given service, using the name `N`

import-types

macro

(import-types & types)
Import the given Thrift Types making them accessible as Clojure Types of the same name.

multi-threaded-server

(multi-threaded-server iface port & opts)
Create multi-threaded Server using the given Iface Implementation.

nonblocking-server

(nonblocking-server iface port & opts)
Create non-blocking Server using the given Iface Implementation.

nonblocking-server-transport

(nonblocking-server-transport port {:keys [bind client-timeout]})
Create non-blocking server transport on the given port.

serve!

(serve! server)
Start Server in a new Thread. Returns the Server.

serve-and-block!

(serve-and-block! server)
Start Server, blocking the current Thread indefinitely.

service

macro

(service service-cls & implementation)
Implement the given, previously imported Service.

single-threaded-server

(single-threaded-server iface port & opts)
Create single-threaded Server using the given Iface Implementation.

stop!

(stop! server)
Stop the given Server. Returns the Server.

streams

(streams in out)
Create IOStream transport.

tcp

(tcp port)(tcp host port)
Create TCP transport.

tcp-async

(tcp-async port)(tcp-async host port)
Create non-blocking TCP transport.

throw

macro

(throw ex & args)
Throw Exception. May take the Clojure representation of a Thrift Exception.

try

macro

(try & forms)
Try executing the given Forms catching Exceptions that can be identified by their
Clojure equivalent.