MCPcopy Create free account
hub / github.com/ByteYellow/AgentProvenance / setContainerCPUProfile

Method setContainerCPUProfile

internal/control/service.go:552–570  ·  view source on GitHub ↗
(runID, sessionID, containerID, profile string)

Source from the content-addressed store, hash-verified

550}
551
552func (s Service) setContainerCPUProfile(runID, sessionID, containerID, profile string) error {
553 weight, normalized, err := cpuWeightForProfile(profile)
554 if err != nil {
555 return err
556 }
557 start := time.Now()
558 if s.Driver == nil {
559 return fmt.Errorf("runtime driver is required")
560 }
561 if err := s.Driver.SetCPUWeight(context.Background(), containerID, weight); err != nil {
562 return err
563 }
564 switchMS := time.Since(start).Milliseconds()
565 now := time.Now().UTC().Format(time.RFC3339Nano)
566 _, _ = s.DB.Exec(`INSERT INTO events (id, run_id, session_id, source, event_type, payload, created_at)
567 VALUES (?, ?, ?, 'control_plane', 'cpu_weight_set', ?, ?)`,
568 ids.New("evt"), runID, sessionID, fmt.Sprintf(`{"profile":%q,"cpu_weight":%d,"switch_ms":%d}`, normalized, weight, switchMS), now)
569 return nil
570}
571
572func (s Service) lockWrites() {
573 if s.WriteMu != nil {

Callers 5

CreateSessionMethod · 0.95
execMethod · 0.95
SetSessionCPUProfileMethod · 0.95
ResumeSnapshotMethod · 0.95

Calls 4

NewFunction · 0.92
cpuWeightForProfileFunction · 0.85
SetCPUWeightMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected