iop/apps/edge/internal/service/service.go
toki dba289d0fa feat(edge): 모델 그룹 큐 스케줄링 구현
- 모델 그룹별 큐 기반 디스패팅 로직 추가
- ModelQueue 관리자로 모델 인스턴스 큐 처리
- OpenAPI chat 및 responses 핸들러 업데이트
- edge 서비스 테스트 코드 개선
2026-06-16 10:16:05 +09:00

64 lines
1.5 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
queue *modelQueueManager
}
func New(registry *edgenode.Registry, events *edgeevents.Bus) *Service {
s := &Service{registry: registry, events: events}
if events != nil {
q := newModelQueueManager(nil)
q.startEventWatcher(events)
s.queue = q
}
return s
}
func (s *Service) SetNodeStore(store *edgenode.NodeStore) {
s.nodeStore = store
if s.queue != nil {
s.queue.setStore(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()
}