<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amit Stephen</title>
    <description>The latest articles on DEV Community by Amit Stephen (@amit_stephen).</description>
    <link>https://dev.to/amit_stephen</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3980563%2F159341a0-705a-4eeb-8417-80e5acefd7f4.jpg</url>
      <title>DEV Community: Amit Stephen</title>
      <link>https://dev.to/amit_stephen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amit_stephen"/>
    <language>en</language>
    <item>
      <title>Building GoRelay: A Durable Task Queue for Go with Zero Infrastructure</title>
      <dc:creator>Amit Stephen</dc:creator>
      <pubDate>Fri, 12 Jun 2026 05:42:28 +0000</pubDate>
      <link>https://dev.to/amit_stephen/building-gorelay-a-durable-task-queue-for-go-with-zero-infrastructure-4c7d</link>
      <guid>https://dev.to/amit_stephen/building-gorelay-a-durable-task-queue-for-go-with-zero-infrastructure-4c7d</guid>
      <description>&lt;p&gt;Every Go developer has written this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
go sendEmail(user)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works perfectly... until it doesn't. Your server crashes, the task disappears forever, and your user never gets that welcome email.&lt;/p&gt;

&lt;p&gt;I kept building the same solution: a task queue with retries, persistence, and monitoring. But every time, I had to set up Redis, configure workers, and write boilerplate code.&lt;/p&gt;

&lt;p&gt;So I built GoRelay - a durable task queue that works out of the box.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is GoRelay?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GoRelay turns any Go function into a crash-resistant, retryable background job.&lt;/p&gt;

&lt;p&gt;The API is simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
r.Register("email.send", SendEmail)
r.Enqueue("email.send", EmailPayload{To: "user@example.com"})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What makes it different:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setup: go get and done (no Redis required)&lt;/li&gt;
&lt;li&gt;Default storage: SQLite (file-based, zero config)&lt;/li&gt;
&lt;li&gt;Dashboard: Built-in, no separate setup&lt;/li&gt;
&lt;li&gt;Retries: Automatic with exponential backoff&lt;/li&gt;
&lt;li&gt;Backends: SQLite, PostgreSQL, Redis - same code works everywhere&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Journey to v1.0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Building an open source library taught me more than I expected.&lt;/p&gt;

&lt;p&gt;First, I started with the API first. I wrote example code showing how I WANTED it to work, then made it work that way.&lt;/p&gt;

&lt;p&gt;Second, storage abstraction is critical. GoRelay supports SQLite, PostgreSQL, and Redis with the same interface. Start with SQLite on your laptop, deploy to PostgreSQL in production, scale to Redis for high throughput - no code changes needed.&lt;/p&gt;

&lt;p&gt;Third, the dashboard changed everything. I almost skipped it. Big mistake. Being able to see tasks in real-time - their status, history, and errors - is what makes GoRelay trustworthy for production use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works Under the Hood&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lock-Free Ring Buffer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GoRelay uses a lock-free ring buffer for task passing between producers and consumers. This means no mutex contention and no goroutine blocking during normal operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Priority Queues&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tasks are processed in priority order: High, Normal, Low. This ensures critical payments never wait behind analytics jobs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automatic Retries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Failed tasks retry with exponential backoff. The delay increases with each attempt: 1s, 2s, 4s, 8s, up to 1 hour. Random jitter prevents thundering herd problems when services recover.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multiple Storage Backends&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each backend is optimized for its strength:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQLite: Embedded, zero config, perfect for side projects and internal tools&lt;/li&gt;
&lt;li&gt;PostgreSQL: ACID compliant, supports multiple workers, ideal for production SaaS&lt;/li&gt;
&lt;li&gt;Redis: High throughput, great for existing Redis shops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-World Use Cases&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GoRelay is being used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Welcome emails after user signup&lt;/li&gt;
&lt;li&gt;PDF report generation&lt;/li&gt;
&lt;li&gt;SMS notifications&lt;/li&gt;
&lt;li&gt;Data processing pipelines&lt;/li&gt;
&lt;li&gt;Scheduled maintenance tasks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What I Learned Building Open Source&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Documentation is code.&lt;/strong&gt; I spent 40% of my time on README, examples, and godoc. Worth it. Users judge your library by its documentation first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tests build confidence.&lt;/strong&gt; Writing tests caught bugs I didn't know I had. The race detector (go test -race) is your best friend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Release early, release often.&lt;/strong&gt; v1.0 doesn't need every feature. Ship something useful, then iterate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's Next for GoRelay&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;v1.1: Webhooks and Outbox pattern for transactional consistency&lt;/li&gt;
&lt;li&gt;v1.2: Idempotency keys to prevent duplicate processing&lt;/li&gt;
&lt;li&gt;v2.0: Distributed tracing and Prometheus metrics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Try GoRelay Today&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
go get github.com/amitstephen-dev/gorelay@v1.0.0

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Complete working example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
package main

import (
    "fmt"
    "github.com/amitstephen-dev/gorelay"
)

type EmailPayload struct {
    To   string
    Body string
}

func SendEmail(payload interface{}) error {
    p := payload.(*EmailPayload)
    fmt.Printf("Sending to: %s\n", p.To)
    return nil
}

func main() {
    r := gorelay.New()
    r.Register("email.send", SendEmail, &amp;amp;EmailPayload{})
    r.EnableDashboard(":8080")
    r.Start()

    r.Enqueue("email.send", &amp;amp;EmailPayload{
        To:   "user@example.com",
        Body: "Welcome to GoRelay!",
    })

    select {}
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt; to see the dashboard with real-time task monitoring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Fast Is It?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of giving you marketing numbers, I encourage you to benchmark GoRelay on your own hardware with your own workload patterns.&lt;/p&gt;

&lt;p&gt;The architecture is designed for efficiency:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lock-free ring buffer for zero contention&lt;/li&gt;
&lt;li&gt;Zero-copy JSON for small payloads&lt;/li&gt;
&lt;li&gt;Batch writes to reduce database round trips&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Actual throughput depends on your storage backend:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQLite: Great for development and moderate workloads&lt;/li&gt;
&lt;li&gt;PostgreSQL: Production-ready with strong consistency&lt;/li&gt;
&lt;li&gt;Redis: Highest throughput for high-volume workloads&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Memory usage is typically under 50MB for most workloads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: github.com/amitstephen-dev/gorelay&lt;/li&gt;
&lt;li&gt;Documentation: pkg.go.dev/github.com/amitstephen-dev/gorelay&lt;/li&gt;
&lt;li&gt;Report Issues: github.com/amitstephen-dev/gorelay/issues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Closing Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Building GoRelay taught me that simple tools can solve complex problems. You don't always need Kubernetes or microservices. Sometimes, a well-designed library with a SQLite backend is all you need.&lt;/p&gt;

&lt;p&gt;The best part? You can start with zero infrastructure. No Redis. No Postgres. Just go get and go run.&lt;/p&gt;

&lt;p&gt;If GoRelay saves you time or solves a problem, star the repo on GitHub - it helps other developers find it.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Built with love for the Go community&lt;/em&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>opensource</category>
      <category>backend</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
