Giter VIP home page Giter VIP logo

protobuf's Introduction

protobuf - Rendering protobuf files

This repository is associated with a blog post. Please see the post for some background. Here you'll find a Makefile, script, and some example configurations for using prototool to render gRPC protobuf files into separate repositories for different languages (go, typescript, and php).

Setup

  1. Be sure to have docker running and git, curl, and jq available.
  2. Create a personal access token for accessing github and set a GITHUB_TOKEN environment variable. This is required for creating rendered code github repos.
  3. Clone/fork this repo or simply copy the desired files (Makefile, etc.)
  4. Create a PACKAGE_PREFIX (typically your company name) directory for your protobuf definitions and then a subdirectory (PACKAGE_PREFIX/service) for each service. In this repo, PACKAGE_PREFIX=caseylucas.
  5. Modify rendered_repos.mk to suit your service names and desired language renderings.

Use

Run make to show useful make targets. Ex:

Make targets:
- generate: Runs prototool in order to validate / lint all *.proto files
- repos:    Create required protobuf-* github repos
- diff:     Show diff of *generated* code. Does not commit changes - just shows diff
- commit:   Commits (and pushes) generated code (NOT *.proto files)
- clean:    Cleans up intermediate files
- help:     Print this help

When adding a *new* folder, you'll need to edit rendered_repos.mk and add to the REPOS variable. Be sure to add
a protobuf-X-L for every X service with desired language L.

Typically you can use 'make generate' while you are working issues out.  Then run 'make diff' to view the
rendered code changes. Finally run 'make commit' to commit/push rendered code changes.

New Service

If you are defining a new service, you'll need to:

  1. Create the new protobuf file(s) in PACKAGE_PREFIX/SERVICE directory.
  2. Add desired renderings (ex: protobuf-SERVICE-go and/or protobuf-SERVICE-ts) to rendered_repos.mk.
  3. Run make repos to automatically create the github projects.

Protobuf Modifications

When creating new service definitions or altering existing ones, you'll typically run

make generate

to generate and lint protobuf files. This is typically an iterative process. Nothing will be committed when running make generate.

After you're happy with the protobuf modifications, you can push them to the rendered repos by running:

make commit

If you want to see differences in rendered code before committing, you can run:

make diff

More advanced cases

You may need to modify prototool.yaml to suit your needs, especially if you have inter-service dependencies. See comments in prototool.yaml for more info.

protobuf's People

Contributors

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