Giter VIP home page Giter VIP logo

kameshsampath / grpc-todo-app Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 122 KB

A demo to show how to get started with building Data Streaming API using https://grpc.de) and https://redpanda.com, and how to add analytics using https://snowflake.com e.g. a https://streamlit.io dashboard.

License: MIT License

Go 100.00%
demo-app grpc-client grpc-go grpc-golang grpc-server-streaming protobuf3 redpanda kafka-connector snowflake

grpc-todo-app's Introduction

Get Started with Data Streaming with gRPC

A demo to show how to get started with building Data Streaming API using gRPC. We will use Redpanda as our streaming platform.

Prerequisites

To run the demo you need the following tools on your local machine,

Data Streaming Platform Setup

The entire demo is containerized and all the applications could be started using the Docker compose,

docker compose up -d

The docker compose starts the following services,

  • redpanda-0 - A single node Redpanda server
  • console - The Redpanda console
  • todo-app-server - The Todo Application gRPC server
  • todo-list - The Todo Application client that receives the streaming messages from the gRPC todo-app-server

The Todo application runs with the following environment variables defaults, please change them as needed if you deploy without these defaults.

Todo gRPC Server

# gRPC service port
PORT=9090
# Redpanda Brokers
BROKERS=redpanda-0:9092
# Topic to store the Todo
TOPICS=todo-list
# Running environment, typically used for grpcurl
ENV=dev
# The consumer group used while consuming messages
CONSUMER_GROUP_ID=grpc-todo-app

Todo gRPC Client (Todo List)

SERVICE_ADDRESS=todo-app-server:9090

NOTE:

The individual application binaries for Todo App gRPC Server and Todo App Client are available on the application repo. You can download them and run the application individually.

Interact With Todo Service

List Available Services

grpcurl -plaintext "localhost:$PORT" list

Should return an output like,

grpc.reflection.v1.ServerReflection
grpc.reflection.v1alpha.ServerReflection
todo.Todo

List Service Methods

grpcurl -plaintext "localhost:$PORT" list todo.Todo

It should return the following methods,

todo.Todo.AddTodo
todo.Todo.TodoList

View List of Todo

On a new terminal run the following command to view the list of Todos added by earlier steps,

docker compose logs -f todo-list

The output should be something like,

todo-list  | 2023-12-05T05:20:19.235Z   INFO    client/main.go:44       Task    {"Title": "Finish gRPC Demo README", "Description": "Complete the README update of the gRPC Data Streaming Demo App.", "Completed": false, "Last Updated": "Thursday, 01-Jan-70 00:00:00 UTC", "Partition": 0, "Offset": 0}
todo-list  | 2023-12-05T05:20:19.236Z   INFO    client/main.go:44       Task    {"Title": "Finish gRPC Demo README", "Description": "Complete the README update of the gRPC Data Streaming Demo App.", "Completed": false, "Last Updated": "Thursday, 01-Jan-70 00:00:00 UTC", "Partition": 0, "Offset": 1}

TIP:

You can also use

grpcurl -plaintext "localhost:$PORT" todo.Todo/TodoList

Add a TODO

grpcurl -plaintext -d @ "localhost:$PORT" todo.Todo/AddTodo <<EOM
{
  "task": {
    "title": "Finish gRPC Demo README",
    "description": "Complete the README update of the gRPC Data Streaming Demo App.",
    "completed": false
  }
}
EOM

Once the task is added the terminal running the client should show an output similar to,

{
  "Title": "Finish gRPC Demo README",
  "Description": "Complete the README update of the gRPC Data Streaming Demo App.",
  "Completed": false,
  "Last Updated": "Thursday, 01-Jan-70 00:00:00 UTC",
  "Partition": 0,
  "Offset": 1
}

References

The demo uses the protobuf definitions from https://github.com/kameshsampath/demo-protos

Cleanup

docker compose down

grpc-todo-app's People

Contributors

kameshsampath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.