An annotation-based Java library for creating Thrift serializable types and services.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
drift-api [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-client [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-codec [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-idl-generator [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-integration-tests [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-javadoc [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-maven-plugin [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-protocol [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-server [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-transport-apache [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-transport-netty [maven-release-plugin] prepare for next development iteration Feb 22, 2019
drift-transport-spi [maven-release-plugin] prepare for next development iteration Feb 22, 2019
src/spotbugs Update to Airbase 79 Mar 27, 2018
.gitignore Remove dependency-reduced-pom.xml Jan 15, 2013
.travis.yml Add Travis config for Java 9 Dec 17, 2017
README.md
license.txt Change to ASL license headers Jul 10, 2012
notice.md Add drift-core to replace libthrift Aug 11, 2017
pom.xml [maven-release-plugin] prepare for next development iteration Feb 22, 2019

README.md

Drift

Maven Central Build Status

Drift is an easy-to-use, annotation-based Java library for creating Thrift clients and serializable types. The client library is similar to JAX-RS (HTTP Rest) and the serialization library is similar to JaxB (XML) and Jackson (JSON), but for Thrift.

Example

The following interface defines a client for a Scribe server:

@ThriftService
public interface Scribe
{
    @ThriftMethod
    ResultCode log(List<LogEntry> messages);
}

The log method above uses the LogEntry Thrift struct which is defined as follows:

@ThriftStruct
public class LogEntry
{
    private final String category;
    private final String message;

    @ThriftConstructor
    public LogEntry(String category, String message)
    {
        this.category = category;
        this.message = message;
    }

    @ThriftField(1)
    public String getCategory()
    {
        return category;
    }

    @ThriftField(2)
    public String getMessage()
    {
        return message;
    }
}

An instance of the Scribe client can be created using a DriftClientFactory:

// create a client
Scribe scribe = clientFactory.createDriftClient(Scribe.class);

// use client
scribe.log(Arrays.asList(new LogEntry("category", "message")));

Detailed Documentation