iop/apps/edge/internal/service/service.go
toki 6b684ee5cf refactor: edge service split and OpenAI surface separation
- Split edge service into dedicated modules (control_command, node_command, run_dispatch, status_provider)
- Separate OpenAI handlers (chat_handler, ollama_passthrough, routes, stream, strict_output, types)
- Archive completed milestone documents (02_edge_service_split, 03+02_openai_surface_split)
- Update architecture refactor foundation milestone
2026-06-06 12:18:33 +09:00

54 lines
1.3 KiB
Go

package service
import (
edgeevents "iop/apps/edge/internal/events"
edgenode "iop/apps/edge/internal/node"
)
const (
DefaultSessionID = "default"
DefaultTimeoutSec = 30
)
// Service is the surface-neutral application service shared by the console,
// HTTP/A2A input surfaces, and the Control Plane connector. Its responsibilities
// are split across this package by concern: status_provider.go (node snapshots,
// capabilities, health status), run_dispatch.go (run lifecycle), node_command.go
// (node command transport), and control_command.go (Control Plane command
// execution).
type Service struct {
registry *edgenode.Registry
events *edgeevents.Bus
nodeStore *edgenode.NodeStore
}
func New(registry *edgenode.Registry, events *edgeevents.Bus) *Service {
return &Service{registry: registry, events: events}
}
func (s *Service) SetNodeStore(store *edgenode.NodeStore) {
s.nodeStore = store
}
func (s *Service) ListNodes() []*edgenode.NodeEntry {
return s.registry.All()
}
// NormalizeSessionID maps an empty session id to the default session.
func NormalizeSessionID(id string) string {
if id == "" {
return DefaultSessionID
}
return id
}
func normalizeTimeoutSec(timeoutSec int) int {
if timeoutSec <= 0 {
return DefaultTimeoutSec
}
return timeoutSec
}
func nodeLabel(entry *edgenode.NodeEntry) string {
return entry.DisplayLabel()
}