Tidying up

This commit is contained in:
2025-10-16 22:10:47 -07:00
parent d28bb92486
commit ba3fad9431
13 changed files with 225 additions and 296 deletions
+10 -10
View File
@@ -11,12 +11,12 @@ import (
// Config represents the application configuration
type Config struct {
Server ServerConfig `mapstructure:"server"`
Queue domain.QueueConfig `mapstructure:"queue"`
Notifiers NotifiersConfig `mapstructure:"notifiers"`
Logging LoggingConfig `mapstructure:"logging"`
Metrics MetricsConfig `mapstructure:"metrics"`
HealthCheck HealthCheckConfig `mapstructure:"health_check"`
Server ServerConfig `mapstructure:"server"`
Queue domain.QueueConfig `mapstructure:"queue"`
Notifiers NotifiersConfig `mapstructure:"notifiers"`
Logging LoggingConfig `mapstructure:"logging"`
Metrics MetricsConfig `mapstructure:"metrics"`
HealthCheck HealthCheckConfig `mapstructure:"health_check"`
}
// ServerConfig contains server configuration
@@ -44,10 +44,10 @@ type LoggingConfig struct {
// MetricsConfig contains metrics/observability configuration
type MetricsConfig struct {
Enabled bool `mapstructure:"enabled"`
Port int `mapstructure:"port"`
Path string `mapstructure:"path"`
PrometheusEnabled bool `mapstructure:"prometheus_enabled"`
Enabled bool `mapstructure:"enabled"`
Port int `mapstructure:"port"`
Path string `mapstructure:"path"`
PrometheusEnabled bool `mapstructure:"prometheus_enabled"`
}
// HealthCheckConfig contains health check configuration
+8 -8
View File
@@ -104,12 +104,12 @@ type NotificationResult struct {
// NotificationFilter is used for querying notifications
type NotificationFilter struct {
IDs []string `json:"ids,omitempty"`
Types []NotificationType `json:"types,omitempty"`
Statuses []NotificationStatus `json:"statuses,omitempty"`
Recipients []string `json:"recipients,omitempty"`
CreatedAfter *time.Time `json:"created_after,omitempty"`
CreatedBefore *time.Time `json:"created_before,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
IDs []string `json:"ids,omitempty"`
Types []NotificationType `json:"types,omitempty"`
Statuses []NotificationStatus `json:"statuses,omitempty"`
Recipients []string `json:"recipients,omitempty"`
CreatedAfter *time.Time `json:"created_after,omitempty"`
CreatedBefore *time.Time `json:"created_before,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
+7 -7
View File
@@ -57,11 +57,11 @@ type NotificationService interface {
// NotificationStats contains statistics about notification processing
type NotificationStats struct {
TotalSent int64 `json:"total_sent"`
TotalFailed int64 `json:"total_failed"`
TotalPending int64 `json:"total_pending"`
TotalQueued int64 `json:"total_queued"`
ByType map[string]int64 `json:"by_type"`
ByStatus map[string]int64 `json:"by_status"`
AverageLatency float64 `json:"average_latency_ms"`
TotalSent int64 `json:"total_sent"`
TotalFailed int64 `json:"total_failed"`
TotalPending int64 `json:"total_pending"`
TotalQueued int64 `json:"total_queued"`
ByType map[string]int64 `json:"by_type"`
ByStatus map[string]int64 `json:"by_status"`
AverageLatency float64 `json:"average_latency_ms"`
}
+10 -10
View File
@@ -43,17 +43,17 @@ type NtfyNotifier struct {
// ntfyRequest represents the ntfy API request format
type ntfyRequest struct {
Topic string `json:"topic"`
Message string `json:"message"`
Title string `json:"title,omitempty"`
Priority int `json:"priority,omitempty"`
Tags []string `json:"tags,omitempty"`
Click string `json:"click,omitempty"`
Attach string `json:"attach,omitempty"`
Topic string `json:"topic"`
Message string `json:"message"`
Title string `json:"title,omitempty"`
Priority int `json:"priority,omitempty"`
Tags []string `json:"tags,omitempty"`
Click string `json:"click,omitempty"`
Attach string `json:"attach,omitempty"`
Actions []ntfyAction `json:"actions,omitempty"`
Icon string `json:"icon,omitempty"`
Delay string `json:"delay,omitempty"`
Email string `json:"email,omitempty"`
Icon string `json:"icon,omitempty"`
Delay string `json:"delay,omitempty"`
Email string `json:"email,omitempty"`
}
// ntfyAction represents an action button in ntfy
+7 -7
View File
@@ -30,17 +30,17 @@ type SlackNotifier struct {
// slackMessage represents the Slack API request format
type slackMessage struct {
Channel string `json:"channel,omitempty"`
Username string `json:"username,omitempty"`
IconEmoji string `json:"icon_emoji,omitempty"`
Text string `json:"text,omitempty"`
Blocks []slackBlock `json:"blocks,omitempty"`
Markdown bool `json:"mrkdwn,omitempty"`
Channel string `json:"channel,omitempty"`
Username string `json:"username,omitempty"`
IconEmoji string `json:"icon_emoji,omitempty"`
Text string `json:"text,omitempty"`
Blocks []slackBlock `json:"blocks,omitempty"`
Markdown bool `json:"mrkdwn,omitempty"`
}
// slackBlock represents a Slack block element
type slackBlock struct {
Type string `json:"type"`
Type string `json:"type"`
Text *slackTextBlock `json:"text,omitempty"`
}
+9 -9
View File
@@ -8,20 +8,20 @@ import (
"sync"
"time"
"github.com/igodwin/notifier/internal/domain"
"github.com/google/uuid"
"github.com/igodwin/notifier/internal/domain"
)
// LocalQueue is an in-memory queue implementation
type LocalQueue struct {
queue chan *domain.QueueMessage
messages map[string]*domain.QueueMessage
mu sync.RWMutex
config *domain.LocalQueueConfig
persistToDisk bool
persistPath string
closed bool
closeChan chan struct{}
queue chan *domain.QueueMessage
messages map[string]*domain.QueueMessage
mu sync.RWMutex
config *domain.LocalQueueConfig
persistToDisk bool
persistPath string
closed bool
closeChan chan struct{}
}
// NewLocalQueue creates a new local queue instance