Skip to content
William Kennedy edited this page Jul 30, 2024 · 132 revisions

This course teaches you how to build production-level services in Go, leveraging the power of a Domain Driven, Data Oriented Archiecture deployed in Kubernetes. From the beginning of the course, you will pair-program with your instructor Bill Kennedy as he walks you through the design philosophies, architectural decisions, and best practices as they apply to engineering a production-ready Go service.

With each new feature that is added to the service, you will learn how to deploy and manage the Kubernetes environment used to run the service. Throughout the class, the code being worked on is pushed to a repository for personal access and review.

For further class information, please see the class schedule or review the self-study options


Design Philosophy, Review, and Culture

This class tries to teach to these core design philosophies, review practices, and culture.

There are three core design philosophies that drive every guideline:

  • Don’t make things easy to do, make things easy to understand.
  • Every encapsulation must define a new and precise semantic.
  • Engineer with clear and obvious layers of concern and purpose.

There are three core reviews that must be performed with each change:

  • Can this change be maintained, managed, and debugged by the team?
  • Is this change the minimal code needed right now to solve the problem?
  • Does this change violate any style or project guidelines?

There are three core aspects of a team’s culture that should be cultivated:

  • Uncertainty is not a license to guess, but a directive to stop and learn more.
  • Don’t focus on reuse, focus on constant review and refactoring.
  • Be open to discussion and pivot as new things are learned and discovered.

Course Curriculum

1.0 - Introduction

Introduction to the class and all the engineering that you will learn.

  • 1.1: Design Philosophy, Guidelines, What to Expect
  • 1.2: Tooling and Images to Install

2.0 - Deploy First Mentality

We begin to build the service with a focus on the ability to deploy the service in Kuberenetes.

  • 2.1: Project Layers, Policies, and Guidelines
  • 2.2: Prepare Project
  • 2.3: Build Service with Logging

3.0 - Kubernetes

We introduce Kubernetes and get a K8s environment up and running. At this point, everything we do runs in the K8s environment.

  • 3.1: Clusters, Nodes and Pods
  • 3.2: Start the Kubernetes Cluster
  • 3.3: Create/Build Dockerfile for the Service
  • 3.4: Create/Apply K8s Deployment for the Service

4.0 - Kubernetes Quotas

We introduce applying Quotas to the deployment and discuss the problems that can result.

  • 4.1: Understanding the Go Scheduler
  • 4.2: Understanding CPU Quotas
  • 4.3: Adding Qutoas and Adjusting GOMAXPROCS

5.0 - Finish Initial Service Startup/Shutdown

We finish the initial startup and shutdown of the service.

  • 5.1: Configuration
  • 5.2: Debugging / Metrics
  • 5.3: Shutdown Signaling and Load Shedding

6.0 - Web Framework

We build out our own router by extending an existing one. This gives us a framework for injecting business logic into the processing of requests. It also allows for more consistency in the handling of requests.

  • 6.1: Basic Structure of an HTTP Router
  • 6.2: Liveness and Readiness Handlers
  • 6.3: Customize the Router
  • 6.4: Middleware Support
  • 6.5: Sending Responses

7.0 - Middleware

We add middleware functions for business-level logic that needs to be injected into the processing of requests.

  • 7.1: Logging
  • 7.2: Error Handling
    • 7.2.1: Understanding what Error Handling Means
    • 7.2.2: Declaring Custom Error Types
    • 7.2.3: Consistent Handling and Response
  • 7.3: Panic Handling
  • 7.4: Metrics

8.0 - JSON Web Tokens (JWT) and Open Policy Agent (OPA)

We gain an understanding of how JWT's work and their shortcomings. We also learn about OPA and how we will use it to perform the actual authentication and authorization.

  • 8.1: Understanding JWT
  • 8.2: Private/Public Key Generation
  • 8.3: Token Generation
  • 8.4: Token Signature Validation with OPA

9.0 - Key Store

We create a simple key store for the project to store and retrieve the private key.

  • 9.1: Key Store Package

10.0 - Authentication / Authorization

We integrate authentication and authorization support into the project by developing a packages to generate and validate tokens. Then we integrate the packages into the application and test things are working.

  • 10.1: Auth Package
  • 10.2: Auth Unit Test
  • 10.3: Add Middleware
  • 10.4: Auth Service
  • 10.5: Auth Client

11.0 - Domain Driven, Data Oriented Archiecture

We talk about the data driven data oriented architecture that is implemented in the project. We discuss the design philosophy, guidelines, and semantics of how the three layers of App, Business, and Storage work together.

  • 11.1: Architecture Review
  • 11.2: Data Flow Trust vs Non-Trust

12.0 - Database Support

We add a Postgres database to our K8s environment. Then we write a small database package that provides support for using the SQLx package more effectively. Finally, integrate the database package on application startup.

  • 12.1: Kubernetes Support for Postgres
  • 12.2: Create Database Package
  • 12.3: Update Readiness Handler to Perform DB Checks

13.0 - Database Migrations and Seeding

We define our schema and provide support for migration schema changes over time. We also provide support for seeding the database. Finally, we add support in Kubernetes to run the migration and seeding on POD startup.

  • 13.1: Maintaining Database Schemas and Seeds
  • 13.2: Admin Tooling and Init Containers to Automate Migrations

14.0 - API, App, Business, and Storage Domain Implementation

We implement the User domain inside the App, Business, and Storage layers.

  • 14.1: User Business Domain Support
  • 14.2: User Storage Domain Support
  • 14.3: User App Domain Support
  • 14.4: User API Domain Support

15.0 - Testing

We add docker and unit testing support for writing tests against a real database and write the actual user package tests.

  • 15.1: Starting and Stopping Containers
  • 15.2: Database Testing Support
  • 15.3: Unit and API Testing Support
  • 15.4: Write User Business Test
  • 15.5: Write User API Tests

16.0 - Delegate and Transactions

We talk about how the delegate and transaction systems work.

  • 16.1: Delegate System
  • 16.2: Transaction System

17.0 - Observability

We add tracing to the project by integrating Open Telemetry and Zipkin.

  • 17.1: Integrate OTEL into the Project

18.0 - Review Service Project

Review service project and get it running

  • 18.1: Check For Dependency Upgrades, Rebuild, Run

Extra Curriculum

Modules

A walkthrough of how the module ecosystem works. We talk about the engineering decisions you need to make as they relate to modules.

  • 1: Adding Dependencies
  • 2: Module Mirrors
  • 3: Checksum Database
  • 4: Vendoring
  • 5: MVS Algorithm
  • 6: Upgrading Dependencies