Documentation
¶
Overview ¶
Package sender provides a common interface for sending notifications.
Index ¶
Constants ¶
const ( FormatPlainText = "txt" FormatHTML = "html" )
Supported message formats.
Variables ¶
This section is empty.
Functions ¶
func ValidateMessageFormatAndSetDefault ¶
ValidateMessageFormatAndSetDefault validates message the format and sets the default value if empty.
Types ¶
type Factory ¶
Factory is a function that creates a new instance of a notification sender with a given context and options.
type Message ¶
type Message struct {
Subject string `json:"subject"`
Headers map[string]string `json:"headers"`
Severity Severity `json:"severity"`
Body string `json:"body"`
}
Message represents a notification message.
func ParseMessage ¶
ParseMessage parses a notification message string into a Message structure.
type MethodConfig ¶
MethodConfig represents JSON-serializable configuration of a notification method and parameters.
func (MethodConfig) MarshalJSON ¶
func (c MethodConfig) MarshalJSON() ([]byte, error)
MarshalJSON returns JSON-encoded notification method configuration.
func (MethodConfig) Options ¶
func (c MethodConfig) Options(result any) error
Options unmarshals the configuration into the provided structure.
func (*MethodConfig) UnmarshalJSON ¶
func (c *MethodConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON parses the JSON-encoded notification method configuration into MethodInfo.
type Provider ¶
type Provider interface {
Send(ctx context.Context, msg *Message) error
// Format returns the format of the message body that the provider supports, either "html" or "md", some providers will support both.
Format() string
// Summary returns a human-readable summary of the provider configuration.
Summary() string
}
Provider is an interface implemented by all notification providers.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package email provides email notification support.
|
Package email provides email notification support. |
|
Package pushover provides pushover notification support.
|
Package pushover provides pushover notification support. |
|
Package testsender provides notification sender testing support.
|
Package testsender provides notification sender testing support. |
|
Package webhook provides webhook notification support.
|
Package webhook provides webhook notification support. |