feedkit now contains a reusable core, while weatherfeeder is a concrete implementation that includes weather-specific functions.
31 lines
811 B
Go
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
|
|
}
|