Giter Site home page Giter Site logo

go-xdr's Introduction

An XDR to Go compiler

For Buildbarn Remote Execution we have implemented a userspace NFSv4 server. NFS makes use of XDR (External Data Representation) to describe its wire format. The XDR description for NFSv4 can be found in RFC 7531.

This repository provides a compiler that is capable of converting the XDR description of NFSv4, and other protocols, to Go code. For each data type in the XDR description, a Go language equivalent is created. Each data type in Go implements the io.ReaderFrom and io.WriterTo interfaces, allowing instances of the data type to be deserialized and serialized, respectively.

Furthermore, the XDR to Go compiler is capable of emitting interfaces for ONC RPCv2 ("Sun RPC") program definitions, as described in RFC 5531. A simple RPC server implementation is also provided.

Grammar accepted by the XDR to Go compiler

The grammar supported by the XDR to Go compiler should match with what's described in RFCs 4506 and 5531. Minor extensions have been made:

  • Every XDR description file should start with a package statement, containing the full name of the resulting Go package.
  • After the package statement, there may be import statements. These can be used to express dependencies between XDR description files, similar to Protobuf schema files can also depend on each other.
  • As XDR's string type only permits ASCII characters, an utf8string type has been added for UTF-8.

Please refer to the pkg/compiler/tests and pkg/protocols directories for examples.

Bundled protocols

The pkg/protocols directory includes pregenerated copies of commonly used XDR descriptions, such as ONC RPCv2 and NFSv4. Also included is a copy of the NFS mount arguments protocol used by macOS.

Why not use...

There are already a couple of other XDR libraries for Go. Examples include:

All of these were considered, but turned out to be unsuitable for Buildbarn's use case for one or more of the following reasons:

  • They depend on runtime reflection,
  • They don't include an XDR description compiler, requiring definitions to be translated to Go code manually,
  • They don't support ONC RPCv2 program definitions,
  • They can't compile XDR descriptions that depend on definitions coming from other protocols (e.g., NFSv4's dependency on ONC RPCv2).

License

The XDR to Go compiler is Apache v2 licensed, just like other Buildbarn components. Protocols that are bundled under pkg/protocols are subject to their original license terms.

go-xdr's People

Contributors

edschouten 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.