truss-client-test

module
v0.0.0-...-de9d718 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2016 License: MIT

README

Truss Client Test

This repository hosts two Truss generated services: a generator and a printer. They don't do anything useful. But this was an exercise in connecting two Truss-generated services using the generated HTTP client.

In this case, the Printer service uses the Generator service to get a message based on a name that is provided. The Printer service then decorates the returned message with an exclamation point (just so that the Printer service isn't *only a passthrough).

Notes

Truss generates a HTTP client that cannot reach the server that it attempts to connect to. This happens because on the server side, all the HTTP routes are specified as lowercase, and the client attempts to reach HTTP endpoints that are title-cased. This results in a HTTP 404 being sent back to the client.

I have hand-modified the generated code for the Generator client to address this, so that it attempts to connect to an endpoint with a lowercase path.

To Run

make run

To use:

curl "locahost:11000/print?name=Test"

You should see the message in the JSON response, like so:

➜  printer git:(master) ✗ curl -i "localhost:11000/print?name=Ian%20Molee"
HTTP/1.1 200 OK
Date: Wed, 16 Nov 2016 04:46:01 GMT
Content-Length: 78
Content-Type: text/plain; charset=utf-8

{"message":"Hello, Ian Molee!","generated_at":"Tue Nov 15 20:46:01 PST 2016"}

To Stop

make stop

Directories

Path Synopsis
generator
generator-service
Package generator is a generated protocol buffer package.
Package generator is a generated protocol buffer package.
generator-service/generated/client/grpc
Package grpc provides a gRPC client for the add service.
Package grpc provides a gRPC client for the add service.
generator-service/third_party/googleapis/google/api
Package google_api is a generated protocol buffer package.
Package google_api is a generated protocol buffer package.
printer
printer-service
Package printer is a generated protocol buffer package.
Package printer is a generated protocol buffer package.
printer-service/generated/client/grpc
Package grpc provides a gRPC client for the add service.
Package grpc provides a gRPC client for the add service.
printer-service/third_party/googleapis/google/api
Package google_api is a generated protocol buffer package.
Package google_api is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL