Giter VIP home page Giter VIP logo

grpc-twitter-example's Introduction

grpc-twitter-example

Usage

go get github.com/crowdint/grpc-twitter-example

Run the server:

$ go run server/main.go

Run the client:

$ go run client/main.go

You should see something like:

ID:7 text:"One dog rolled before him, well-nigh slashed in half; but a second had him by the thigh, a third gripped his collar be- hind, and a fourth h" user:<ID:1 >
ID:19 text:"Near it in the field, I remember, were three faint points of light, three telescopic stars infinitely remote, and all around it was the unfa" user:<ID:1 >
ID:1 text:"Near it in the field, I remember, were three faint points of light, three telescopic stars infinitely remote, and all around it was the unfa" user:<ID:1 >
ID:9 text:"The secular cooling that must someday overtake our planet has already gone far indeed with our neighbour.It was at this time that the meetin" user:<ID:1 >
ID:3 text:"The Nellie, a cruising yawl, swung to her anchor without a flutter of the sails, and was at rest.One dog rolled before him, well-nigh slashe" user:<ID:1 >

Got 5 tweets

Web front-end example

This example demonstrates an HTTP front-end, using gin, which connects to the backend Twitter server via grpc.

$ go run frontend/main.go
[GIN-debug] GET   /tweets/:user_id          --> main.func·001 (3 handlers)
[GIN-debug] Listening and serving HTTP on :8080

Now, let's do some twittering!

$ curl -v -d '{"text": "a tweet!", "userId": 1}' -H "Content-Type: application/json" -XPOST http://localhost:8080/tweet/1
[...]
< HTTP/1.1 204 No Content

$ curl http://localhost:8080/tweets/1
[{"text":"a tweet!","user":{"ID":1}}]

grpc-twitter-example's People

Contributors

jpfuentes2 avatar

Watchers

James Cloos 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.