All Projects → grpc-ecosystem → Polyglot

grpc-ecosystem / Polyglot

Licence: other
A universal grpc command line client

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Polyglot

Protobuf
[Looking for new ownership] Protocol Buffers for Go with Gadgets
Stars: ✭ 4,998 (+924.18%)
Mutual labels:  grpc, protobuf
Rejoiner
Generates a unified GraphQL schema from gRPC microservices and other Protobuf sources
Stars: ✭ 3,432 (+603.28%)
Mutual labels:  grpc, protobuf
Yarpc Go
A message passing platform for Go
Stars: ✭ 285 (-41.6%)
Mutual labels:  grpc, protobuf
grpc-spring-security-demo
Spring Boot-based gRPC server with gRPC endpoints secured by Spring Security
Stars: ✭ 50 (-89.75%)
Mutual labels:  protobuf, grpc
Kroto Plus
gRPC Kotlin Coroutines, Protobuf DSL, Scripting for Protoc
Stars: ✭ 400 (-18.03%)
Mutual labels:  grpc, protobuf
gruf-demo
A demonstration Rails application utilizing gruf, a gRPC Rails framework.
Stars: ✭ 42 (-91.39%)
Mutual labels:  protobuf, grpc
Kocircuit
Ko: A generic type-safe language for concurrent, stateful, deadlock-free systems and protocol manipulations
Stars: ✭ 305 (-37.5%)
Mutual labels:  grpc, protobuf
grpcman
A grpc testing tool based on Electron & Vue.js & Element-UI
Stars: ✭ 22 (-95.49%)
Mutual labels:  protobuf, grpc
Protoactor Go
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
Stars: ✭ 3,934 (+706.15%)
Mutual labels:  grpc, protobuf
Grpc Example
An example of using Go gRPC and tools from the greater gRPC ecosystem together with the GoGo Protobuf Project.
Stars: ✭ 352 (-27.87%)
Mutual labels:  grpc, protobuf
docker-protobuf
An all-inclusive protoc Docker image
Stars: ✭ 105 (-78.48%)
Mutual labels:  protobuf, grpc
Spring boot
Spring Boot 使用总结 和 demo。 如果您觉得本代码对您有所帮助,请点击页面右上方"Star"
Stars: ✭ 431 (-11.68%)
Mutual labels:  grpc, protobuf
xrgrpc
gRPC library for Cisco IOS XR
Stars: ✭ 40 (-91.8%)
Mutual labels:  protobuf, grpc
Dog
A command-line DNS client.
Stars: ✭ 3,623 (+642.42%)
Mutual labels:  command-line, client
api
Temporal gRPC API and proto files
Stars: ✭ 25 (-94.88%)
Mutual labels:  protobuf, grpc
Flatbuffers
FlatBuffers: Memory Efficient Serialization Library
Stars: ✭ 17,180 (+3420.49%)
Mutual labels:  grpc, protobuf
vtprotobuf
A Protocol Buffers compiler that generates optimized marshaling & unmarshaling Go code for ProtoBuf APIv2
Stars: ✭ 418 (-14.34%)
Mutual labels:  protobuf, grpc
tsrpc
A TypeScript RPC framework, with runtime type checking and serialization, support both HTTP and WebSocket. It is very suitable for website / APP / games, and absolutely comfortable to full-stack TypeScript developers.
Stars: ✭ 866 (+77.46%)
Mutual labels:  protobuf, grpc
Ts Proto
An idiomatic protobuf generator for TypeScript
Stars: ✭ 340 (-30.33%)
Mutual labels:  grpc, protobuf
Gruf
gRPC Ruby Framework
Stars: ✭ 411 (-15.78%)
Mutual labels:  grpc, protobuf

Polyglot - a universal grpc command line client

Build Status

Polyglot is a grpc client which can talk to any grpc server. In order to make a call, the following are required:

  • A compiled Polyglot binary,
  • the .proto files for the service or grpc reflection enabled on the remote server,
  • and a request proto instance in text format.

In particular, it is not necessary to generate grpc classes for the service or to compile the protos into the Polyglot binary.

Features

  • Supports unary, client streaming, server streaming, and bidi streaming rpcs.
  • Runs on Windows, Mac and Linux.
  • Parses proto files at runtime to discover services. Supports pretty-printing discovered services.
  • Can discover services by reflection if the remote server has reflection enabled
  • Supports authentication via oauth.
  • Accepts request protos through stdin and can output responses to stdout to allow chaining.
  • Supports plain text connections as well as TLS.
  • Supports passing custom grpc metadata over the command line.
  • Supports all protobuf well-known-types, including fields of type "Any".

Usage

Requirements

All you need to run Polyglot is a Java runtime. Binaries for Mac, Linux, and Windows are available from the releases page.

Making a grpc request

The "Hello World" of using Polyglot is to make an rpc call. This can be done using call command as follows:

$ echo <json-request> | java -jar polyglot.jar \
    --proto_discovery_root=<path> \
    call \
    --endpoint=<host>:<port> \
    --full_method=<some.package.Service/doSomething>

For stream requests double newlines \n\n are used to separate your json requests as follows:

$ echo '<json-request-1> \n\n <json-request-2> ... \n\n <json-request-n>' | java -jar polyglot.jar \
    --proto_discovery_root=<path> \
    call \
    --endpoint=<host>:<port> \
    --full_method=<some.package.Service/doSomething>  

For more invocation examples, see the examples directory.

Server reflection

If the remote server has reflection enabled, there is no need to pass the proto files to Polyglot. The example invocation above then becomes:

$ echo <json-request> | java -jar polyglot.jar \
    call \
    --endpoint=<host>:<port> \
    --full_method=<some.package.Service/doSomething>

Bu default, Polyglot always tries to use reflection before compiling local protos. Reflection can be turned off explicitly by setting the flag --use_reflection=false.

Configuration (optional)

Some of the features of Polyglot (such as Oauth, see below) require some configuration. Moreover, that sort of configuration tends to remain identical across multiple Polyglot runs. In order to improve usability, Polyglot supports loading a configuration set from a file at runtime. This configuration set can contain multiple named Configuration objects (schema defined here). An example configuration could look like this:

{
  "configurations": [
    {
      "name": "production",
      "call_config": {
        "use_tls": "true",
        "oauth_config": {
          "refresh_token_credentials": {
            "token_endpoint_url": "https://auth.example.com/token",
            "client": {
                "id": "example_id",
                "secret": "example_secret"
            },
            "refresh_token_path": "/path/to/refresh/token"
          }
        }
      },
      "proto_config": {
        "proto_discovery_root": "/home/dave/protos",
        "include_paths": [
          "/home/dave/lib"
        ]
      }
    },
    {
      "name": "staging",
      "call_config": {
        "oauth_config": {
          "refresh_token_credentials": {
            "token_endpoint_url": "https://auth-staging.example.com/token"
          }
        }
      },
      "proto_config": {
        "proto_discovery_root": "/home/dave/staging/protos",
        "include_paths": [
          "/home/dave/staging/lib"
        ]
      }
    }
  ]
}

By default, Polyglot tries to find a config file at $HOME/.polyglot/config.pb.json, but this can be overridden with the --config_set_path flag. By default, Polyglot uses the first configuration in the set, but this can be overridden with the --config_name flag.

The general philosophy is for the configuration to drive Polyglot's behavior and for command line flags to allow selectively overriding parts of the configuration. For a full list of what can be configured, please see config.proto.

Using TLS

Polyglot uses statically linked boringssl libraries under the hood and doesn't require the host machine to have any specific libraries. Whether or not the client uses TLS to talk to the server can be controlled using the --use_tls flag or the corresponding configuration entry.

Polyglot can also do client certificate authentication with the --tls_client_cert_path and --tls_client_key_path flags. If the hostname on the server does not match the endpoint (e.g. connecting to localhost, but the server thinks it's foo.example.com), --tls_client_override_authority=foo.example.com can be used.

Authenticating requests using OAuth

Polyglot has built-in support for authentication of requests using OAuth tokens in two ways:

  • Loading an access token from disk and attaching it to the request.
  • Loading a refresh token from disk, exchanging it for an access token, and attaching the access token to the request.

In order to use this feature, Polyglot needs an OauthConfiguration inside its Configuration. For details on how to populate the OauthConfiguration, please see the documentation of the fields in config.proto.

Listing services

Polyglot supports printing a list of all the discovered services using the list_services command. This command can be invoked as follows:

$ java -jar polyglot.jar \
    --proto_discovery_root=<path> \
    list_services

The printed services can be filtered using --service_filter=<service_name> or --method_filter=<method_name>, and the --with_message flag can be used to also print the exact format of the requests.

Custom metadata

It is possible to add custom grpc metadata to calls made using Polyglot by setting the --metadata=key1:value1,key2:value2 flag.

Configuring logs

Polyglot uses the slf4j logging framework with the org.slf4j.impl.SimpleLogger implementation. It also redirects grpc's JUL logs to slf4j. To change the default log level, specify the org.slf4j.simpleLogger.defaultLogLevel JVM argument, e.g., by passing the argument -Dorg.slf4j.simpleLogger.defaultLogLevel=debug.

Build requirements

In order to build Polyglot from source, you will need:

Building a binary

$ bazel build src/main/java/me/dinowernli/grpc/polyglot

After calling this, you should have a fresh binary at:

./bazel-bin/src/main/java/me/dinowernli/grpc/polyglot

If you would like to build a deployable (fat) jar, run:

$ bazel build src/main/java/me/dinowernli/grpc/polyglot:polyglot_deploy.jar

Running the examples

Example invocations can be found in the examples directory. In order to run a simple rpc call, invoke run-server.sh followed by (in a different terminal) call-command-example.sh.

Building and running tests

$ bazel test //src/...

Main contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].