Git Product home page Git Product logo

jute's Introduction

Jute

godoc build coverage license

Jute is a implementation of Apache Zookeepers's jute IDL and generation code written in pure Go. This module includes a parser to real the jute DDL file into an AST and then a generator to generate serialization/deserialization code.

Jute started out as a serialization format for Hadoop and is no longer being used (Hadoop moved to Apache Avro as such only Zookeeper seems to be using it.

Note: There may be work in future versions of Zookeeper to use a different format as well (see: ZOOKEEPER-102).

Each jute module is mapped to a Go package with each class getting it's own go file.

Usage

$ go get github.com/go-zookeeper/jute/cmd/jutec
$ jutec input.jute

You can control the output folder structure with the go.moduleMap and go.prefix options.

go.prefix can control the import prefix for the generated packages. Packages generated will append this prefix to the package names, however the prefix is not used in the generated directories.

go.moduleMap uses regular expressions to rewrite module names to go packages names. The format for this option is <regexp match>:<regexp replacement>. If the replacement string is - then the module is skipped and no code is generated. All moduleMaps are processed in order. Unlike go.prefix any mapped modules will be represented in the generated directory structure for the packages.

Example

This command will ignore the org.apache.zookeeper.server.* and the org.apache.zookeeper.txn modules. All other modules matching org.apache.zookeeper will drop the org.apache.zookeeper prefix. All generated modules will have the prefix github.com/go-zookeeper/zk/internal appended to it (for imports) but it won't be incuded in the directories.

$ jutec \
    -go.moduleMap=org.apache.zookeeper.server:- \
    -go.moduleMap=org.apache.zookeeper.txn:- \
    -go.moduleMap=org.apache.zookeeper: \
    -go.prefix=github.com/go-zookeeper/zk/internal \
    testdata/zookeeper.jute

Caveats

This is pretty experimental code. There are a lot of error checking missing, imports are not implemented and there are probably some pretty bad bugs. You have been warned!

TODO

Parser

  • Check for duplicate field names
  • Validate external module class fields
  • Block reserved keywords

Generator

  • Support imported jute files

jute's People

Contributors

apantina-zz avatar nemith avatar pmazzini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jute's Issues

references to other structs

I think that to be consistent with C++ we should not use references to other jute defined class/struct.

Example C++:

        class ACL : public ::hadoop::Record {
          private:
          int32_t perms;
          org::apache::zookeeper::data::Id id;

Example Go:

type ACL struct {
	Perms int32 // perms
	Id    *Id   // id
}

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.