Files
feedkit/event/kind.go
Eric Rakestraw 0cc2862170 feedkit: split the former maximumdirect.net/weatherd project in two.
feedkit now contains a reusable core, while weatherfeeder is a concrete implementation that includes weather-specific functions.
2026-01-13 10:40:01 -06:00

31 lines
811 B
Go

package event
import (
"fmt"
"strings"
)
// Kind identifies the "type/category" of an event for routing and policy decisions.
//
// Kind is intentionally open-ended (stringly-typed), because different daemons will
// have different kinds:
//
// weatherfeeder: "observation", "forecast", "alert"
// newsfeeder: "article", "breaking", ...
// stockfeeder: "quote", "bar", "news", ...
//
// Conventions (recommended, not required):
// - lowercase
// - words separated by underscores if needed
type Kind string
// ParseKind normalizes and validates a kind string.
// It lowercases and trims whitespace, and rejects empty values.
func ParseKind(s string) (Kind, error) {
k := strings.ToLower(strings.TrimSpace(s))
if k == "" {
return "", fmt.Errorf("kind cannot be empty")
}
return Kind(k), nil
}