Files
protocol/rpc/agent.psrpc.go
Benjamin Pracht 82786f41fd Additions to agent protocol (#717)
This PR:

- Adds StartAgentJobRequest/StopAgentJobRequest calls to start an handle manually mange an agent lifecycle
- Deprecates the JobType field in WorkerInfo as workers will now be expected to handle both kinds jobs (if the namespace supports both kinds in the first place)
- Adds a metadata string -> string map to Job to allow agent implementation to take anonymous (to us) parameters
- Adds a JobStatus and error fields to Job for status reporting (Similar to egress and ingress)
- Makes livekit_agent.proto indentation consistent with other proto files
- Add room configuration and management APIs to the Room service. Rooms configuration allow bundling most room configuration parameters under a single id, that can eventually be put as part of the room creation token.
2024-06-27 10:30:58 -07:00

182 lines
7.4 KiB
Go

// Code generated by protoc-gen-psrpc v0.5.1, DO NOT EDIT.
// source: rpc/agent.proto
package rpc
import (
"context"
"github.com/livekit/psrpc"
"github.com/livekit/psrpc/pkg/client"
"github.com/livekit/psrpc/pkg/info"
"github.com/livekit/psrpc/pkg/rand"
"github.com/livekit/psrpc/pkg/server"
"github.com/livekit/psrpc/version"
)
import google_protobuf "google.golang.org/protobuf/types/known/emptypb"
import livekit1 "github.com/livekit/protocol/livekit"
var _ = version.PsrpcVersion_0_5
// ==============================
// AgentInternal Client Interface
// ==============================
type AgentInternalClient interface {
CheckEnabled(ctx context.Context, req *CheckEnabledRequest, opts ...psrpc.RequestOption) (<-chan *psrpc.Response[*CheckEnabledResponse], error)
JobRequest(ctx context.Context, namespace string, jobType string, req *livekit1.Job, opts ...psrpc.RequestOption) (*google_protobuf.Empty, error)
SubscribeWorkerRegistered(ctx context.Context, handlerNamespace string) (psrpc.Subscription[*google_protobuf.Empty], error)
}
// ==================================
// AgentInternal ServerImpl Interface
// ==================================
type AgentInternalServerImpl interface {
CheckEnabled(context.Context, *CheckEnabledRequest) (*CheckEnabledResponse, error)
JobRequest(context.Context, *livekit1.Job) (*google_protobuf.Empty, error)
JobRequestAffinity(context.Context, *livekit1.Job) float32
}
// ==============================
// AgentInternal Server Interface
// ==============================
type AgentInternalServer interface {
RegisterJobRequestTopic(namespace string, jobType string) error
DeregisterJobRequestTopic(namespace string, jobType string)
PublishWorkerRegistered(ctx context.Context, handlerNamespace string, msg *google_protobuf.Empty) error
// Close and wait for pending RPCs to complete
Shutdown()
// Close immediately, without waiting for pending RPCs
Kill()
}
// ====================
// AgentInternal Client
// ====================
type agentInternalClient struct {
client *client.RPCClient
}
// NewAgentInternalClient creates a psrpc client that implements the AgentInternalClient interface.
func NewAgentInternalClient(bus psrpc.MessageBus, opts ...psrpc.ClientOption) (AgentInternalClient, error) {
sd := &info.ServiceDefinition{
Name: "AgentInternal",
ID: rand.NewClientID(),
}
sd.RegisterMethod("CheckEnabled", false, true, false, false)
sd.RegisterMethod("JobRequest", true, false, true, false)
sd.RegisterMethod("WorkerRegistered", false, true, false, false)
rpcClient, err := client.NewRPCClient(sd, bus, opts...)
if err != nil {
return nil, err
}
return &agentInternalClient{
client: rpcClient,
}, nil
}
func (c *agentInternalClient) CheckEnabled(ctx context.Context, req *CheckEnabledRequest, opts ...psrpc.RequestOption) (<-chan *psrpc.Response[*CheckEnabledResponse], error) {
return client.RequestMulti[*CheckEnabledResponse](ctx, c.client, "CheckEnabled", nil, req, opts...)
}
func (c *agentInternalClient) JobRequest(ctx context.Context, namespace string, jobType string, req *livekit1.Job, opts ...psrpc.RequestOption) (*google_protobuf.Empty, error) {
return client.RequestSingle[*google_protobuf.Empty](ctx, c.client, "JobRequest", []string{namespace, jobType}, req, opts...)
}
func (c *agentInternalClient) SubscribeWorkerRegistered(ctx context.Context, handlerNamespace string) (psrpc.Subscription[*google_protobuf.Empty], error) {
return client.Join[*google_protobuf.Empty](ctx, c.client, "WorkerRegistered", []string{handlerNamespace})
}
// ====================
// AgentInternal Server
// ====================
type agentInternalServer struct {
svc AgentInternalServerImpl
rpc *server.RPCServer
}
// NewAgentInternalServer builds a RPCServer that will route requests
// to the corresponding method in the provided svc implementation.
func NewAgentInternalServer(svc AgentInternalServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (AgentInternalServer, error) {
sd := &info.ServiceDefinition{
Name: "AgentInternal",
ID: rand.NewServerID(),
}
s := server.NewRPCServer(sd, bus, opts...)
sd.RegisterMethod("CheckEnabled", false, true, false, false)
var err error
err = server.RegisterHandler(s, "CheckEnabled", nil, svc.CheckEnabled, nil)
if err != nil {
s.Close(false)
return nil, err
}
sd.RegisterMethod("JobRequest", true, false, true, false)
sd.RegisterMethod("WorkerRegistered", false, true, false, false)
return &agentInternalServer{
svc: svc,
rpc: s,
}, nil
}
func (s *agentInternalServer) RegisterJobRequestTopic(namespace string, jobType string) error {
return server.RegisterHandler(s.rpc, "JobRequest", []string{namespace, jobType}, s.svc.JobRequest, s.svc.JobRequestAffinity)
}
func (s *agentInternalServer) DeregisterJobRequestTopic(namespace string, jobType string) {
s.rpc.DeregisterHandler("JobRequest", []string{namespace, jobType})
}
func (s *agentInternalServer) PublishWorkerRegistered(ctx context.Context, handlerNamespace string, msg *google_protobuf.Empty) error {
return s.rpc.Publish(ctx, "WorkerRegistered", []string{handlerNamespace}, msg)
}
func (s *agentInternalServer) Shutdown() {
s.rpc.Close(false)
}
func (s *agentInternalServer) Kill() {
s.rpc.Close(true)
}
var psrpcFileDescriptor0 = []byte{
// 365 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x8a, 0xdb, 0x30,
0x10, 0x86, 0x91, 0x53, 0x8a, 0xa3, 0x26, 0xd4, 0x51, 0x9a, 0xe2, 0xba, 0x94, 0x26, 0x86, 0x42,
0x4e, 0x72, 0x69, 0x5f, 0x20, 0x4d, 0xc9, 0xa1, 0x81, 0x5e, 0x02, 0xa5, 0xd0, 0x8b, 0xb1, 0x94,
0xa9, 0xed, 0x8d, 0x2d, 0x69, 0x25, 0x79, 0x21, 0x8f, 0x90, 0xeb, 0x9e, 0xf7, 0x29, 0xf2, 0x84,
0x8b, 0x63, 0xc7, 0x64, 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