Service types

The kinds of service humus runs, one section each: HTTP, gRPC, jobs, Kafka, RabbitMQ and Kubernetes controllers, each with its guide, its walkthrough and its example.

A service type is a package whose Services an Init returns to humus.Main. Each section here is a guide to one of them, in this order: HTTP, gRPC, jobs, Kafka, RabbitMQ and Kubernetes controllers. Each links to its walkthrough, which builds a production-ready service of that type step by step, and to the walkthrough’s code under example/ on GitHub.


HTTP

Serving HTTP with the httpserver package, then serving an API of typed operations, with its OpenAPI document, with the openapi/v3 package.

gRPC

Serving gRPC with the grpcserver package, from the grpc module.

Jobs

How to write a job with the job package: a run that job.NewService turns into a humus Service, the exit status Kubernetes sees for each way the run ends, which failures a Job retries, and how the run’s span joins the trace of the process that started it.

Consuming and producing Kafka

How to consume and produce Kafka with the queue and queue/kafka packages: the contract a Processor keeps, an Init that sources kafka.Settings and returns the Service from NewService, what each Delivery commits and does with an error, how the consumer shuts down and rebalances on humus.Main’s defaults, how a Producer built with NewProducer produces dead letters and events, what a call to Produce promises, its delivery timeout, circuit breaker and shutdown, what both record, and how to test them on kfake.

Consuming and publishing with RabbitMQ

How to consume and publish with RabbitMQ through the queue and queue/rabbitmq packages: the contract a Processor keeps, an Init that sources rabbitmq.Settings and returns the Service from NewService, what each Delivery acks and does with an error, how the consumer shuts down, rides out a broker’s rolling upgrade and turns ready with Consuming, how a Publisher built with NewPublisher publishes with confirms, retries and a circuit breaker, what both record, and how to test an App that uses RabbitMQ, which humus ships no fake broker for.

Writing a Kubernetes controller

How to write a Kubernetes controller with the kube module, on client-go and without kubebuilder: an Init that fills a kube.Connection in a pod or from a kubeconfig and returns the Service from NewController, a custom resource declared as Go values with typed constraints and its CRD kept true to the types by a golden test, a Reconciler handed its object that returns its status, owned resources, finalizers, Kubernetes’ own kinds, panics, the settings, leader election and shutdown, readiness, the RBAC a controller needs, what it records, failure injection from an object’s annotation down through an operator’s controllers, and how to test it.