Giter Club home page Giter Club logo

grpcbin's Introduction

grpcbin

httpbin like for gRPC

CircleCI Docker Build Status Go Report Card GoDoc License

overview

Links

Run server locally

$ docker run -it --rm -p 9000:9000 -p 9001:9001 moul/grpcbin
2017/12/18 14:48:01 listening on :9000 (insecure)
2017/12/18 14:48:01 listening on :9001 (secure)

Example

See examples on a the dedicated repo: grpcbin-example


Golang

package main

import (
	"fmt"
	"log"

	"golang.org/x/net/context"
	"google.golang.org/grpc"

	pb "github.com/moul/pb/grpcbin/go-grpc"
)

func main() {
	// dial
	conn, _ := grpc.Dial("grpcb.in:9000", grpc.WithInsecure())
	defer conn.Close()

	// create client and context
	client := pb.NewGRPCBinClient(conn)
	ctx := context.Background()

	// call DummyUnary
	res, err := client.DummyUnary(ctx, &pb.DummyMessage{
		FString: "hello",
		FInt32:  42,
	})
	if err != nil {
		log.Fatalf("failed to call DummyUnary: %v", err)
	}
	fmt.Println(res)
}

Example with grpcc:

# fetch proto and install tool
$ wget -qN https://github.com/moul/pb/raw/master/grpcbin/grpcbin.proto
$ npm install -g grpcc

# interactive client
$ grpcc -i -p ./grpcbin.proto --address grpcb.in:9000
Connecting to grpcbin.GRPCBin on grpcb.in:9000. Available globals:

  client - the client connection to GRPCBin
    index (EmptyMessage, callback) returns IndexReply
    dummyUnary (DummyMessage, callback) returns DummyMessage
    dummyServerStream (DummyMessage, callback) returns DummyMessage
    dummyClientStream (DummyMessage, callback) returns DummyMessage
    dummyBidirectionalStreamStream (DummyMessage, callback) returns DummyMessage

  printReply - function to easily print a unary call reply (alias: pr)
  streamReply - function to easily print stream call replies (alias: sr)
  createMetadata - convert JS objects into grpc metadata instances (alias: cm)

[email protected]:9000> ^C

# call index endpoint
$ grpcc -i -p ./grpcbin.proto --address grpcb.in:9000 --eval 'client.index({}, printReply)'
{
  "description": "gRPC testing server",
  "endpoints": [
    {
      "path": "index",
      "description": "This endpoint."
    },
    {
      "path": "dummyUnary",
      "description": "Unary endpoint that replies a received DummyMessage."
    },
    [...]
  ]
}

# call dummyUnary with arguments
$ grpcc -i -p ./grpcbin.proto --address grpcb.in:9000 --eval 'client.dummyUnary({f_string:"hello",f_int32:42}, printReply)'
{
  "f_string": "hello",
  "f_strings": [],
  "f_int32": 42,
  "f_int32s": [],
  "f_enum": "ENUM_0",
  "f_enums": [],
  "f_sub": null,
  "f_subs": [],
  "f_bool": false,
  "f_bools": [],
  "f_int64": "0",
  "f_int64s": [],
  "f_bytes": {
    "type": "Buffer",
    "data": []
  },
  "f_bytess": [],
  "f_float": 0,
  "f_floats": []
}

grpcbin's People

Contributors

dependabot[bot] avatar dustbyte avatar gszr avatar moul avatar moul-bot avatar renovate-bot 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

grpcbin's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

docker-compose
.prod/docker-compose.yml
dockerfile
Dockerfile
  • golang 1.18.1-alpine
  • alpine 3.15.1
github-actions
.github/workflows/go.yml
  • actions/checkout v3
  • actions/checkout v3
  • actions/setup-go v2
  • actions/cache v2.1.7
  • goreleaser/goreleaser-action v2.9.1
  • actions/checkout v3
  • golangci/golangci-lint-action v3.1.0
  • actions/checkout v3
  • actions/setup-go v2
  • actions/checkout v3
  • actions/setup-go v2
  • actions/cache v2.1.7
  • codecov/codecov-action v2.1.0
  • actions/checkout v3
  • actions/setup-go v2
  • actions/cache v2.1.7
  • codecov/codecov-action v2.1.0
.github/workflows/pr.yml
  • actions/checkout v3
  • snyk/release-notes-preview v1.6.2
.github/workflows/release.yml
  • actions/checkout v3
  • ghcr.io/codfish/semantic-release-action v1
  • actions/setup-go v2
  • actions/cache v2.1.7
  • goreleaser/goreleaser-action v2.9.1
.github/workflows/semgrep.yml
  • actions/checkout v3
  • ubuntu 20.04
gomod
go.mod
  • go 1.14
  • github.com/grpc-ecosystem/grpc-gateway v1.16.0
  • github.com/moul/pb v0.0.0-20180404114147-54bdd96e6a52@54bdd96e6a52
  • github.com/smartystreets/goconvey v1.7.2
  • golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a@c07d793c2f9a
  • golang.org/x/net v0.0.0-20210610132358-84b48f89b13b@84b48f89b13b
  • google.golang.org/grpc v1.45.0
  • github.com/moul/grpc-gateway v1.9.1-0.20190603230725-390f150e109c@390f150e109c

  • Check this box to trigger a request for Renovate to run again on this repository

Possible typo

secureAddr = flag.String("metrics-addr", ":9001", "The ip:port combination to listen on for secure connections")

I looks like this line:

secureAddr         = flag.String("metrics-addr", ":9001", "The ip:port combination to listen on for secure connections") 

should have "secure-addr" instead of "metrics-addr", but I haven't had time to try it, in case something else depends on this name.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

[IDEA] Support mTLS endpoint

Is your feature request related to a problem? Please describe.
Grpcbin is used in nginx-ingress controller's e2e tests. For fixing a bug related to client-side mTLS authentication it would be helpful to also test this use-case. Therefore a grpc endpoint with mTLS authentication is required.

Describe the solution you'd like
Add a new endpoint (e.g. listening on port 9002) that requires the client to send a certificate during the TLS handshake.

Describe alternatives you've considered

Additional context
PR in nginx-ingress controller that requires a e2e test: kubernetes/ingress-nginx#8188 (comment)

[IDEA] Add the grpc.health.v1.Health service to grpcbin

Is your feature request related to a problem? Please describe.
It would be really nice to be able to use grpc_health_probe against this out-of-the-box.

Describe the solution you'd like
I'd like to be able to spin this up in a cluster and then be able to immediately hit it with grpc-health-probe to determine if it is working as expected.

Describe alternatives you've considered
Nothing really. I am not super familiar with GRPC, but I know that this would be useful to me.

Additional context

grpc_health_probe  -addr 192.168.15.203:9000

error: this server does not implement the grpc health protocol (grpc.health.v1.Health): unknown service grpc.health.v1.Health

[IDEA] Include Apple M1 in releases

Is your feature request related to a problem? Please describe.
I'd like to be able to use grpcbin on Apple M1s without having to use the (sometimes unreliable) translation layer.

Describe the solution you'd like
Ideally I would like "grpcbin_Darwin_arm64.tar.gz" to appear in the releases

Describe alternatives you've considered
I think all this might need is modifications of the goreleaser.yml file. I have given it a look but I don't understand exactly how that yml generates the list of release files that grpcbin has.

Additional context
Goreleaser is supposed to support Apple M1s now: goreleaser/goreleaser#1952

Thank you!

How do I do a healthcheck on grpcbin?

Hi, I want to setup grpcbin inside a testing env using a docker-compose file, along other services.

I would like to know if there's a healthcheck I can use to verify it is actually up and running (and not just that Docker has created the container).

For example, PostgreSQL provides a command-line utility called pg_isready which can be used like so:

services:
  postgresql:
    image: postgres:9.5
    healthcheck:
      interval: 5s
      retries: 10
      test: ["CMD", "pg_isready", "--dbname=my_db", "--username=my_user"]
      timeout: 10s
    restart: on-failure
    stop_signal: SIGKILL

Could something like netcat be used to this effect?

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.