worker

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: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkerTypeRoom      = workerlivekit.WorkerTypeRoom
	WorkerTypePublisher = workerlivekit.WorkerTypePublisher
)
View Source
const (
	AutoSubscribeSubscribeAll  = workerlivekit.AutoSubscribeSubscribeAll
	AutoSubscribeSubscribeNone = workerlivekit.AutoSubscribeSubscribeNone
	AutoSubscribeAudioOnly     = workerlivekit.AutoSubscribeAudioOnly
	AutoSubscribeVideoOnly     = workerlivekit.AutoSubscribeVideoOnly
)
View Source
const WorkerProtocolVersion = 1

Variables

This section is empty.

Functions

func ValidateWorkerTransport added in v0.1.0

func ValidateWorkerTransport(value WorkerTransport) error

Types

type AcceptedJobRoomConnectOptions added in v0.1.0

type AcceptedJobRoomConnectOptions = workerlivekit.AcceptedJobRoomConnectOptions

type AgentNameEnvOptions added in v0.1.0

type AgentNameEnvOptions = workerlivekit.AgentNameEnvOptions

type AgentServer

type AgentServer struct {
	Options WorkerOptions
	// contains filtered or unexported fields
}

func NewAgentServer

func NewAgentServer(opts WorkerOptions) *AgentServer

func (*AgentServer) ActiveJobs added in v0.0.15

func (s *AgentServer) ActiveJobs() []*JobContext

func (*AgentServer) ActiveRunningJobs added in v0.0.15

func (s *AgentServer) ActiveRunningJobs() []workeripc.RunningJobInfo

func (*AgentServer) Drain added in v0.0.5

func (s *AgentServer) Drain(ctx context.Context) error

func (*AgentServer) DrainWithTimeout added in v0.0.15

func (s *AgentServer) DrainWithTimeout(ctx context.Context, timeout time.Duration) error

func (*AgentServer) Draining added in v0.0.15

func (s *AgentServer) Draining() bool

func (*AgentServer) ExecuteLocalJob

func (s *AgentServer) ExecuteLocalJob(ctx context.Context, roomName string, participantIdentity string) error

ExecuteLocalJob runs a job locally without connecting to the worker service, useful for the CLI console

func (*AgentServer) ExecuteLocalJobWithOptions added in v0.0.15

func (s *AgentServer) ExecuteLocalJobWithOptions(ctx context.Context, roomName string, participantIdentity string, options LocalJobOptions) error

func (*AgentServer) ExecuteRunningJob added in v0.0.15

func (s *AgentServer) ExecuteRunningJob(ctx context.Context, info workeripc.RunningJobInfo) error

func (*AgentServer) GetConsoleSession

func (s *AgentServer) GetConsoleSession() any

GetConsoleSession retrieves the active local console session

func (*AgentServer) ID added in v0.0.15

func (s *AgentServer) ID() string

func (*AgentServer) OnWorkerRegistered added in v0.0.15

func (s *AgentServer) OnWorkerRegistered(handler WorkerRegisteredHandler)

func (*AgentServer) OnWorkerRegisteredInfo added in v0.1.0

func (s *AgentServer) OnWorkerRegisteredInfo(handler WorkerRegisteredInfoHandler)

func (*AgentServer) OnWorkerStarted added in v0.0.15

func (s *AgentServer) OnWorkerStarted(handler WorkerStartedHandler)

func (*AgentServer) RTCSession

func (s *AgentServer) RTCSession(
	entrypoint func(*JobContext) error,
	request func(*JobRequest) error,
	sessionEnd func(*JobContext) error,
) error

func (*AgentServer) ReloadRunningJobs added in v0.0.15

func (s *AgentServer) ReloadRunningJobs(ctx context.Context, jobs []workeripc.RunningJobInfo, now time.Time) error

func (*AgentServer) Run

func (s *AgentServer) Run(ctx context.Context) error

func (*AgentServer) RunUnregistered added in v0.0.15

func (s *AgentServer) RunUnregistered(ctx context.Context) error

func (*AgentServer) SetConsoleSession

func (s *AgentServer) SetConsoleSession(session any)

SetConsoleSession allows entrypoints to register their session for console interaction

func (*AgentServer) SetTransportRunFunc added in v0.1.0

func (s *AgentServer) SetTransportRunFunc(fn func(context.Context) error)

func (*AgentServer) UpdateOptions added in v0.0.15

func (s *AgentServer) UpdateOptions(opts WorkerOptions) error

func (*AgentServer) WorkerInfo added in v0.0.15

func (s *AgentServer) WorkerInfo() WorkerInfo

type AssignmentContextValueOptions added in v0.1.0

type AssignmentContextValueOptions = workerlivekit.AssignmentContextValueOptions

type AutoSubscribe added in v0.0.15

type AutoSubscribe = workerlivekit.AutoSubscribe

type AvailabilityAnswerOptions added in v0.1.0

type AvailabilityAnswerOptions = workerlivekit.AvailabilityAnswerOptions

type AvailabilityRequest added in v0.1.0

type AvailabilityRequest = workerlivekit.AvailabilityRequest

type ClaimGrants added in v0.1.0

type ClaimGrants = workerlivekit.ClaimGrants

type ConnectOptions added in v0.0.15

type ConnectOptions = workerlivekit.ConnectOptions

type DeleteRoomResponse added in v0.1.0

type DeleteRoomResponse = workerlivekit.DeleteRoomResponse

type EntrypointResult added in v0.1.0

type EntrypointResult = workerlivekit.EntrypointResult

type Job added in v0.1.0

type Job = workerlivekit.Job

type JobAPI added in v0.0.15

type JobAPI = workerlivekit.JobAPI

func NewJobAPI added in v0.0.15

func NewJobAPI(url string, apiKey string, apiSecret string) *JobAPI

type JobAcceptArguments

type JobAcceptArguments = workerlivekit.JobAcceptArguments

type JobAssignment added in v0.1.0

type JobAssignment = workerlivekit.JobAssignment

type JobContext

type JobContext struct {
	Job             *Job
	Room            *SDKRoom
	Report          *agent.SessionReport
	AcceptArguments JobAcceptArguments
	// contains filtered or unexported fields
}

func GetCurrentJobContext added in v0.0.15

func GetCurrentJobContext() (*JobContext, bool)

GetCurrentJobContext is an alias for GetJobContext kept for reference parity with LiveKit Agents' get_current_job_context name.

func GetJobContext added in v0.0.15

func GetJobContext() (*JobContext, bool)

GetJobContext returns the JobContext currently executing on this goroutine.

This mirrors LiveKit Agents' get_job_context helper for code that runs inside a worker job entrypoint. Go does not have Python contextvars, so newly spawned goroutines should receive the JobContext explicitly instead of relying on this helper.

func NewJobContext

func NewJobContext(job *Job, url string, apiKey string, apiSecret string) *JobContext

func RequireCurrentJobContext added in v0.0.15

func RequireCurrentJobContext() (*JobContext, error)

func RequireJobContext added in v0.0.15

func RequireJobContext() (*JobContext, error)

func (*JobContext) API added in v0.0.15

func (c *JobContext) API() *JobAPI

func (*JobContext) AddParticipantEntrypoint added in v0.0.15

func (c *JobContext) AddParticipantEntrypoint(entrypoint ParticipantEntrypoint, kinds ...ParticipantInfoKind) error

func (*JobContext) AddSIPParticipant

func (c *JobContext) AddSIPParticipant(ctx context.Context, callTo string, trunkID string, identity string, names ...string) (*SIPParticipantInfo, error)

AddSIPParticipant adds a SIP participant to the room.

func (*JobContext) AddShutdownCallback added in v0.0.15

func (c *JobContext) AddShutdownCallback(callback any) error

func (*JobContext) Agent added in v0.0.15

func (c *JobContext) Agent() *LocalParticipant

func (*JobContext) AvatarStartInfo added in v0.0.15

func (c *JobContext) AvatarStartInfo() agent.AvatarStartInfo

func (*JobContext) Connect

func (c *JobContext) Connect(ctx context.Context, cb *RoomCallback, options ...ConnectOptions) error

func (*JobContext) ConnectPreparedRoom added in v0.1.0

func (c *JobContext) ConnectPreparedRoom(ctx context.Context, room *SDKRoom, options ...ConnectOptions) error

func (*JobContext) CreateSIPParticipant added in v0.0.15

func (c *JobContext) CreateSIPParticipant(ctx context.Context, req *SIPCreateParticipantRequest) (*SIPParticipantInfo, error)

func (*JobContext) DeleteRoom

func (c *JobContext) DeleteRoom(ctx context.Context, roomName string) (*DeleteRoomResponse, error)

DeleteRoom deletes the room and disconnects all participants.

func (*JobContext) InitRecording added in v0.0.15

func (c *JobContext) InitRecording(options agent.RecordingOptions)

func (*JobContext) IsFakeJob added in v0.0.15

func (c *JobContext) IsFakeJob() bool

func (*JobContext) JobID added in v0.0.15

func (c *JobContext) JobID() string

func (*JobContext) LocalParticipantIdentity added in v0.0.15

func (c *JobContext) LocalParticipantIdentity() string

func (*JobContext) LogContextFields added in v0.0.15

func (c *JobContext) LogContextFields() map[string]any

func (*JobContext) MakeSessionReport added in v0.0.15

func (c *JobContext) MakeSessionReport(sessions ...*agent.AgentSession) (*agent.SessionReport, error)

func (*JobContext) MoveParticipant added in v0.0.15

func (c *JobContext) MoveParticipant(ctx context.Context, room string, identity string, destinationRoom string) error

func (*JobContext) NewRoom added in v0.1.0

func (c *JobContext) NewRoom(cb *RoomCallback, options ...ConnectOptions) *SDKRoom

func (*JobContext) ParticipantIdentity added in v0.0.15

func (c *JobContext) ParticipantIdentity() string

func (*JobContext) PrimarySession added in v0.0.15

func (c *JobContext) PrimarySession() (*agent.AgentSession, error)

func (*JobContext) Proc added in v0.0.15

func (c *JobContext) Proc() *JobProcess

func (*JobContext) PublisherInfo added in v0.0.15

func (c *JobContext) PublisherInfo() *ParticipantInfo

func (*JobContext) RoomInfo added in v0.0.15

func (c *JobContext) RoomInfo() *Room

func (*JobContext) SessionDirectory added in v0.0.11

func (c *JobContext) SessionDirectory() string

func (*JobContext) SetLogContextFields added in v0.0.15

func (c *JobContext) SetLogContextFields(fields map[string]any)

func (*JobContext) SetPrimarySession added in v0.0.15

func (c *JobContext) SetPrimarySession(session *agent.AgentSession)

func (*JobContext) SetSessionDirectory added in v0.0.15

func (c *JobContext) SetSessionDirectory(path string)

func (*JobContext) Shutdown

func (c *JobContext) Shutdown(reasons ...string)

func (*JobContext) ShutdownDone added in v0.0.18

func (c *JobContext) ShutdownDone() <-chan struct{}

func (*JobContext) StartSession added in v0.1.6

func (c *JobContext) StartSession(ctx context.Context, session *agent.AgentSession, options ...StartSessionOptions) error

func (*JobContext) Tagger added in v0.0.15

func (c *JobContext) Tagger() *agent.Tagger

func (*JobContext) Terminated added in v0.0.18

func (c *JobContext) Terminated() bool

func (*JobContext) TokenClaims added in v0.0.15

func (c *JobContext) TokenClaims() (*ClaimGrants, error)

func (*JobContext) TransferSIPParticipant

func (c *JobContext) TransferSIPParticipant(ctx context.Context, identity string, transferTo string, playDialtones ...bool) error

TransferSIPParticipant transfers a SIP participant to another number.

func (*JobContext) TransferSIPParticipantByParticipant added in v0.0.15

func (c *JobContext) TransferSIPParticipantByParticipant(ctx context.Context, participant any, transferTo string, playDialtones ...bool) error

func (*JobContext) WaitForAgent added in v0.0.15

func (c *JobContext) WaitForAgent(
	ctx context.Context,
	agentName ...string,
) (*RemoteParticipant, error)

func (*JobContext) WaitForParticipant added in v0.0.15

func (c *JobContext) WaitForParticipant(
	ctx context.Context,
	identity string,
	kinds ...ParticipantInfoKind,
) (*RemoteParticipant, error)

func (*JobContext) WaitForParticipantAttribute added in v0.0.15

func (c *JobContext) WaitForParticipantAttribute(
	ctx context.Context,
	identity string,
	attribute string,
	value string,
) error

func (*JobContext) WaitForTrackPublication added in v0.0.15

func (c *JobContext) WaitForTrackPublication(
	ctx context.Context,
	identity string,
	kinds ...TrackType,
) (*RemoteTrackPublication, error)

func (*JobContext) WaitForTrackPublicationWithOptions added in v0.0.15

func (c *JobContext) WaitForTrackPublicationWithOptions(
	ctx context.Context,
	options TrackPublicationWaitOptions,
) (*RemoteTrackPublication, error)

func (*JobContext) WorkerID added in v0.0.15

func (c *JobContext) WorkerID() string

type JobEntrypointLifecycleOptions added in v0.1.0

type JobEntrypointLifecycleOptions = workerlivekit.JobEntrypointLifecycleOptions

type JobExecutorType added in v0.0.15

type JobExecutorType = workeripc.ExecutorType
const (
	JobExecutorTypeThread  JobExecutorType = workeripc.ExecutorTypeThread
	JobExecutorTypeProcess JobExecutorType = workeripc.ExecutorTypeProcess
)

type JobProcess added in v0.0.15

type JobProcess struct {
	// contains filtered or unexported fields
}

func NewJobProcess added in v0.0.15

func NewJobProcess(executorType JobExecutorType, userArguments any, httpProxy string) *JobProcess

func (*JobProcess) ExecutorType added in v0.0.15

func (p *JobProcess) ExecutorType() JobExecutorType

func (*JobProcess) HTTPProxy added in v0.0.15

func (p *JobProcess) HTTPProxy() string

func (*JobProcess) PID added in v0.0.15

func (p *JobProcess) PID() int

func (*JobProcess) UserArguments added in v0.0.15

func (p *JobProcess) UserArguments() any

func (*JobProcess) Userdata added in v0.0.15

func (p *JobProcess) Userdata() map[any]any

type JobRejectArguments added in v0.0.15

type JobRejectArguments = workerlivekit.JobRejectArguments

type JobRequest

type JobRequest = workerlivekit.JobRequest

type JobRoomServiceAPI added in v0.0.15

type JobRoomServiceAPI = workerlivekit.JobRoomServiceAPI

type JobSIPAPI added in v0.0.15

type JobSIPAPI = workerlivekit.JobSIPAPI

type JobSessionEndPlanOptions added in v0.1.0

type JobSessionEndPlanOptions = workerlivekit.JobSessionEndPlanOptions

type JobSessionReportUploadPlanOptions added in v0.1.0

type JobSessionReportUploadPlanOptions = workerlivekit.JobSessionReportUploadPlanOptions

type JobSessionReportUploadPlanResult added in v0.1.0

type JobSessionReportUploadPlanResult = workerlivekit.JobSessionReportUploadPlanResult

type JobStatus added in v0.1.0

type JobStatus = workerlivekit.JobStatus

type JobTermination added in v0.1.0

type JobTermination = workerlivekit.JobTermination

type LocalJobContextSetupPlanOptions added in v0.1.0

type LocalJobContextSetupPlanOptions = workerlivekit.LocalJobContextSetupPlanOptions

type LocalJobOptions added in v0.0.15

type LocalJobOptions = workerlivekit.LocalJobOptions

type LocalParticipant added in v0.1.0

type LocalParticipant = workerlivekit.LocalParticipant

type ParticipantEntrypoint added in v0.0.15

type ParticipantEntrypoint func(*JobContext, *ParticipantInfo)

type ParticipantEntrypointRegistrationOptions added in v0.1.0

type ParticipantEntrypointRegistrationOptions = workerlivekit.ParticipantEntrypointRegistrationOptions

type ParticipantInfo added in v0.1.0

type ParticipantInfo = workerlivekit.ParticipantInfo

type ParticipantInfoKind added in v0.1.0

type ParticipantInfoKind = workerlivekit.ParticipantInfoKind

type ParticipantTaskKey added in v0.1.0

type ParticipantTaskKey = workerlivekit.ParticipantTaskKey

type PendingAcceptStoreOptions added in v0.1.0

type PendingAcceptStoreOptions = workerlivekit.PendingAcceptStoreOptions

type ReloadedJobContextValueOptions added in v0.1.0

type ReloadedJobContextValueOptions = workerlivekit.ReloadedJobContextValueOptions

type ReloadedJobEntrypointLifecycleOptions added in v0.1.0

type ReloadedJobEntrypointLifecycleOptions = workerlivekit.ReloadedJobEntrypointLifecycleOptions

type RemoteParticipant added in v0.1.0

type RemoteParticipant = workerlivekit.RemoteParticipant

type RemoteParticipantView added in v0.1.0

type RemoteParticipantView = workerlivekit.RemoteParticipantView

type RemoteTrackPublication added in v0.1.0

type RemoteTrackPublication = workerlivekit.RemoteTrackPublication

type RemoteTrackSubscriptionResult added in v0.1.0

type RemoteTrackSubscriptionResult = workerlivekit.RemoteTrackSubscriptionResult

type Room added in v0.0.14

type Room = workerlivekit.Room

type RoomCallback added in v0.1.0

type RoomCallback = workerlivekit.RoomCallback

type RoomCallbackHandlers added in v0.1.0

type RoomCallbackHandlers = workerlivekit.RoomCallbackHandlers

type RoomConnector added in v0.1.0

type RoomConnector = workerlivekit.RoomConnector

type RoomOptions

type RoomOptions = workerlivekit.RoomOptions

type RunningJobContextValueOptions added in v0.1.0

type RunningJobContextValueOptions = workerlivekit.RunningJobContextValueOptions

type RunningJobEntrypointLifecycleOptions added in v0.1.0

type RunningJobEntrypointLifecycleOptions = workerlivekit.RunningJobEntrypointLifecycleOptions

type RunningJobInfoOptions added in v0.1.0

type RunningJobInfoOptions = workerlivekit.RunningJobInfoOptions

type SDKRoom added in v0.1.0

type SDKRoom = workerlivekit.SDKRoom

type SIPCreateParticipantRequest added in v0.1.0

type SIPCreateParticipantRequest = workerlivekit.SIPCreateParticipantRequest

type SIPParticipantInfo added in v0.1.0

type SIPParticipantInfo = workerlivekit.SIPParticipantInfo

type ServerAvailableWorkerStatusMessageOptions added in v0.1.0

type ServerAvailableWorkerStatusMessageOptions = workerlivekit.ServerAvailableWorkerStatusMessageOptions

type ServerConnectionEnvOptions added in v0.1.0

type ServerConnectionEnvOptions = workerlivekit.ServerConnectionEnvOptions

type ServerConnectionOptions added in v0.1.0

type ServerConnectionOptions = workerlivekit.ServerConnectionOptions

type ServerConnectionResolveOptions added in v0.1.0

type ServerConnectionResolveOptions = workerlivekit.ServerConnectionResolveOptions

type ServerInfo added in v0.1.0

type ServerInfo = workerlivekit.ServerInfo

type ServerMessage added in v0.1.0

type ServerMessage = workerlivekit.ServerMessage

type ServerMessageLoopOptions added in v0.1.0

type ServerMessageLoopOptions = workerlivekit.ServerMessageLoopOptions

type ServerMessageRouteOptions added in v0.1.0

type ServerMessageRouteOptions = workerlivekit.ServerMessageRouteOptions

type ServerRegisterWorkerMessageOptions added in v0.1.0

type ServerRegisterWorkerMessageOptions = workerlivekit.ServerRegisterWorkerMessageOptions

type StartSessionOptions added in v0.1.6

type StartSessionOptions struct {
	RoomOptions    RoomOptions
	ConnectOptions []ConnectOptions
	RoomCallback   *RoomCallback
	SessionContext context.Context
}

type TrackPublicationWaitOptions added in v0.1.0

type TrackPublicationWaitOptions = workerlivekit.TrackPublicationWaitOptions

type TrackType added in v0.1.0

type TrackType = workerlivekit.TrackType

type WorkerInfo added in v0.0.15

type WorkerInfo struct {
	HTTPPort    int
	CloudAgents bool
}

type WorkerMessage added in v0.1.0

type WorkerMessage = workerlivekit.WorkerMessage

type WorkerOptions

type WorkerOptions struct {
	AgentName       string
	AgentNameIsEnv  bool
	WorkerType      WorkerType
	Transport       WorkerTransport
	JobExecutorType JobExecutorType
	MaxRetry        int
	MaxRetrySet     bool
	Version         string
	Host            string
	Port            int
	PortSet         bool
	WSURL           string
	LoadFunc        func(*AgentServer) float64
	HealthCheck     func(*AgentServer) error
	SetupFunc       func(*JobProcess) error
	// WSRL is kept for backward compatibility. Prefer WSURL for new code.
	WSRL                               string
	APIKey                             string
	APISecret                          string
	WorkerToken                        string
	HTTPProxy                          string
	HTTPProxySet                       bool
	UserArguments                      any
	DevMode                            bool
	Simulation                         bool
	LogLevel                           string
	PrometheusPort                     int
	PrometheusPortSet                  bool
	PrometheusMultiprocDir             string
	LoadThreshold                      float64
	LoadThresholdSet                   bool
	JobMemoryWarnMB                    float64
	JobMemoryWarnMBSet                 bool
	JobMemoryLimitMB                   float64
	JobMemoryLimitMBSet                bool
	NumIdleProcesses                   int
	NumIdleProcessesSet                bool
	DrainTimeoutSeconds                int
	DrainTimeoutSecondsSet             bool
	SessionEndTimeoutSeconds           float64
	SessionEndTimeoutSecondsSet        bool
	ShutdownProcessTimeoutSeconds      float64
	ShutdownProcessTimeoutSecondsSet   bool
	InitializeProcessTimeoutSeconds    float64
	InitializeProcessTimeoutSecondsSet bool
	Permissions                        *WorkerPermissions
}

type WorkerPermissions added in v0.0.15

type WorkerPermissions = workerlivekit.WorkerPermissions

type WorkerRegisteredEvent added in v0.1.0

type WorkerRegisteredEvent = workerlivekit.WorkerRegisteredEvent

type WorkerRegisteredHandler added in v0.0.15

type WorkerRegisteredHandler = workerlivekit.WorkerRegisteredHandler

type WorkerRegisteredInfo added in v0.1.0

type WorkerRegisteredInfo struct {
	WorkerID string
}

type WorkerRegisteredInfoHandler added in v0.1.0

type WorkerRegisteredInfoHandler func(WorkerRegisteredInfo)

type WorkerRuntimeMetadataOptions added in v0.1.0

type WorkerRuntimeMetadataOptions = workerlivekit.WorkerRuntimeMetadataOptions

type WorkerStartedHandler added in v0.0.15

type WorkerStartedHandler func()

type WorkerTransport added in v0.1.0

type WorkerTransport string
const (
	WorkerTransportLiveKit WorkerTransport = "livekit"
	WorkerTransportAgora   WorkerTransport = "agora"
)

func NormalizeWorkerTransport added in v0.1.0

func NormalizeWorkerTransport(value string) WorkerTransport

type WorkerType

type WorkerType = workerlivekit.WorkerType

type WorkerWebSocketOpenOptions added in v0.1.0

type WorkerWebSocketOpenOptions = workerlivekit.WorkerWebSocketOpenOptions

type WorkerWebSocketOpenResult added in v0.1.0

type WorkerWebSocketOpenResult = workerlivekit.WorkerWebSocketOpenResult

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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