This repository contains code samples to demonstrate vagaries around Go's
context API.
Structure
{grpc,http}-in-series: shows the behavior of a function with manual
deadline management juxtaposed with the context's native cancellation
mechanisms as implemented respectively through gRPC and HTTP server libraries.
{grpc,http}-branch: shows the behavior of the same function from
{grpc,http}-in-series run in a separate goroutine from the respective server
libraries to connect how the server's dispatch functions handle context
lifetime.
{grpc,http}-notify: shows the lifetime behaviors of the context from the
respective server libraries to establish when lifetime begins and ends in
isolation.
{grpc,http}-deadline: reveals what deadline the server library attaches to
the context (if any).
http-deadline-synth demonstrates a deadline with the HTTP stack using
a homegrown X-MTP-Deadline request header (uses http.TimeFormat values).
{grpc,http}-complete: these combine respectively
{grpc,http}-{branch,deadline,notify} and http-deadline-synth into one
server to show you all of the moving parts of the original quiz.
The server samples serve on localhost:8080:
Clients can exercise the HTTP servers with curl:
$ curl localhost:8080
Clients can exercise the gRPC servers the gRPC CLI (grpc_cli):