This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Protocol Overview
xsc edited this page Apr 20, 2013
·
5 revisions
Protocols include:
-
:binary
: The Thrift binary protocol. Options:-
:strict-read
: require a version number at the beginning of each incoming message -
:strict-write
: place a version number at the beginning of each outgoing message -
:read-length
: maximum number of bytes per message
-
-
:compact
: The Thrift compact protocol. Options:-
:max-network-bytes
: the maximum number of bytes to read for variable-length fields
-
-
:tuple
: The Thrift tuple protocol (an extension of:compact
). No options. -
:json
: The Thrift JSON protocol. No options. -
:simple-json
: The Thrift simple JSON protocol. This is write-only!
For servers and clients you can usually either use the protocol ID by itself or a vector of the ID followed by pairs of options, e.g. [:binary :strict-read true :strict-write true]
.
You can create an instance of org.apache.thrift.protocol.TProtocolFactory
using the function thrift-clj.protocol.core/protocol-factory
with a protocol ID and some additional options.
Example:
(require '[thrift-clj.protocol.core :as proto])
(def f (proto/protocol-factory :binary
:strict-read true
:strict-write true))
(def p (.getProtocol f some-transport))
If you want to directly create a protocol (which you probably won't need to), use thrift-clj.protocol.core/protocol
:
(def p (proto/protocol :binary some-transport
:strict-read true
:strict-write true))
You can add your own protocol factories by implementing the multimethod thrift-clj.protocol.core/protocol-factory*
.