Coder Social home page Coder Social logo

eze-rpc's Introduction

Eze RPC

Is a simple RPC library for Golang, which uses binary encoding/decoding based on a DSL for type safety.

Eze uses code generation to generate the boilerplate code.

This project is purely for a "fun" because I'm sick of gRPC, and am imagining a world where there's something easier to use. So... don't use it in production. If you do, then it's your own silly fault if something goes horribly wrong.

What's funny is, it basically doesn't solve any problem that gRPC has, other than being smaller. But it's smaller because it barely functions. But it killed a few hours, and who knows, maybe there's enough other people out there who CBA with gRPC anymore, that this could take off and actual adults could take over the development of this.

Installation

$ go install github.com/EwanValentine/eze-rpc

Usage

Define an Eze schema

package users

service UserService {
	GetUser(request: GetUserRequest): User
	CreateUser(request: CreateUserRequest): User
}

struct CreateUserRequest {
	Name: String
}

struct User {
	ID: String
	Name: String
}

struct GetUserRequest {
	ID: String
}

Run the code generate command

eze generate --input=example.eze --output=.

Implement the generated interface

type UserService struct{}

func (s *UserService) GetUser(user *users.GetUserRequest) (*users.User, error) {
	return &users.User{
		ID:   user.ID,
		Name: "Ewan",
	}, nil
}

func (s *UserService) CreateUser(user *users.CreateUserRequest) (*users.User, error) {
	return &users.User{
		ID:   "123",
		Name: user.Name,
	}, nil
}

Register the server

srv := users.NewServer()
srv.RegisterService("UserService", &UserService{})
if err := srv.Serve(":8080"); err != nil {
    panic(err)
}

Call the server

getConnection := users.NewConnection(":8080")

client := users.NewUserServiceClient(getConnection)
response, err := client.GetUser(&users.GetUserRequest{
    ID: "123",
})
if err != nil {
    log.Panic(err)
}

fmt.Println(response.Name)

createResponse, err := client.CreateUser(&users.CreateUserRequest{
    Name: "Ewan",
})
if err != nil {
    log.Panic(err)
}

fmt.Println(createResponse.ID)

eze-rpc's People

Contributors

ewanvalentine avatar

Watchers

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