Skip to content

Export a notify package for sending from Go programs - #47

Merged
archlemon merged 1 commit into
mainfrom
export-notify-package
Nov 28, 2026
Merged

archlemon merged 1 commit into
mainfrom
export-notify-package

Conversation

@archlemon

Copy link
Copy Markdown
Member

Summary

Adds a public package, github.com/suprbdev/noty/notify, so Go programs can send notifications in-process with the same config format and behaviour as the CLI. kickly-generated projects will use it.

  • notify.Load / notify.Parse read the existing YAML config, with the same ${VAR}, ${VAR:-default} and $$ handling. WithLookupEnv injects the env lookup for tests.
  • notify.New(cfg, opts...) builds a Client. Options: WithHTTPClient, WithExecRunner, WithTimeout, WithRetries, WithBackoff, WithClock.
  • Client.Send(ctx, Message) fans out to channels concurrently and keeps going past failures. It returns per-channel Results, and a *SendError that unwraps to each channel's error.
  • Sentinel errors: ErrInvalidConfig, ErrNoChannel, ErrUnknownChannel.
  • Provider internals stay in internal/.

The CLI now sends through the package, so there is one code path. Flags, output and exit codes are unchanged.

Testing

  • go vet ./..., go test -race ./... and golangci-lint (0 issues) pass. Existing CLI tests are unchanged.
  • New tests in notify/ cover config parsing, env injection, fan-out against an httptest server and a fake exec runner, retries and backoff, dry-run masking, and unknown channels. There are also runnable examples.
  • Built main and this branch and ran both on 28 CLI cases: dry-run variants, --list, error paths, retries, --version and piped stdin. After normalising timestamps, stdout, stderr and exit codes are identical.

Suggested release: v0.3.0. It adds a public API and has no breaking change for CLI users.

github.com/suprbdev/noty/notify loads the same YAML config as the CLI
and sends messages in-process: Load/Parse, New with options for the
HTTP client, exec runner, timeout, retries and clock, and Client.Send
with per-channel results. Provider internals stay internal.

The CLI now sends through the package, so both share one code path.
CLI flags, output and exit codes are unchanged.
@archlemon
archlemon merged commit 9ecc188 into main Nov 28, 2026
2 checks passed
@archlemon
archlemon deleted the export-notify-package branch November 28, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant