What Notification Channels Does Dewy Support? A Complete Guide to Deployment Alerts
Dewy supports three notification channels: Slack via slack:// URLs, SMTP email via mail:// or smtp:// URLs, and a no-op Null channel when no notifier is configured.
Dewy is an automated deployment tool written in Go by linyows that handles release management and server restarts. Understanding what notification channels Dewy supports is essential for setting up deployment alerts that keep your team informed about release status, failures, and hook execution results.
Supported Notification Channels
Dewy's notification system is built around a factory pattern in notifier/notifier.go that parses URL schemes to instantiate the appropriate sender. The system supports three concrete implementations, each designed for different operational requirements.
Slack Notifications
The Slack channel sends formatted deployment messages to Slack channels using the Slack API. This implementation lives in notifier/slack.go and requires the SLACK_TOKEN environment variable for authentication.
Key features include:
- Support for the
quietquery parameter to suppress routine success messages - Rich message formatting with attachments and color coding
- Channel specification directly in the URL (e.g.,
slack://#deploys)
When initialized via notifier.New, the factory parses the slack:// scheme and calls NewSlack to create a concrete sender that wraps the Slack Web API.
Email (SMTP) Notifications
The Email channel delivers plain-text deployment alerts via SMTP servers. Implemented in notifier/mail.go, this channel accepts URLs with either mail:// or smtp:// schemes.
Configuration options include:
- SMTP authentication via
MAIL_USERNAMEandMAIL_PASSWORDenvironment variables - Sender address configuration via
MAIL_FROM - All parameters overridable via URL query strings (e.g.,
?username=dewy&password=secret)
The NewMail constructor parses these parameters and establishes an SMTP connection for sending deployment status emails to specified recipients.
Null (No-Op) Notifications
The Null channel serves as the default no-operation implementation when no notifier URL is provided. Defined in notifier/null.go, this sender silently discards all messages without error.
This channel activates when:
- The
--notifierCLI flag is omitted (defined incli.go) - An unsupported URL scheme is provided to the factory
- An empty string URL (
"") is passed tonotifier.New
Notification Architecture and Routing
The notification system centers on the Notifier interface and a sophisticated wrapper that manages error states. The architectural flow ensures reliable alert delivery while preventing notification spam during failure conditions.
Factory Pattern Implementation
The notifier.New function (lines 152-162 in notifier/notifier.go) acts as the central factory, parsing the URL scheme and instantiating the correct concrete type:
- Empty scheme (
"") →Nullimplementation slackscheme →NewSlack(creates aSlacksender)mailorsmtpscheme →NewMail(creates aMailsender)
Error Limiting Wrapper
Every concrete sender gets wrapped by ErrorLimitingSender (lines 36-43 in notifier/notifier.go), which provides:
- Error suppression: Normal messages are suppressed while an error condition is active
- Rate limiting: Sends up to
maxNotifyErrorserror alerts, then emits a final "quiet" warning - Important message handling: Provides
SendImportant,SendError,ResetErrorCount, andSendHookResultmethods
This wrapper ensures that during deployment failures, your team receives immediate alerts but avoids being overwhelmed by repetitive error notifications.
Lifecycle Integration
Throughout the deployment lifecycle in dewy.go, Dewy invokes specific notifier methods:
d.Notifier.Sendannounces deployment startd.Notifier.SendErrorreports failuresd.Notifier.SendHookResultreports hook execution results after deployment steps complete
Configuring Notification Channels
Configure notifications by passing a URL to the --notifier flag. The factory parses this URL to initialize the appropriate channel with your specified parameters.
Setting Up Slack Alerts
To receive Slack notifications, export your SLACK_TOKEN and use the slack:// scheme with an optional quiet flag:
package main
import (
"context"
"log"
"log/slog"
"os"
"github.com/linyows/dewy/notifier"
)
func main() {
ctx := context.Background()
logger := slog.New(slog.NewJSONHandler(os.Stderr, nil))
// Configure Slack to post in "#deploys" with quiet mode enabled
n, err := notifier.New(ctx, "slack://#deploys?quiet=true", logger)
if err != nil {
log.Fatalf("failed to create notifier: %v", err)
}
n.Send(ctx, "🚀 Deployment started")
// Later in the deployment process...
n.SendImportant(ctx, "✅ Deployment succeeded")
}
Configuring SMTP Email
For email notifications, use the mail:// scheme with embedded credentials or environment variables:
package main
import (
"context"
"log"
"log/slog"
"os"
"github.com/linyows/dewy/notifier"
)
func main() {
ctx := context.Background()
logger := slog.New(slog.NewJSONHandler(os.Stderr, nil))
// Configure SMTP with authentication
url := "mail://smtp.example.com:587?username=dewy&password=secret&to=ops@example.com"
n, err := notifier.New(ctx, url, logger)
if err != nil {
log.Fatalf("failed to create mail notifier: %v", err)
}
n.Send(ctx, "Dewy is deploying version v1.2.3")
}
Alternatively, set MAIL_USERNAME, MAIL_PASSWORD, and MAIL_FROM environment variables and omit credentials from the URL.
Disabling Notifications
To explicitly disable notifications, pass an empty string or omit the --notifier flag entirely:
package main
import (
"context"
"log/slog"
"os"
"github.com/linyows/dewy/notifier"
)
func main() {
ctx := context.Background()
logger := slog.New(slog.NewJSONHandler(os.Stderr, nil))
// Null implementation - messages are silently discarded
n, _ := notifier.New(ctx, "", logger)
n.Send(ctx, "This message is ignored")
}
Summary
Dewy provides a flexible, interface-driven notification system supporting three distinct channels:
- Slack integration via
slack://URLs with API token authentication and optional quiet mode - SMTP email delivery via
mail://orsmtp://URLs with configurable authentication parameters - Null no-op channel serving as the safe default when notifications are not configured
The architecture uses a factory pattern in notifier/notifier.go to route URLs to concrete implementations, wraps all senders with ErrorLimitingSender for spam prevention, and integrates seamlessly with the deployment lifecycle in dewy.go.
Frequently Asked Questions
How do I configure the Slack notification channel in Dewy?
Set the SLACK_TOKEN environment variable with your Slack Bot token, then pass a slack:// URL to the --notifier flag. Include the channel name in the URL path (e.g., slack://#deploys) and add ?quiet=true to suppress routine success messages. The implementation in notifier/slack.go handles message formatting and API communication automatically.
Can I use SMTP authentication with Dewy email notifications?
Yes. Dewy's email channel in notifier/mail.go supports SMTP authentication via the MAIL_USERNAME and MAIL_PASSWORD environment variables, or by embedding credentials directly in the URL query string. You can also specify the sender address via MAIL_FROM or the from query parameter. The NewMail constructor parses these values when creating the sender instance.
What happens if I don't specify a notifier URL?
Dewy defaults to the Null implementation defined in notifier/null.go. This no-op sender silently discards all notification calls without error, ensuring deployment operations continue uninterrupted. The factory in notifier/notifier.go instantiates this when receiving an empty string or when the --notifier CLI flag is omitted.
How does Dewy handle notification errors?
All notification channels are wrapped by ErrorLimitingSender (lines 36-43 in notifier/notifier.go), which implements error-rate limiting and "important" message handling. While an error condition is active, normal messages are suppressed. The system sends up to maxNotifyErrors error alerts before emitting a final warning and entering a quiet state, preventing notification spam during persistent deployment failures.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →