notifykit

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: Apache-2.0

README

Notifykit

A small Go library for templated webhook and email notifications. Your application owns its events and configuration; Notifykit handles delivery.

Features

  • Synchronous delivery or a bounded queue with multiple workers.
  • Receiver routing and per-receiver template data.
  • Opt-in retries with backoff, jitter, and Retry-After support.
  • HTTP webhooks and SMTP with explicit TLS modes.
  • Text and HTML templates, structured errors, and graceful shutdown.

Quick start

Requires Go 1.27 or newer:

go get github.com/containeroo/notifykit

Replace the example URL with your webhook endpoint:

package main

import (
    "context"
    "log"

    "github.com/containeroo/notifykit/notify"
    "github.com/containeroo/notifykit/targets/webhook"
    "github.com/containeroo/notifykit/templates"
)

type Alert struct{ Message string }

func (a Alert) ID() string { return "alert-1" }
func (a Alert) Data(_ string, _ map[string]any, title string) any {
    return map[string]any{"Message": a.Message, "Title": title}
}

func main() {
    title, err := templates.ParseStringTemplate("title", "Service alert")
    if err != nil {
        log.Fatal(err)
    }
    body, err := templates.ParseTemplate(
        "body", `{"text": {{ printf "%s: %s" .Title .Message | json }}}`,
        templates.WithDefaultFuncs(),
    )
    if err != nil {
        log.Fatal(err)
    }
    target := webhook.New(
        webhook.WithURL("https://example.com/webhook"),
        webhook.WithTitleTemplate(title),
        webhook.WithTemplate(body),
        webhook.WithValidateJSON(),
    )
    if err := notify.SendTo(context.Background(), Alert{"API is down"},
        notify.NewReceiver("ops", target)); err != nil {
        log.Fatal(err)
    }
}

Documentation

Start with the documentation overview or getting started. Full guides cover routing, retries, queueing, templates, SMTP, and logging/redaction.

Runnable examples: single receiver and multiple receivers.

Documentation is built with Lore; see the development guide for build instructions.

License

Apache License 2.0.

Directories

Path Synopsis
examples
multiple command
single command
internal
targets

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL