Documentation
¶
Index ¶
- Constants
- Variables
- func DecodePayload(msg Message) (any, error)
- func JobID(job Job) string
- func ProcessJobEnv(baseEnv []string, processID string, info RunningJobInfo) ([]string, error)
- func WriteMessage(w io.Writer, msg Message) error
- type ActiveJobsRequest
- type ActiveJobsResponse
- type DumpStackTraceRequest
- type ExecutorType
- type Exiting
- type InferenceRequest
- type InferenceResponse
- type InitializeRequest
- type InitializeResponse
- type JSONJob
- type Job
- type JobAcceptArguments
- type JobExecutor
- type JobStatus
- type Message
- type MessageType
- type PingRequest
- type PongResponse
- type ProcPool
- func (p *ProcPool) ActiveJobs() []RunningJobInfo
- func (p *ProcPool) Close() error
- func (p *ProcPool) GetByJobID(jobID string) JobExecutor
- func (p *ProcPool) GetExecutors() []JobExecutor
- func (p *ProcPool) LaunchJob(ctx context.Context, job Job) error
- func (p *ProcPool) LaunchRunningJob(ctx context.Context, info RunningJobInfo) error
- func (p *ProcPool) On(event ProcPoolEvent, handler func(JobExecutor))
- func (p *ProcPool) SetCloseTimeout(timeout time.Duration)
- func (p *ProcPool) SetTargetIdleProcesses(numIdleProcesses int)
- func (p *ProcPool) Start(ctx context.Context) error
- func (p *ProcPool) TargetIdleProcesses() int
- type ProcPoolEvent
- type ProcessJobExecutor
- func (e *ProcessJobExecutor) Close(ctx context.Context) error
- func (e *ProcessJobExecutor) HandlePong(PongResponse)
- func (e *ProcessJobExecutor) HandleShutdownRequestAck(ShutdownRequestAck)
- func (e *ProcessJobExecutor) HandleShuttingDown(ShuttingDown)
- func (e *ProcessJobExecutor) ID() string
- func (e *ProcessJobExecutor) Job() Job
- func (e *ProcessJobExecutor) LaunchJob(ctx context.Context, job Job) error
- func (e *ProcessJobExecutor) LaunchRunningJob(ctx context.Context, info RunningJobInfo) error
- func (e *ProcessJobExecutor) RunningJob() *RunningJobInfo
- func (e *ProcessJobExecutor) SetCloseTimeout(timeout time.Duration)
- func (e *ProcessJobExecutor) Started() bool
- func (e *ProcessJobExecutor) Status() JobStatus
- type ReloadJobsRequest
- type ReloadJobsResponse
- type Reloaded
- type RunningJobInfo
- type ShutdownRequest
- type ShutdownRequestAck
- type ShuttingDown
- type StartJobRequest
- type ThreadJobExecutor
- func (e *ThreadJobExecutor) Close(ctx context.Context) error
- func (e *ThreadJobExecutor) ID() string
- func (e *ThreadJobExecutor) Job() Job
- func (e *ThreadJobExecutor) LaunchJob(ctx context.Context, job Job) error
- func (e *ThreadJobExecutor) LaunchRunningJob(ctx context.Context, info RunningJobInfo) error
- func (e *ThreadJobExecutor) RunningJob() *RunningJobInfo
- func (e *ThreadJobExecutor) Started() bool
- func (e *ThreadJobExecutor) Status() JobStatus
Constants ¶
View Source
const ( WorkerURLEnvVar = "LIVEKIT_URL" WorkerAPIKeyEnvVar = "LIVEKIT_API_KEY" WorkerAPISecretEnvVar = "LIVEKIT_API_SECRET" ProcessIDEnvVar = "LIVEKIT_AGENT_PROCESS_ID" JobJSONEnvVar = "LIVEKIT_AGENT_JOB_JSON" RunningJobJSONEnvVar = "LIVEKIT_AGENT_RUNNING_JOB_JSON" )
Variables ¶
View Source
var ErrProcPoolClosed = errors.New("proc pool closed")
View Source
var ErrUnknownMessageType = errors.New("unknown IPC message type")
View Source
var ErrUnknownPayloadType = errors.New("unknown IPC payload type")
Functions ¶
func DecodePayload ¶ added in v0.0.15
func ProcessJobEnv ¶ added in v0.1.0
func ProcessJobEnv(baseEnv []string, processID string, info RunningJobInfo) ([]string, error)
Types ¶
type ActiveJobsRequest ¶ added in v0.0.15
type ActiveJobsRequest struct{}
type ActiveJobsResponse ¶ added in v0.0.15
type ActiveJobsResponse struct {
Jobs []RunningJobInfo `json:"jobs,omitempty"`
ReloadCount int `json:"reload_count"`
}
type DumpStackTraceRequest ¶ added in v0.0.15
type DumpStackTraceRequest struct{}
type ExecutorType ¶
type ExecutorType string
const ( ExecutorTypeThread ExecutorType = "thread" ExecutorTypeProcess ExecutorType = "process" )
type InferenceRequest ¶ added in v0.0.15
type InferenceResponse ¶ added in v0.0.15
type InitializeRequest ¶
type InitializeResponse ¶
type InitializeResponse struct {
Error string `json:"error,omitempty"`
}
type JSONJob ¶ added in v0.1.0
type JSONJob struct {
ID string
// contains filtered or unexported fields
}
func (JSONJob) MarshalJSON ¶ added in v0.1.0
func (*JSONJob) RawJSON ¶ added in v0.1.0
func (j *JSONJob) RawJSON() json.RawMessage
func (*JSONJob) UnmarshalJSON ¶ added in v0.1.0
type JobAcceptArguments ¶ added in v0.0.15
type JobExecutor ¶
type Message ¶
type Message struct {
Type MessageType `json:"type"`
Payload json.RawMessage `json:"payload,omitempty"`
}
func NewMessage ¶ added in v0.0.15
type MessageType ¶
type MessageType string
const ( MessageTypeInitializeRequest MessageType = "initialize_request" MessageTypeInitializeResponse MessageType = "initialize_response" MessageTypePingRequest MessageType = "ping_request" MessageTypePongResponse MessageType = "pong_response" MessageTypeStartJobRequest MessageType = "start_job_request" MessageTypeShutdownRequest MessageType = "shutdown_request" MessageTypeExiting MessageType = "exiting" MessageTypeInferenceRequest MessageType = "inference_request" MessageTypeInferenceResponse MessageType = "inference_response" MessageTypeDumpStackTrace MessageType = "dump_stack_trace_request" MessageTypeShutdownRequestAck MessageType = "shutdown_request_ack" MessageTypeShuttingDown MessageType = "shutting_down" MessageTypeActiveJobsRequest MessageType = "active_jobs_request" MessageTypeActiveJobsResponse MessageType = "active_jobs_response" MessageTypeReloadJobsRequest MessageType = "reload_jobs_request" MessageTypeReloadJobsResponse MessageType = "reload_jobs_response" MessageTypeReloaded MessageType = "reloaded" )
type PingRequest ¶
type PingRequest struct {
Timestamp int64 `json:"timestamp"`
}
type PongResponse ¶
type ProcPool ¶
type ProcPool struct {
// contains filtered or unexported fields
}
func NewProcPool ¶
func NewProcPool(maxProcesses int, executorType ExecutorType, entrypoint func() error) *ProcPool
func (*ProcPool) ActiveJobs ¶ added in v0.0.15
func (p *ProcPool) ActiveJobs() []RunningJobInfo
func (*ProcPool) GetByJobID ¶ added in v0.0.15
func (p *ProcPool) GetByJobID(jobID string) JobExecutor
func (*ProcPool) GetExecutors ¶
func (p *ProcPool) GetExecutors() []JobExecutor
func (*ProcPool) LaunchRunningJob ¶ added in v0.0.15
func (p *ProcPool) LaunchRunningJob(ctx context.Context, info RunningJobInfo) error
func (*ProcPool) On ¶ added in v0.0.15
func (p *ProcPool) On(event ProcPoolEvent, handler func(JobExecutor))
func (*ProcPool) SetCloseTimeout ¶ added in v0.0.15
func (*ProcPool) SetTargetIdleProcesses ¶ added in v0.0.15
func (*ProcPool) TargetIdleProcesses ¶ added in v0.0.15
type ProcPoolEvent ¶ added in v0.0.15
type ProcPoolEvent string
const ( ProcPoolEventProcessCreated ProcPoolEvent = "process_created" ProcPoolEventProcessStarted ProcPoolEvent = "process_started" ProcPoolEventProcessReady ProcPoolEvent = "process_ready" ProcPoolEventJobLaunched ProcPoolEvent = "process_job_launched" ProcPoolEventProcessClosed ProcPoolEvent = "process_closed" )
type ProcessJobExecutor ¶
type ProcessJobExecutor struct {
// contains filtered or unexported fields
}
func NewProcessJobExecutor ¶
func NewProcessJobExecutor(id string) *ProcessJobExecutor
func (*ProcessJobExecutor) HandlePong ¶ added in v0.0.15
func (e *ProcessJobExecutor) HandlePong(PongResponse)
func (*ProcessJobExecutor) HandleShutdownRequestAck ¶ added in v0.1.0
func (e *ProcessJobExecutor) HandleShutdownRequestAck(ShutdownRequestAck)
func (*ProcessJobExecutor) HandleShuttingDown ¶ added in v0.1.0
func (e *ProcessJobExecutor) HandleShuttingDown(ShuttingDown)
func (*ProcessJobExecutor) ID ¶
func (e *ProcessJobExecutor) ID() string
func (*ProcessJobExecutor) Job ¶ added in v0.0.15
func (e *ProcessJobExecutor) Job() Job
func (*ProcessJobExecutor) LaunchJob ¶
func (e *ProcessJobExecutor) LaunchJob(ctx context.Context, job Job) error
func (*ProcessJobExecutor) LaunchRunningJob ¶ added in v0.0.15
func (e *ProcessJobExecutor) LaunchRunningJob(ctx context.Context, info RunningJobInfo) error
func (*ProcessJobExecutor) RunningJob ¶ added in v0.0.15
func (e *ProcessJobExecutor) RunningJob() *RunningJobInfo
func (*ProcessJobExecutor) SetCloseTimeout ¶ added in v0.1.0
func (e *ProcessJobExecutor) SetCloseTimeout(timeout time.Duration)
func (*ProcessJobExecutor) Started ¶
func (e *ProcessJobExecutor) Started() bool
func (*ProcessJobExecutor) Status ¶
func (e *ProcessJobExecutor) Status() JobStatus
type ReloadJobsRequest ¶ added in v0.0.15
type ReloadJobsRequest struct{}
type ReloadJobsResponse ¶ added in v0.0.15
type ReloadJobsResponse struct {
Jobs []RunningJobInfo `json:"jobs,omitempty"`
ReloadCount int `json:"reload_count"`
}
type RunningJobInfo ¶ added in v0.0.15
type RunningJobInfo struct {
AcceptArguments JobAcceptArguments `json:"accept_arguments"`
Job Job `json:"job"`
URL string `json:"url"`
Token string `json:"token"`
WorkerID string `json:"worker_id"`
FakeJob bool `json:"fake_job"`
}
func CloneRunningJobInfo ¶ added in v0.1.0
func CloneRunningJobInfo(info RunningJobInfo) RunningJobInfo
func RunningJobInfoFromEnv ¶ added in v0.0.15
func RunningJobInfoFromEnv(env map[string]string) (RunningJobInfo, error)
func (RunningJobInfo) MarshalJSON ¶ added in v0.1.0
func (info RunningJobInfo) MarshalJSON() ([]byte, error)
func (*RunningJobInfo) UnmarshalJSON ¶ added in v0.1.0
func (info *RunningJobInfo) UnmarshalJSON(data []byte) error
type ShutdownRequest ¶
type ShutdownRequest struct {
Reason string `json:"reason"`
}
type ShutdownRequestAck ¶ added in v0.0.15
type ShutdownRequestAck struct{}
type ShuttingDown ¶ added in v0.0.15
type ShuttingDown struct{}
type StartJobRequest ¶
type StartJobRequest struct {
RunningJob RunningJobInfo `json:"running_job"`
}
type ThreadJobExecutor ¶
type ThreadJobExecutor struct {
// contains filtered or unexported fields
}
func NewThreadJobExecutor ¶
func NewThreadJobExecutor(id string, entrypoint func() error) *ThreadJobExecutor
func (*ThreadJobExecutor) ID ¶
func (e *ThreadJobExecutor) ID() string
func (*ThreadJobExecutor) Job ¶ added in v0.0.15
func (e *ThreadJobExecutor) Job() Job
func (*ThreadJobExecutor) LaunchJob ¶
func (e *ThreadJobExecutor) LaunchJob(ctx context.Context, job Job) error
func (*ThreadJobExecutor) LaunchRunningJob ¶ added in v0.0.15
func (e *ThreadJobExecutor) LaunchRunningJob(ctx context.Context, info RunningJobInfo) error
func (*ThreadJobExecutor) RunningJob ¶ added in v0.0.15
func (e *ThreadJobExecutor) RunningJob() *RunningJobInfo
func (*ThreadJobExecutor) Started ¶
func (e *ThreadJobExecutor) Started() bool
func (*ThreadJobExecutor) Status ¶
func (e *ThreadJobExecutor) Status() JobStatus
Click to show internal directories.
Click to hide internal directories.