- Add worker storage layer with PostgreSQL/sqlc setup - Add migration files for worker backbone schema - Add job runner and built-in jobs implementation - Add Redis key definitions for worker state management - Archive socket-session-loop milestone (completed/renamed) - Update roadmap current.md and foundation-alignment phase - Add socket endpoint integration and runtime smoke tests - Add infra-check, worker-storage-check, worker-storage-gen CLI tools - Update API socket server and config - Add pubspec dependencies and client socket endpoint changes - Add config tests for API and worker services
31 lines
874 B
Go
31 lines
874 B
Go
package rediskeys
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// WorkerKey builds a Redis key in the format "<prefix>:worker:<purpose>:<id>"
|
|
// prefix, purpose, and id are trimmed of whitespace and leading/trailing colons.
|
|
// If purpose or id is empty after normalization, an error is returned.
|
|
func WorkerKey(prefix, purpose, id string) (string, error) {
|
|
normPrefix := strings.Trim(prefix, " \t\n\r:")
|
|
if normPrefix == "" {
|
|
normPrefix = "alt"
|
|
}
|
|
normPrefix = strings.ToLower(normPrefix)
|
|
|
|
normPurpose := strings.Trim(purpose, " \t\n\r:")
|
|
if normPurpose == "" {
|
|
return "", errors.New("rediskeys: purpose cannot be empty")
|
|
}
|
|
normPurpose = strings.ToLower(normPurpose)
|
|
|
|
normID := strings.Trim(id, " \t\n\r:")
|
|
if normID == "" {
|
|
return "", errors.New("rediskeys: id cannot be empty")
|
|
}
|
|
|
|
return fmt.Sprintf("%s:worker:%s:%s", normPrefix, normPurpose, normID), nil
|
|
}
|