testutils

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentJob

type AgentJob struct {
	*livekit.Job
	JobLoad
}

type AgentJobRequest

type AgentJobRequest struct {
	*livekit.AvailabilityRequest
	// contains filtered or unexported fields
}

func (AgentJobRequest) Accept

func (r AgentJobRequest) Accept()

func (AgentJobRequest) Reject

func (r AgentJobRequest) Reject()

type AgentService

type AgentService interface {
	HandleConnection(context.Context, agent.SignalConn, agent.WorkerProtocolVersion)
	DrainConnections(time.Duration)
}

type AgentWorker

type AgentWorker struct {
	*SimulatedWorkerOptions

	RegisterWorkerResponses *events.ObserverList[*livekit.RegisterWorkerResponse]
	AvailabilityRequests    *events.ObserverList[*livekit.AvailabilityRequest]
	JobAssignments          *events.ObserverList[*livekit.JobAssignment]
	JobTerminations         *events.ObserverList[*livekit.JobTermination]
	WorkerPongs             *events.ObserverList[*livekit.WorkerPong]
	// contains filtered or unexported fields
}

func (*AgentWorker) Close

func (w *AgentWorker) Close() error

func (*AgentWorker) Jobs

func (w *AgentWorker) Jobs() []*AgentJob

func (*AgentWorker) ReadWorkerMessage

func (w *AgentWorker) ReadWorkerMessage() (*livekit.WorkerMessage, int, error)

func (*AgentWorker) Register

func (w *AgentWorker) Register(agentName string, jobType livekit.JobType)

func (*AgentWorker) SendAvailability

func (w *AgentWorker) SendAvailability(m *livekit.AvailabilityResponse)

func (*AgentWorker) SendMigrateJob

func (w *AgentWorker) SendMigrateJob(m *livekit.MigrateJobRequest)

func (*AgentWorker) SendPing

func (w *AgentWorker) SendPing(m *livekit.WorkerPing)

func (*AgentWorker) SendRegister

func (w *AgentWorker) SendRegister(m *livekit.RegisterWorkerRequest)

func (*AgentWorker) SendSimulateJob

func (w *AgentWorker) SendSimulateJob(m *livekit.SimulateJobRequest)

func (*AgentWorker) SendUpdateJob

func (w *AgentWorker) SendUpdateJob(m *livekit.UpdateJobStatus)

func (*AgentWorker) SendUpdateWorker

func (w *AgentWorker) SendUpdateWorker(m *livekit.UpdateWorkerStatus)

func (*AgentWorker) SetReadDeadline

func (w *AgentWorker) SetReadDeadline(t time.Time) error

func (*AgentWorker) SimulateRoomJob

func (w *AgentWorker) SimulateRoomJob(roomName string)

func (*AgentWorker) WriteServerMessage

func (w *AgentWorker) WriteServerMessage(m *livekit.ServerMessage) (int, error)

type JobLoad

type JobLoad interface {
	Load() float32
}

func NewNormalRandomJobLoad

func NewNormalRandomJobLoad(mean, stddev float64) JobLoad

func NewNormalRandomJobLoadWithRNG

func NewNormalRandomJobLoadWithRNG(mean, stddev float64, rng *rand.Rand) JobLoad

func NewPeriodicJobLoad

func NewPeriodicJobLoad(max float32, period time.Duration) JobLoad

func NewStableJobLoad

func NewStableJobLoad(load float32) JobLoad

func NewUniformRandomJobLoad

func NewUniformRandomJobLoad(min, max float32) JobLoad

func NewUniformRandomJobLoadWithRNG

func NewUniformRandomJobLoadWithRNG(min, max float32, rng *rand.Rand) JobLoad

type SimulatedWorkerOption

type SimulatedWorkerOption func(*SimulatedWorkerOptions)

func WithContext

func WithContext(ctx context.Context) SimulatedWorkerOption

func WithDefaultWorkerLoad

func WithDefaultWorkerLoad(load float32) SimulatedWorkerOption

func WithJobAssignmentHandler

func WithJobAssignmentHandler(h func(*livekit.Job) JobLoad) SimulatedWorkerOption

func WithJobAvailabilityHandler

func WithJobAvailabilityHandler(h func(AgentJobRequest)) SimulatedWorkerOption

func WithJobLoad

func WithJobLoad(l JobLoad) SimulatedWorkerOption

func WithLabel

func WithLabel(label string) SimulatedWorkerOption

type SimulatedWorkerOptions

type SimulatedWorkerOptions struct {
	Context            context.Context
	Label              string
	SupportResume      bool
	DefaultJobLoad     float32
	JobLoadThreshold   float32
	DefaultWorkerLoad  float32
	HandleAvailability func(AgentJobRequest)
	HandleAssignment   func(*livekit.Job) JobLoad
}

type TestServer

type TestServer struct {
	AgentService
}

func NewTestServer

func NewTestServer(bus psrpc.MessageBus) *TestServer

func NewTestServerWithService

func NewTestServerWithService(s AgentService) *TestServer

func (*TestServer) Close

func (h *TestServer) Close()

func (*TestServer) SimulateAgentWorker

func (h *TestServer) SimulateAgentWorker(opts ...SimulatedWorkerOption) *AgentWorker

Jump to

Keyboard shortcuts

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