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.
This commit is contained in:
30
event/kind.go
Normal file
30
event/kind.go
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user