feat(service): expose subscribe, input, exit status for ws handler
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"io"
|
||||
|
||||
"codespace/internal/process"
|
||||
"codespace/internal/workspace"
|
||||
)
|
||||
@@ -70,3 +72,27 @@ func (s *ProcessService) Status(workspaceID string) (process.Status, error) {
|
||||
}
|
||||
return s.processes.Status(workspaceID), nil
|
||||
}
|
||||
|
||||
// Subscribe subscribes to output events for the workspace process.
|
||||
func (s *ProcessService) Subscribe(workspaceID string) (process.Subscription, error) {
|
||||
if _, err := s.workspaces.Get(workspaceID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.processes.Subscribe(workspaceID)
|
||||
}
|
||||
|
||||
// Input returns the stdin writer for the workspace process.
|
||||
func (s *ProcessService) Input(workspaceID string) (io.WriteCloser, error) {
|
||||
if _, err := s.workspaces.Get(workspaceID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.processes.Stdin(workspaceID)
|
||||
}
|
||||
|
||||
// ExitStatus returns the exit status for the workspace process.
|
||||
func (s *ProcessService) ExitStatus(workspaceID string) (process.ExitInfo, error) {
|
||||
if _, err := s.workspaces.Get(workspaceID); err != nil {
|
||||
return process.ExitInfo{}, err
|
||||
}
|
||||
return s.processes.ExitStatus(workspaceID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user