Skip to content
/ drift Public

An annotation-based Java library for creating Thrift serializable types and services.

License

Notifications You must be signed in to change notification settings

airlift/drift

Folders and files

NameName
Last commit message
Last commit date
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
May 8, 2024
Jan 15, 2013
May 7, 2018
Jul 10, 2012
Aug 11, 2017
May 8, 2024

Repository files navigation

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

About

An annotation-based Java library for creating Thrift serializable types and services.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages