GithubHelp home page GithubHelp logo

benbrittain / rust-xdr Goto Github PK

View Code? Open in Web Editor NEW
29.0 6.0 2.0 113 KB

Generate Rust services from XDR RPC

Home Page: https://tech.okcupid.com/rust-and-rpc-okcupid-hackweek-2017/

License: MIT License

Rust 97.12% Logos 2.88%
rust-services serialization xdr-rpc rust-xdr rust xdr codegen

rust-xdr's Introduction

rust-xdr โ€ƒ Build Status

Converts XDR RPC definitions into Rust Services

Description

rust-xdr is a framework for building Rust services from XDR RPC specifications. This is 2 parts

  • serde_xdr: A serialization/deserialization library implemented ontop of serde. This is a stand-alone crate as well.
  • rust-xdr: A code generator for tokio based services. This depends on serde_xdr for serialization and some of the runtime code.

Setup

Assuming a Rust/Cargo install

$ cargo install xdrgen
$ xdrgen --input <files that define your service or types> --output <directory>

If you are attempting to only use serde_xdr be aware that discrimant unions require extra serde annotations due to limitations of XDR. The examples directory shows how to properly annotate these if you are not codegening off a XDR file (which generates the annotations for you)

See the /examples directory.

Examples

  • /examples/xdr_protocol_example/ shows how the XDR protocol implementation is primarily codegenned off the RPC XDR specification.

  • /examples/rust_xdr_service shows how to implement a service. The main.rs & service.rs are hand written files. /examples/rust_xdr_service/xdrgen is the output directory of xdrgen.

    cargo run --bin rust-xdr -- -i examples/example_prot.v --output examples/service_example/xdrgen
    

Background

Built primarily during OkCupid Hack Week 2017, the goal of the project was to Proof Of Concept standing up Rust services that could easily interop with our existing C++ ones. Beyond building a typesafe (de)serialization library, we also wanted to automatically generate the the whole service, except for the implementation specific details for an RPC call.

Future Work

  • Make serde_xdr a stand-alone crate
  • Serialization of Option<> types as discriminant unions
  • Prevent consumption of bytes in too small of packets
  • OkCupid specific complilation flag for non-standard tweaks
  • PoC client implementation
  • Improve Error messages
  • Implement more XDR rejection responses
  • Test Suite

Contacts

Please file a github issue if you experience any problems

Specifications Implemented

rust-xdr's People

Contributors

benbrittain avatar brendon-scheinman-okcupid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

icodein jordilin

rust-xdr's Issues

Upgrade to newer Rust?

Hi there,

I have been trying to use this PoC code to generate some functioning code but since the blog post was written in 2017 most of the Rust ecosystem has changed and libraries it relied have evolved significantly (futures/tokio). So nothing works with an up to date Rust.

I am wondering what it would take to port some of the code to the newer APIs as I am interested in using Rust for a PoC with XDR RPC.

Thanks!

Thomas

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.