* Added AgentRegistered broadcast to clients * generated protobuf --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
180 lines
7.0 KiB
Go
180 lines
7.0 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, topic string, req *livekit1.Job, opts ...psrpc.RequestOption) (*google_protobuf.Empty, error)
|
|
|
|
SubscribeAgentRegistered(ctx context.Context, projectId string) (psrpc.Subscription[*CheckEnabledResponse], 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(topic string) error
|
|
DeregisterJobRequestTopic(topic string)
|
|
PublishAgentRegistered(ctx context.Context, projectId string, msg *CheckEnabledResponse) 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("AgentRegistered", 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, topic string, req *livekit1.Job, opts ...psrpc.RequestOption) (*google_protobuf.Empty, error) {
|
|
return client.RequestSingle[*google_protobuf.Empty](ctx, c.client, "JobRequest", []string{topic}, req, opts...)
|
|
}
|
|
|
|
func (c *agentInternalClient) SubscribeAgentRegistered(ctx context.Context, projectId string) (psrpc.Subscription[*CheckEnabledResponse], error) {
|
|
return client.Join[*CheckEnabledResponse](ctx, c.client, "AgentRegistered", []string{projectId})
|
|
}
|
|
|
|
// ====================
|
|
// 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("AgentRegistered", false, true, false, false)
|
|
return &agentInternalServer{
|
|
svc: svc,
|
|
rpc: s,
|
|
}, nil
|
|
}
|
|
|
|
func (s *agentInternalServer) RegisterJobRequestTopic(topic string) error {
|
|
return server.RegisterHandler(s.rpc, "JobRequest", []string{topic}, s.svc.JobRequest, s.svc.JobRequestAffinity)
|
|
}
|
|
|
|
func (s *agentInternalServer) DeregisterJobRequestTopic(topic string) {
|
|
s.rpc.DeregisterHandler("JobRequest", []string{topic})
|
|
}
|
|
|
|
func (s *agentInternalServer) PublishAgentRegistered(ctx context.Context, projectId string, msg *CheckEnabledResponse) error {
|
|
return s.rpc.Publish(ctx, "AgentRegistered", []string{projectId}, msg)
|
|
}
|
|
|
|
func (s *agentInternalServer) Shutdown() {
|
|
s.rpc.Close(false)
|
|
}
|
|
|
|
func (s *agentInternalServer) Kill() {
|
|
s.rpc.Close(true)
|
|
}
|
|
|
|
var psrpcFileDescriptor0 = []byte{
|
|
// 329 bytes of a gzipped FileDescriptorProto
|
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0x4f, 0x4f, 0xf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