<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Service types on Humus</title><link>https://z5labs.github.io/humus/services/</link><description>Recent content in Service types on Humus</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://z5labs.github.io/humus/services/index.xml" rel="self" type="application/rss+xml"/><item><title>Jobs</title><link>https://z5labs.github.io/humus/services/jobs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://z5labs.github.io/humus/services/jobs/</guid><description>&lt;p&gt;A job is a process that does one piece of work and exits. The
&lt;a href="https://pkg.go.dev/github.com/z5labs/humus/job"&gt;&lt;code&gt;job&lt;/code&gt;&lt;/a&gt; package turns that
work, the run, into a &lt;code&gt;humus.Service&lt;/code&gt; that runs it once, stops it on either
shutdown signal and records one span around it. The job runs on
&lt;code&gt;humus.Main&lt;/code&gt;&amp;rsquo;s defaults, and the run&amp;rsquo;s error is the exit status, so
Kubernetes retries a job that failed or was interrupted and completes one
that finished.&lt;/p&gt;
&lt;p&gt;The package is &lt;code&gt;job.NewService&lt;/code&gt; and nothing else: no App, no &lt;code&gt;Main&lt;/code&gt;, no
&lt;code&gt;Settings&lt;/code&gt;. The design behind everything on this page is in
&lt;a href="https://github.com/z5labs/humus/discussions/682"&gt;Proposal: jobs&lt;/a&gt; and
&lt;a href="https://github.com/z5labs/humus/discussions/682#discussioncomment-18988201"&gt;its revision&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Consuming and producing Kafka</title><link>https://z5labs.github.io/humus/services/kafka/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://z5labs.github.io/humus/services/kafka/</guid><description>&lt;p&gt;The &lt;a href="https://pkg.go.dev/github.com/z5labs/humus/queue/kafka"&gt;&lt;code&gt;queue/kafka&lt;/code&gt;&lt;/a&gt;
package consumes Kafka topics as a &lt;code&gt;humus.Service&lt;/code&gt;, with
&lt;a href="https://github.com/twmb/franz-go"&gt;franz-go&lt;/a&gt;. The Service joins a consumer
group, dials the brokers through the Setup&amp;rsquo;s Host, and hands each record to
the end user&amp;rsquo;s &lt;code&gt;queue.Processor&lt;/code&gt;, one record at a time per partition, in
offset order. The end user&amp;rsquo;s &lt;code&gt;Init&lt;/code&gt; sources its &lt;code&gt;Settings&lt;/code&gt;, builds the Service
with &lt;code&gt;kafka.NewService&lt;/code&gt;, and returns it to &lt;code&gt;humus.Main&lt;/code&gt;, whose defaults are a
consumer&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;The package produces records too. A &lt;code&gt;kafka.Producer&lt;/code&gt;, which the end user&amp;rsquo;s
&lt;code&gt;Init&lt;/code&gt; builds with &lt;code&gt;kafka.NewProducer&lt;/code&gt;, produces to one cluster for any
Service of the process: a &lt;code&gt;Processor&lt;/code&gt; that produces a dead letter or writes
to another topic, an HTTP handler that publishes an event, a job.
&lt;a href="#producing"&gt;Producing&lt;/a&gt; describes it.&lt;/p&gt;</description></item><item><title>Consuming and publishing with RabbitMQ</title><link>https://z5labs.github.io/humus/services/rabbitmq/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://z5labs.github.io/humus/services/rabbitmq/</guid><description>&lt;p&gt;The &lt;a href="https://pkg.go.dev/github.com/z5labs/humus/queue/rabbitmq"&gt;&lt;code&gt;queue/rabbitmq&lt;/code&gt;&lt;/a&gt;
package consumes a RabbitMQ queue as a &lt;code&gt;humus.Service&lt;/code&gt;, with
&lt;a href="https://github.com/rabbitmq/amqp091-go"&gt;amqp091-go&lt;/a&gt;, RabbitMQ&amp;rsquo;s own Go
client. The Service dials the broker through the Setup&amp;rsquo;s Host, consumes one
queue with manual acks, and hands each delivery to the end user&amp;rsquo;s
&lt;code&gt;queue.Processor&lt;/code&gt;, in the order the queue delivered them. The end user&amp;rsquo;s
&lt;code&gt;Init&lt;/code&gt; sources its &lt;code&gt;Settings&lt;/code&gt;, builds the Service with &lt;code&gt;rabbitmq.NewService&lt;/code&gt;,
and returns it to &lt;code&gt;humus.Main&lt;/code&gt;, whose defaults are a consumer&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;The package publishes too. A &lt;code&gt;rabbitmq.Publisher&lt;/code&gt;, which the end user&amp;rsquo;s
&lt;code&gt;Init&lt;/code&gt; builds with &lt;code&gt;rabbitmq.NewPublisher&lt;/code&gt;, publishes to the broker with
publisher confirms for any Service of the process: a &lt;code&gt;Processor&lt;/code&gt; that
publishes an event, an HTTP handler, a job. &lt;a href="#publishing"&gt;Publishing&lt;/a&gt;
describes it.&lt;/p&gt;</description></item><item><title>Writing a Kubernetes controller</title><link>https://z5labs.github.io/humus/services/kubernetes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://z5labs.github.io/humus/services/kubernetes/</guid><description>&lt;p&gt;The &lt;a href="https://pkg.go.dev/github.com/z5labs/humus/kube"&gt;&lt;code&gt;kube&lt;/code&gt;&lt;/a&gt; package writes
Kubernetes controllers as &lt;code&gt;humus.Service&lt;/code&gt;s, with
&lt;a href="https://github.com/kubernetes/client-go"&gt;client-go&lt;/a&gt;, Kubernetes&amp;rsquo; own client,
and no controller-runtime. It reaches the API server through the Setup&amp;rsquo;s
Host, declares custom resources as Go values, reflects their CRDs from Go
types, and reconciles their objects, or those of Kubernetes&amp;rsquo; own kinds, on
client-go&amp;rsquo;s informers, work queue and leader election. The end user&amp;rsquo;s
&lt;code&gt;Init&lt;/code&gt; fills a &lt;code&gt;kube.Connection&lt;/code&gt; and sources &lt;code&gt;kube.Settings&lt;/code&gt;, builds a
&lt;code&gt;Client&lt;/code&gt; and a &lt;code&gt;Reconciler&lt;/code&gt;, and returns the Service that
&lt;code&gt;kube.NewController&lt;/code&gt; builds to &lt;code&gt;humus.Main&lt;/code&gt;, whose defaults fit a
controller.&lt;/p&gt;</description></item></channel></rss>