GithubHelp home page GithubHelp logo

hartl3y94 / hsthrift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebookincubator/hsthrift

0.0 0.0 0.0 1.32 MB

The Haskell Thrift Compiler. This is an implementation of the Thrift spec that generates code in Haskell. It depends on the fbthrift project for the implementation of the underlying transport.

License: Other

Makefile 0.19% Haskell 50.27% C++ 6.40% C 0.52% Lex 0.49% Yacc 1.41% Shell 0.25% Thrift 14.98% Dockerfile 0.07% CMake 4.69% Python 20.72%

hsthrift's Introduction

The Haskell Thrift Compiler

Thrift is a serialization and remote procedure call (RPC) framework used for cross-service communication. Most services at Facebook communicate via Thrift because it provides a simple, language-agnostic protocol for communicating with structured data. Thrift can already be used in programming languages such as C++, Python, and Java using fbthrift.

The hsthrift project includes the full collection of tools and libraries for using Thrift in your own Haskell projects. The Haskell Thrift compiler generates the Haskell code needed to communicate with other Thrift services, and the included libraries allow you to build both Thrift clients and servers in Haskell. Haskell Thrift is fully compatible with all other fbthrift languages, so your Haskell project can freely communicate with other services no matter what language they are implemented in.

Note: hsthrift is compatible with fbthrift but not Apache Thrift clients and servers.

hsthrift is licensed under a standard BSD license.

Documentation

Build instructions are below.

To use Thrift, see Getting Started with Thrift in Haskell.

Cabal packages

The repository contains the following packages:

Building and testing

First install all dependencies (see Dependencies section below).

Then, build a local checkout of cabal-install's master branch using commit f5f8d933db229d30e6fc558f5335f0a4e85d7d44 or newer. The aforementioned commit will be available in the 3.6 release of Cabal and cabal-install.

We then use the C++ thrift compiler to generate some files needed to build the Haskell thrift compiler, which we can do immediately afterwards.

$ make thrift-cpp
$ cabal build exe:thrift-compiler

At this point, you should have a working thrift-compiler. You can check that this is indeed the case by running the following command to process many .thrift files used by tests of various packages in this repository with your freshly built compiler:

$ make thrift-hs

Finally, we can issue any cabal build/cabal run/cabal test command to build/run/test a specific component or entire package. For instance, we could test all the packages with:

$ cabal test all

# or, if there's no IPv6 configured on your machine (see below),
# you can borrow the ci configuration or derive your own:
$ cabal test --project-file=ci.cabal.project all

Source distributions

A simple

$ cabal sdist <package name>
# or, to generate all sdists
$ cabal sdist all

will generate source distribution archives under dist-newstyle/sdist/, all named following the fairly common <pkg>-<version>.tar.gz template.

The Github CI actions make use of these commands to build and test the packages from source distributions.

IPv4 vs IPv6

Some tests bring up thrift clients and servers on localhost, but designate the said localhost differently depending on whether the code is built to use ::1 (IPv6) or 127.0.0.1 (IPv4). This is determined by a tests_use_ipv4 cabal flag in thrift-lib and thrift-server. The Github CI actions turn those flags on as can be seen in the .cabal.project files at the root of this repository, because the Docker environment in which CI actions get executed does not have IPv6 configured.

Dependencies

System dependencies

Debian / Ubuntu

sudo apt install
libgoogle-glog-dev
libgflags-dev
libmysqlclient-dev
bison
flex
ninja-build
cmake
libzstd-dev

(TODO: this list is probably incomplete, please file an issue if you encounter something missing)

Fedora

sudo yum install \
     openssl-devel \
     libevent-devel \
     double-conversion-devel \
     boost-devel \
     cmake \
     ninja-build \
     glog-devel \
     gflags-devel \
     gmock-devel \
     bison \
     flex \
     libatomic \
     libsodium \
     libzstd-devel \
     pcre-devel \
     ncurses-devel \
     fmt-devel \
     gmp-devel \
     community-mysql-devel

Also you may need:

export LD_LIBRARY_PATH=/usr/local/lib:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Other dependencies

hsthrift also depends on:

These are typically not packaged by Linux distributions, so we have to build and install them manually from their github repos. We've provided a script in the hsthrift repository, new_install_deps.sh to do that. Run the following commands to clone the repos and build and install the dependencies (pass e.g. --threads 8 to build in parallel. Default is 4):

./new_install_deps.sh

Set your env variables to pick up the new libraries and binaries:

export LD_LIBRARY_PATH=$HOME/.hsthrift/lib:
export PKG_CONFIG_PATH=$HOME/.hsthrift/lib/pkgconfig
export PATH=$PATH:$HOME/.hsthrift/bin
make all

and test the installation with:

cabal test all

hsthrift's People

Contributors

alpmestan avatar andriigrynenko avatar avasylev avatar bigfootjon avatar binhuang00 avatar chriskuklewicz avatar colavitam avatar cpluss avatar dgrnbrg-meta avatar dimitribouche avatar donsbot avatar facebook-github-bot avatar helfper avatar iahs avatar joncoens avatar josefs avatar kmancini avatar kostmo avatar malmerey avatar meteorfox avatar pepeiborra avatar praihan avatar quark-zju avatar r-barnes avatar rayshih avatar sethdelliott avatar simonmar avatar snarkmaster avatar vitaut avatar watashi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.