gRPC & gRPC Gateway development in Go Training
This course was designed for anyone wanting to learn gRPC and the gRPC Gateway. Students will learn how to use the Protocol Buffer language to define messages and services for gRPC. They will learn how to create synchronous and asynchronous endpoints (streaming and non-streaming) as well as how to configure and secure their services. They'll also learn how to configure their gRPC services to automatically generate and handle legacy RESTful JSON endpoints by using the gRPC Gateway.
Length
3 days. Each day is 4 hours long including a 15 minute break.Class Size
Our classes are priced for small and large classes. We offer classes starting at only five students, up to 100 students. We recognize that each company has specific needs and budgets.
For pricing, fill out our contact us form and you'll receive an automated reply with our current rates.
Target Audience
- You have been doing daily Go development for 1-3 months.
- You want to learn how to create services with gRPC and Protocol Buffers in Go
- You need to support legacy RESTful JSON API's with your new services.
Prerequisites
- Familiarity and comfort navigating and basic file manipulation at the command line.
- Familiarity and comfort with a modern code editor, including creating and modifying files and projects.
- You have 1 to 3 months of daily Go experience.
- You have at least 6 months of experience with other modern development languages such as Java, C#, Swift, JavaScript, Python, Rust, etc.
- Familiarity with basic programming concepts and structures such as variables, loops, conditionals, etc.
- Computers should be capable of modern software development, such as access to install and run binaries, install a code editor, etc. Full instructions referenced here: preparing your environment for Go development. It may be necessary for them to have root/admin access to their computer.
Recommended Preparation
- Install and configure an editor for Go.
- Have a functioning Go environment installed with Go 1.13 or later.
- Sign up for a Github account if you don't already have one.
Suggested Followup Learning
- Testing, Stubbing, and Automating Go Work Environments
- Web API Development in Go
- Advanced Go Development
- Profiling and Optimization in Go
Expected Outcomes
- Students will learn the Protocol Buffer syntax and how to create messages and services with Proto syntax.
- Students will be able to generate robust services with gRPC in Go.
- Students will learn how to create gRPC streams for accepting multiple messages in a service request.
- Students will learn how to secure and configure their gRPC services.
- Students will learn how to create unit tests and integration tests for gRPC services.
- Students will be able to configure their projects to create RESTful JSON endpoints for existing services with the gRPC Gateway Project.
Course Details
Day One
Welcome
This chapter covers general information about your instructor and course materials.
Install And Configure Protobuf
Installing all the tools you need to make protocol buffers work can be challenging. This chapter lays out in detail the steps needed to properly install and configure your development environment for protocol buffers. It also includes specific steps for each operating system when necessary.
Protocol Buffers
Protocol Buffers are the next step in data formats for high performance distributed systems. In comparison to JSON or XML, protobufs can encode and decode faster, have a smaller encoded size, and allow for use across platforms and languages.
In this chapter, we will cover how to create and use protocol buffers, as well as how to extend them.
Break
Tea/Coffee Break.
Introduction To GRPC
gRPC is a modern open source high performance RPC framework that can run in any environment. In this chapter we will cover the basic concepts used in gRPC, as well as create some simple RPC calls using protocol buffers and implement them with gRPC. We'll also cover how to create specific errors and codes with gRPC.
Streaming With GPRC
Streaming in gRPC allows for the client or server to send and receive more than one message. This allows for asynchronous processing and bi-directional communication. This chapter will cover client streaming, server streaming, and bi-directional streaming.
Day Two
GRPC Metadata
Similar to how HTTP protocol can send headers, gRPC allows you to send key/value pairs via metadata. This chapter shows how to set and retrieve metadata, and guidelines around when to use it.
Observing SLA's With GRPC
Service Level Agreements (SLA's) are an important part of your API. This chapter will discuss how to implement them on the client and server, and best practices to follow.
Contexts are the mechanism that is used to control SLA's in the gRPC ecosystem. As such, we'll also cover additional characteristics of how context works with gRPC beyond SLA's.
Break
Tea/Coffee Break.
Securing GRPC Services
gRPC provides a simple authentication API based around the unified concept of Credentials objects, which can be used when creating an entire gRPC channel or an individual call.
Credentials can be of two types:
Channel credentials
, which are attached to a Channel, such as SSL credentials.Call credentials
, which are attached to a call.
This chapter will cover how to secure a channel
and how to secure a call
.
Testing And Stubbing GRPC
This chapter will show how to approach testing for both client and server services. We will also cover how to stub out specific parts of the stack to enable easy unit testing.
GRPC Middleware
Middleware is a common way to handle many concepts such as logging, tracing, and more. You can implement middleware in your gRPC stack with "interceptors".
This chapter will show how to create basic interceptors and cover existing third party interceptors, as well as setting up retry logic, and load balancing.
Day Three
GRPC Tracing
This chapter will cover how to enable tracing across your distributed gRPC stack, as well as cover popular concepts such as OpenTrace and OpenCensus.
GRPC Tooling
This chapter will cover many useful tools for working with a gRPC API. You will learn how to use common "curl" tools to interact with your API, set up load testing, run a protobuf linter, and more. examining their responses, and working with Protocol Buffers.
Break
Tea/Coffee Break.
GRPC Gateway
The grpc-gateway is a plugin of the Google protocol buffers compiler protoc. It reads protobuf service definitions and generates a reverse-proxy server which translates a RESTful HTTP API into gRPC.
This chapter will cover how to specify the proper definitions in your proto files to generate the RESTful endpoints. It will also cover how to use OpenAPI to quickly test your endpoints.
Finalize
This chapter covers where to get more support on Go, recommends books and videos, and list the contact information for our instructors.
Prerequisites
Introduction To Go Web Development
This chapter will cover some basic concepts of web development in Go. We'll cover how to create handlers, set up routing, and launch a basic web server.
Routing And Muxing
Routing in Go requires the use of a "muxer". In this chapter, we'll explore how to properly set up a muxer to route traffic properly in your web application.
HTTP Handlers
Understanding how Go web applications work means understanding the HTTP.Handler interface. This chapter will cover how Handler
, HandlerFunc
and ServeHTTP
all work together to create the basic building blocks of a Go web service. We will also cover how to create and implement middleware, such as a basic logger and authentication.
Testing Basics
Testing in Go is easy, and simple to use. There is a strong emphasis on testing in Go. The compiler will catch a lot of bugs for you, but it can not ensure your business logic is sound or bug-free.
While the testing package isn't large, there are some features that are not properly understood. In this chapter we will cover the following concepts:
*testing.T
- Error vs. Fatal
- Failure Messages
- Helpers
- Testing Packages
Testing Net/HTTP
In the standard library there are two mechanisms for us to use to test web applications.
- Unit Style Testing
- Integration Style Testing
These are not their "official" names, but we believe they do a good job of describing the styles of testing. In this chapter, we will cover both styles of testing and how to use them.