Building a Chat app with Docker and gRPC

in #utopian-io6 years ago

golang.jpg

Repository

https://github.com/golang/go

What Will I Learn?

  • You will learn how to add a Streaming Service to a gRPC
  • You will learn how to put a Go Service in a Docker Container
  • You will learn how to model a Chat application
  • You will learn about WaitGroups and Go Routines
  • You will learn how to block returns with channels

Requirements

System Requirements:

Operating System:
  • FreeBSD 10.3 or later
  • Linux 2.6.23 or later with glibc
  • macOS 10.10 or later
  • Windows 7, Server 2008R2 or later

Required Knowledge

  • An understanding of APIs
  • A basic understanding of Go
  • Some understanding of micro service architecture.

Resources for Go and this Project:

Credits/Sources:

Difficulty

  • Advanced

Description

In this Go video tutorial, we take a look at a more advanced gRPC example in the form of a simple Console Chat application. This gRPC Chat Application makes use of a stream to push messages from the server to the clients. We also take the server and put it into a Docker Container to make it easy for deployment and for containerization. The application makes use of many goroutines and a WaitGroup to synchronize these goroutines.

Streaming from the Server to the Client with gRPC

Like any RPC system, gRPC is primarily focused around allowing methods to be called remotely. To facilitate this functionality, there are four primary types of RPCs that can be specified with gRPC. In the prior tutorial, we took a look at unary RPC services exclusively. These are the most basic forms of RPC services that can be defined with gRPC. In this tutorial however, we add on a server streaming RPC service in conjunction with a unary RPC service.

broad-service.png

In this image, are the two main services for our Chat Application. The CreateStream service is the server streaming service, denoted by the stream keyword in the returns statement. When a client connects to the server, the server will open a stream to the client. This will then allow the server to stream any received messages to the client and any other active clients which are also connected.

Using Docker Containers for Go and gRPC Microservices

Docker is a revolutionary tool, that was also build with Go, that makes it easier to create, deploy and run applications inside of containers. A container is a small environment detached from the major Operating System which contains all of the tools needed to build and execute the enclosed application. In this way, docker is a bit like a virtual machine; however, unlike a virtual machine, docker doesn't create an entire virtual operating system.

docker-container.png

For the example application, we make use of Docker to serve the server module of the Chat Application. Using Docker in this manner, allows us to not only create a container to compile the server but also a separate container to run the application. In the image above, we derive the container from an Alphine Linux kernel that contains the golang toolchain. We also install a bunch of tools that are necessary for compiling the application using the apk package manager. Afterwards, the folder structure of the original project is rebuilt inside of the container to make it easier to execute the application.

The Source Code for this video may be found here: https://github.com/tensor-programming/docker_grpc_chat_tutorial

Video Tutorial

Curriculum

Sort:  

Hi @tensor

Another fantastic video tutorial on this series.

Building a Chat app is very interesting and your teaching makes it easy for people to follow along.

The supplementary resources in Github created for this tutorial is fantastic. Thanks for all the hard work.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you @rosatravels. As always its nice to hear your feedback.

Thank you for your review, @rosatravels! Keep up the good work!





This post has been voted on by the SteemSTEM curation team and voting trail in collaboration with @curie.

If you appreciate the work we are doing then consider voting both projects for witness by selecting stem.witness and curie!

For additional information please join us on the SteemSTEM discord and to get to know the rest of the community!

Pretty cool stuff. I really don't know where to start...
I just want to be able to contribute codes to steem :-(

If you want to start learning something like Go, I have a set of tutorials aimed at beginners. I also have some other languages that I cover, Rust, Dart, Elixir, Elm, Kotlin etc which might help get you there depending on what you want to do.

Hi, @tensor!

You just got a 6.02% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Hi @tensor!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Congratulations @tensor! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You got more than 300 replies. Your next target is to reach 400 replies.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Valentine challenge - Love is in the air!

Support SteemitBoard's project! Vote for its witness and get one more award!

Hey, @tensor!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.20
TRX 0.25
JST 0.038
BTC 96656.73
ETH 3341.70
USDT 1.00
SBD 3.20