ipc

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

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 DecodePayload(msg Message) (any, error)

func JobID added in v0.1.0

func JobID(job Job) string

func ProcessJobEnv added in v0.1.0

func ProcessJobEnv(baseEnv []string, processID string, info RunningJobInfo) ([]string, error)

func WriteMessage added in v0.0.15

func WriteMessage(w io.Writer, msg Message) 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 Exiting

type Exiting struct {
	Reason string `json:"reason"`
}

type InferenceRequest added in v0.0.15

type InferenceRequest struct {
	Method    string `json:"method"`
	RequestID string `json:"request_id"`
	Data      []byte `json:"data"`
}

type InferenceResponse added in v0.0.15

type InferenceResponse struct {
	RequestID string `json:"request_id"`
	Data      []byte `json:"data"`
	Error     string `json:"error,omitempty"`
}

type InitializeRequest

type InitializeRequest struct {
	AsyncioDebug      bool    `json:"asyncio_debug"`
	PingInterval      float64 `json:"ping_interval"`
	PingTimeout       float64 `json:"ping_timeout"`
	HighPingThreshold float64 `json:"high_ping_threshold"`
	HTTPProxy         string  `json:"http_proxy"`
}

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) GetId added in v0.1.0

func (j *JSONJob) GetId() string

func (JSONJob) MarshalJSON added in v0.1.0

func (j JSONJob) MarshalJSON() ([]byte, error)

func (*JSONJob) RawJSON added in v0.1.0

func (j *JSONJob) RawJSON() json.RawMessage

func (*JSONJob) UnmarshalJSON added in v0.1.0

func (j *JSONJob) UnmarshalJSON(data []byte) error

type Job added in v0.1.0

type Job interface {
	GetId() string
}

type JobAcceptArguments added in v0.0.15

type JobAcceptArguments struct {
	Name       string            `json:"name"`
	Identity   string            `json:"identity"`
	Metadata   string            `json:"metadata"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

type JobExecutor

type JobExecutor interface {
	ID() string
	Status() JobStatus
	Started() bool
	Job() Job
	RunningJob() *RunningJobInfo
	LaunchJob(ctx context.Context, job Job) error
	LaunchRunningJob(ctx context.Context, info RunningJobInfo) error
	Close(ctx context.Context) error
}

type JobStatus

type JobStatus string
const (
	JobStatusRunning JobStatus = "running"
	JobStatusFailed  JobStatus = "failed"
	JobStatusSuccess JobStatus = "success"
)

type Message

type Message struct {
	Type    MessageType     `json:"type"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

func NewMessage added in v0.0.15

func NewMessage(payload any) (Message, error)

func ReadMessage added in v0.0.15

func ReadMessage(r io.Reader) (Message, error)

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 PongResponse struct {
	LastTimestamp int64 `json:"last_timestamp"`
	Timestamp     int64 `json:"timestamp"`
}

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) Close

func (p *ProcPool) Close() error

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) LaunchJob

func (p *ProcPool) LaunchJob(ctx context.Context, job Job) error

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 (p *ProcPool) SetCloseTimeout(timeout time.Duration)

func (*ProcPool) SetTargetIdleProcesses added in v0.0.15

func (p *ProcPool) SetTargetIdleProcesses(numIdleProcesses int)

func (*ProcPool) Start added in v0.0.15

func (p *ProcPool) Start(ctx context.Context) error

func (*ProcPool) TargetIdleProcesses added in v0.0.15

func (p *ProcPool) TargetIdleProcesses() int

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) Close

func (e *ProcessJobExecutor) Close(ctx context.Context) error

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 Reloaded added in v0.0.15

type Reloaded struct{}

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) Close

func (e *ThreadJobExecutor) Close(ctx context.Context) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL