Code Monkey home page Code Monkey logo

remoto's Introduction

Remoto banner

Remoto

Ultra-simple, fast, complete RPC ecosystem designed for right now.

  • Simple service definitions written in Go (interfaces and structs)
  • Generates servers and clients that makes implementing/consuming easy
  • Generates human-readable code
  • Supports batch requests out of the box
  • Lots of templates to use today
  • Modify templates or write your own

In this document

Introduction

Remoto is an RPC ecosystem and code generation tool. A powerful set of templates and supporting code allows you to quickly spin up RPC services, and consume them with hand crafted client libraries by experts in each particular language.

Who is Remoto for?

Remoto is for teams who want to:

  • Deliver mobile and web RPC services
  • Automate SDK and client library generation
  • Stick with simple and familiar technology

Remoto definition files

Definition files are Go source with .remoto.go file extension.

An example definition looks like this:

package project

// Greeter provides greeting services.
type Greeter interface {
	// Greet generates a greeting.
	Greet(GreetRequest) GreetResponse
}

// GreetRequest is the request for Greeter.GreetRequest.
type GreetRequest struct {
	Name string
}

// GreetResponse is the response for Greeter.GreetRequest.
type GreetResponse struct {
	Greeting string
}
  • package project - package name can group services
  • type ServiceName interface - describes an RPC service
  • Greet(GreetRequest) GreetResponse - service method with request and response objects
  • type GreetRequest struct - describes the request data
  • type GreetResponse struct - describes the response data

Rules

  • Each service is an interface
  • Each method is an endpoint
  • Methods must take a request object as its only argument
  • Methods must return the response object as the result
  • Only a subset of Go types are supported: string, float64, int, bool, and struct types
  • Any arrays (slices) of the supported types are also allowed (e.g. []string, []bool, etc.)
  • Comments describe the services, methods and types
  • Do not import packages (apart from official Remoto ones), instead your definition files should be self contained

Special types

  • Learn more about specially handled types in remototypes.

Tips

  • Avoid importing common types - describe all the required types in a single .remoto.go file

Remoto command

The remoto command can be built into your development pipeline to generate source code from definition files.

usage:
	remoto sub-command

Generate

The generate command generates source code from a given template.

usage:
	remoto generate definition template -o output-file
  • definition - Path to the definition file
  • template - Path to the template to render
  • output-file - Where to save the output (folders will be created and files will be overwritten without warning)

remotohttp

As well as code generation, Remoto ships with a complete HTTP client/server implementation which you can generate from your definition files.

For more information, see the remotohttp documentation.

remoto's People

Contributors

jamesjwarren avatar matryer avatar romanyx 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

remoto's Issues

Clarification of decoder behaviour

In the examples, GreetRequest is a simple struct with a single Name field. I was expecting to send the request as an object

{ "name": "mike" }

But I get the error:

decode json: json: cannot unmarshal object into Go value of type []*simplyProjected.SimpleRequest

If I send it as an array its fine. Is the expected behaviour of the decoder to assume an array of objects?

[{ "name": "mike" }]

https://github.com/machinebox/remoto/blob/master/examples/greeter/server/greeter/server.go#L90

generation failed: undeclared name

Hello,

I tried generating a server with remoto and got an undeclared name error. I reproduced the error with:

remoto generate infoer.remoto.go ~/go/src/github.com/machinebox/remoto/templates/remotohttp/server.go.plush 
parse: conf.Check: io.Reader.go:12:7: undeclared name: Info

With the code here
The Info struct is declared in the same package, but remoto cannot understand/find it.

Am I using this wrong?

install failed

go env

GOARCH="amd64"
GOBIN="/home/wdy/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/wdy/gitlab"
GORACE=""
GOROOT="/home/wdy/go"
GOTOOLDIR="/home/wdy/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build039446685=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

wdy@wdy:~$ go get -u -v github.com/matryer/remoto
github.com/matryer/remoto (download)
github.com/gobuffalo/plush (download)
github.com/gobuffalo/envy (download)
github.com/joho/godotenv (download)
github.com/gobuffalo/github_flavored_markdown (download)
# cd /home/wdy/gitlab/src/github.com/gobuffalo/github_flavored_markdown; git pull --ff-only
From https://github.com/gobuffalo/github_flavored_markdown
 * [new branch]      fix-blackfriday -> origin/fix-blackfriday
 * [new branch]      master          -> origin/master
 * [new tag]         v1.0.0          -> v1.0.0
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package github.com/gobuffalo/github_flavored_markdown: exit status 1
github.com/gobuffalo/tags (download)
github.com/fatih/structs (download)
github.com/pkg/errors (download)
github.com/gobuffalo/uuid (download)
github.com/gobuffalo/validate (download)
github.com/markbates/going (download)
# cd .; git clone https://github.com/markbates/going /home/wdy/gitlab/src/github.com/markbates/going
Cloning into '/home/wdy/gitlab/src/github.com/markbates/going'...
error: Untracked working tree file '.gitignore' would be overwritten by merge.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

package github.com/markbates/going/wait: exit status 128
github.com/markbates/inflect (download)
github.com/serenize/snaker (download)
github.com/spf13/cobra (download)
github.com/spf13/pflag (download)

Typescript client template

I'm interested in generating a typescript client, guessing others might be too. I'm keen to work on the necessary template, has there been any prior work on this?

explicitly disallow imports

for simplicity, a remoto definition file should contain everything required, so no important of other types. We'll encourage copy and paste for completeness.

add LICENSE

Apache for example could be a good choice

console: import fails

Importing the remototypes package fails in the console due to importing issues.

To recreate the problem use the following remoto definition in the console:

package classificationbox

import (
	"github.com/machinebox/remoto/remototypes"
)

You will get error:

4:2: could not import github.com/machinebox/remoto/remototypes (open ./vendor/github.com/machinebox/remoto/remototypes: no such file or directory) 
  • Should it be explicitly handled in generator/importer.go?

Consider adding default templates to cli

(Really excited about this project!)

The idea of being able to use your own templates is neat, however, when starting out it may be easier (and more manageable) to use a default (built-in) template if one is not supplied, at least for the supported server/client: Go and ES6.

I don't want to keep a copy of server.go.plush or client.go.plush within our repo. From day-to-day I'd update the remoto cli (if needed) and use it to generate source code without worrying about templates.

remoto project.remoto.go go-server -o server.go

go-server go-client es6-client etc. otherwise check for the supplied template path.

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.