Files
protocol/rpc/agent.psrpc.go
Théo Monnom bc6c7ffd71 agents protocol proposal (#595)
* simulate-job

* generated protobuf

* wip

* job_cost

* Update livekit_agent.proto

* generated protobuf

* Update livekit_agent.proto

* generated protobuf

* Update livekit_agent.proto

* Update livekit_agent.proto

* Update livekit_agent.proto

* generated protobuf

* Update livekit_agent.proto

* renamed to pong

Co-authored-by: David Zhao <dz@livekit.io>

* Update livekit_agent.proto

* Update livekit_agent.proto

* generated protobuf

* remove job_cost & ParticipantPermission

* generated protobuf

* Update livekit_agent.proto

* generated protobuf

* wip

* generated protobuf

* generated protobuf

* Update livekit_agent.proto

* generated protobuf

* generated protobuf

* handler namespace

* generated protobuf

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Zhao <dz@livekit.io>
Co-authored-by: David Colburn <xero73@gmail.com>
2024-04-03 22:49:52 +02: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{
// 367 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xd1, 0x8a, 0xd3, 0x40,
0x14, 0x86, 0x99, 0x56, 0x24, 0x1d, 0x5b, 0x4c, 0xa7, 0x56, 0x6a, 0x44, 0x69, 0x73, 0x55, 0x54,
0x26, 0xa2, 0x2f, 0x50, 0x95, 0x5e, 0x58, 0xf0, 0x26, 0x20, 0x82, 0x37, 0x21, 0x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