Files
protocol/rpc/connector.psrpc.go
cnderrauber 8cf58ff15a Add twilio connector (#1254)
* Add twilio connector

* empty lines

* solve comments

* Make optional field consistent with whatsapp connector

* Remove stream direction, add call direction

* generated protobuf

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2025-10-16 10:41:55 +08:00

366 lines
15 KiB
Go

// Code generated by protoc-gen-psrpc v0.7.0, DO NOT EDIT.
// source: rpc/connector.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 livekit10 "github.com/livekit/protocol/livekit"
import livekit11 "github.com/livekit/protocol/livekit"
var _ = version.PsrpcVersion_0_7
// ==================================
// ConnectorInternal Client Interface
// ==================================
type ConnectorInternalClient interface {
DialWhatsAppCall(ctx context.Context, topic string, req *InternalDialWhatsAppCallRequest, opts ...psrpc.RequestOption) (*livekit10.DialWhatsAppCallResponse, error)
AcceptWhatsAppCall(ctx context.Context, topic string, req *InternalAcceptWhatsAppCallRequest, opts ...psrpc.RequestOption) (*livekit10.AcceptWhatsAppCallResponse, error)
ConnectTwilioCall(ctx context.Context, topic string, req *InternalConnectTwilioCallRequest, opts ...psrpc.RequestOption) (*livekit11.ConnectTwilioCallResponse, error)
// Close immediately, without waiting for pending RPCs
Close()
}
// ======================================
// ConnectorInternal ServerImpl Interface
// ======================================
type ConnectorInternalServerImpl interface {
DialWhatsAppCall(context.Context, *InternalDialWhatsAppCallRequest) (*livekit10.DialWhatsAppCallResponse, error)
AcceptWhatsAppCall(context.Context, *InternalAcceptWhatsAppCallRequest) (*livekit10.AcceptWhatsAppCallResponse, error)
ConnectTwilioCall(context.Context, *InternalConnectTwilioCallRequest) (*livekit11.ConnectTwilioCallResponse, error)
}
// ==================================
// ConnectorInternal Server Interface
// ==================================
type ConnectorInternalServer interface {
RegisterDialWhatsAppCallTopic(topic string) error
DeregisterDialWhatsAppCallTopic(topic string)
RegisterAcceptWhatsAppCallTopic(topic string) error
DeregisterAcceptWhatsAppCallTopic(topic string)
RegisterConnectTwilioCallTopic(topic string) error
DeregisterConnectTwilioCallTopic(topic string)
// Close and wait for pending RPCs to complete
Shutdown()
// Close immediately, without waiting for pending RPCs
Kill()
}
// ========================
// ConnectorInternal Client
// ========================
type connectorInternalClient struct {
client *client.RPCClient
}
// NewConnectorInternalClient creates a psrpc client that implements the ConnectorInternalClient interface.
func NewConnectorInternalClient(bus psrpc.MessageBus, opts ...psrpc.ClientOption) (ConnectorInternalClient, error) {
sd := &info.ServiceDefinition{
Name: "ConnectorInternal",
ID: rand.NewClientID(),
}
sd.RegisterMethod("DialWhatsAppCall", false, false, true, true)
sd.RegisterMethod("AcceptWhatsAppCall", false, false, true, true)
sd.RegisterMethod("ConnectTwilioCall", false, false, true, true)
rpcClient, err := client.NewRPCClient(sd, bus, opts...)
if err != nil {
return nil, err
}
return &connectorInternalClient{
client: rpcClient,
}, nil
}
func (c *connectorInternalClient) DialWhatsAppCall(ctx context.Context, topic string, req *InternalDialWhatsAppCallRequest, opts ...psrpc.RequestOption) (*livekit10.DialWhatsAppCallResponse, error) {
return client.RequestSingle[*livekit10.DialWhatsAppCallResponse](ctx, c.client, "DialWhatsAppCall", []string{topic}, req, opts...)
}
func (c *connectorInternalClient) AcceptWhatsAppCall(ctx context.Context, topic string, req *InternalAcceptWhatsAppCallRequest, opts ...psrpc.RequestOption) (*livekit10.AcceptWhatsAppCallResponse, error) {
return client.RequestSingle[*livekit10.AcceptWhatsAppCallResponse](ctx, c.client, "AcceptWhatsAppCall", []string{topic}, req, opts...)
}
func (c *connectorInternalClient) ConnectTwilioCall(ctx context.Context, topic string, req *InternalConnectTwilioCallRequest, opts ...psrpc.RequestOption) (*livekit11.ConnectTwilioCallResponse, error) {
return client.RequestSingle[*livekit11.ConnectTwilioCallResponse](ctx, c.client, "ConnectTwilioCall", []string{topic}, req, opts...)
}
func (s *connectorInternalClient) Close() {
s.client.Close()
}
// ========================
// ConnectorInternal Server
// ========================
type connectorInternalServer struct {
svc ConnectorInternalServerImpl
rpc *server.RPCServer
}
// NewConnectorInternalServer builds a RPCServer that will route requests
// to the corresponding method in the provided svc implementation.
func NewConnectorInternalServer(svc ConnectorInternalServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (ConnectorInternalServer, error) {
sd := &info.ServiceDefinition{
Name: "ConnectorInternal",
ID: rand.NewServerID(),
}
s := server.NewRPCServer(sd, bus, opts...)
sd.RegisterMethod("DialWhatsAppCall", false, false, true, true)
sd.RegisterMethod("AcceptWhatsAppCall", false, false, true, true)
sd.RegisterMethod("ConnectTwilioCall", false, false, true, true)
return &connectorInternalServer{
svc: svc,
rpc: s,
}, nil
}
func (s *connectorInternalServer) RegisterDialWhatsAppCallTopic(topic string) error {
return server.RegisterHandler(s.rpc, "DialWhatsAppCall", []string{topic}, s.svc.DialWhatsAppCall, nil)
}
func (s *connectorInternalServer) DeregisterDialWhatsAppCallTopic(topic string) {
s.rpc.DeregisterHandler("DialWhatsAppCall", []string{topic})
}
func (s *connectorInternalServer) RegisterAcceptWhatsAppCallTopic(topic string) error {
return server.RegisterHandler(s.rpc, "AcceptWhatsAppCall", []string{topic}, s.svc.AcceptWhatsAppCall, nil)
}
func (s *connectorInternalServer) DeregisterAcceptWhatsAppCallTopic(topic string) {
s.rpc.DeregisterHandler("AcceptWhatsAppCall", []string{topic})
}
func (s *connectorInternalServer) RegisterConnectTwilioCallTopic(topic string) error {
return server.RegisterHandler(s.rpc, "ConnectTwilioCall", []string{topic}, s.svc.ConnectTwilioCall, nil)
}
func (s *connectorInternalServer) DeregisterConnectTwilioCallTopic(topic string) {
s.rpc.DeregisterHandler("ConnectTwilioCall", []string{topic})
}
func (s *connectorInternalServer) Shutdown() {
s.rpc.Close(false)
}
func (s *connectorInternalServer) Kill() {
s.rpc.Close(true)
}
// ======================================
// ConnectorInternal Unimplemented Server
// ======================================
type UnimplementedConnectorInternalServer struct{}
func (UnimplementedConnectorInternalServer) DialWhatsAppCall(context.Context, *InternalDialWhatsAppCallRequest) (*livekit10.DialWhatsAppCallResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedConnectorInternalServer) AcceptWhatsAppCall(context.Context, *InternalAcceptWhatsAppCallRequest) (*livekit10.AcceptWhatsAppCallResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedConnectorInternalServer) ConnectTwilioCall(context.Context, *InternalConnectTwilioCallRequest) (*livekit11.ConnectTwilioCallResponse, error) {
return nil, psrpc.ErrUnimplemented
}
// =================================
// ConnectorHandler Client Interface
// =================================
type ConnectorHandlerClient interface {
ConnectWhatsAppCall(ctx context.Context, whatsappCallId string, req *livekit10.ConnectWhatsAppCallRequest, opts ...psrpc.RequestOption) (*livekit10.ConnectWhatsAppCallResponse, error)
DisconnectWhatsAppCall(ctx context.Context, whatsappCallId string, req *livekit10.DisconnectWhatsAppCallRequest, opts ...psrpc.RequestOption) (*livekit10.DisconnectWhatsAppCallResponse, error)
// Close immediately, without waiting for pending RPCs
Close()
}
// =====================================
// ConnectorHandler ServerImpl Interface
// =====================================
type ConnectorHandlerServerImpl interface {
ConnectWhatsAppCall(context.Context, *livekit10.ConnectWhatsAppCallRequest) (*livekit10.ConnectWhatsAppCallResponse, error)
DisconnectWhatsAppCall(context.Context, *livekit10.DisconnectWhatsAppCallRequest) (*livekit10.DisconnectWhatsAppCallResponse, error)
}
// =================================
// ConnectorHandler Server Interface
// =================================
type ConnectorHandlerServer interface {
RegisterConnectWhatsAppCallTopic(whatsappCallId string) error
DeregisterConnectWhatsAppCallTopic(whatsappCallId string)
RegisterDisconnectWhatsAppCallTopic(whatsappCallId string) error
DeregisterDisconnectWhatsAppCallTopic(whatsappCallId string)
// Close and wait for pending RPCs to complete
Shutdown()
// Close immediately, without waiting for pending RPCs
Kill()
}
// =======================
// ConnectorHandler Client
// =======================
type connectorHandlerClient struct {
client *client.RPCClient
}
// NewConnectorHandlerClient creates a psrpc client that implements the ConnectorHandlerClient interface.
func NewConnectorHandlerClient(bus psrpc.MessageBus, opts ...psrpc.ClientOption) (ConnectorHandlerClient, error) {
sd := &info.ServiceDefinition{
Name: "ConnectorHandler",
ID: rand.NewClientID(),
}
sd.RegisterMethod("ConnectWhatsAppCall", false, false, true, true)
sd.RegisterMethod("DisconnectWhatsAppCall", false, false, true, true)
rpcClient, err := client.NewRPCClient(sd, bus, opts...)
if err != nil {
return nil, err
}
return &connectorHandlerClient{
client: rpcClient,
}, nil
}
func (c *connectorHandlerClient) ConnectWhatsAppCall(ctx context.Context, whatsappCallId string, req *livekit10.ConnectWhatsAppCallRequest, opts ...psrpc.RequestOption) (*livekit10.ConnectWhatsAppCallResponse, error) {
return client.RequestSingle[*livekit10.ConnectWhatsAppCallResponse](ctx, c.client, "ConnectWhatsAppCall", []string{whatsappCallId}, req, opts...)
}
func (c *connectorHandlerClient) DisconnectWhatsAppCall(ctx context.Context, whatsappCallId string, req *livekit10.DisconnectWhatsAppCallRequest, opts ...psrpc.RequestOption) (*livekit10.DisconnectWhatsAppCallResponse, error) {
return client.RequestSingle[*livekit10.DisconnectWhatsAppCallResponse](ctx, c.client, "DisconnectWhatsAppCall", []string{whatsappCallId}, req, opts...)
}
func (s *connectorHandlerClient) Close() {
s.client.Close()
}
// =======================
// ConnectorHandler Server
// =======================
type connectorHandlerServer struct {
svc ConnectorHandlerServerImpl
rpc *server.RPCServer
}
// NewConnectorHandlerServer builds a RPCServer that will route requests
// to the corresponding method in the provided svc implementation.
func NewConnectorHandlerServer(svc ConnectorHandlerServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (ConnectorHandlerServer, error) {
sd := &info.ServiceDefinition{
Name: "ConnectorHandler",
ID: rand.NewServerID(),
}
s := server.NewRPCServer(sd, bus, opts...)
sd.RegisterMethod("ConnectWhatsAppCall", false, false, true, true)
sd.RegisterMethod("DisconnectWhatsAppCall", false, false, true, true)
return &connectorHandlerServer{
svc: svc,
rpc: s,
}, nil
}
func (s *connectorHandlerServer) RegisterConnectWhatsAppCallTopic(whatsappCallId string) error {
return server.RegisterHandler(s.rpc, "ConnectWhatsAppCall", []string{whatsappCallId}, s.svc.ConnectWhatsAppCall, nil)
}
func (s *connectorHandlerServer) DeregisterConnectWhatsAppCallTopic(whatsappCallId string) {
s.rpc.DeregisterHandler("ConnectWhatsAppCall", []string{whatsappCallId})
}
func (s *connectorHandlerServer) RegisterDisconnectWhatsAppCallTopic(whatsappCallId string) error {
return server.RegisterHandler(s.rpc, "DisconnectWhatsAppCall", []string{whatsappCallId}, s.svc.DisconnectWhatsAppCall, nil)
}
func (s *connectorHandlerServer) DeregisterDisconnectWhatsAppCallTopic(whatsappCallId string) {
s.rpc.DeregisterHandler("DisconnectWhatsAppCall", []string{whatsappCallId})
}
func (s *connectorHandlerServer) Shutdown() {
s.rpc.Close(false)
}
func (s *connectorHandlerServer) Kill() {
s.rpc.Close(true)
}
// =====================================
// ConnectorHandler Unimplemented Server
// =====================================
type UnimplementedConnectorHandlerServer struct{}
func (UnimplementedConnectorHandlerServer) ConnectWhatsAppCall(context.Context, *livekit10.ConnectWhatsAppCallRequest) (*livekit10.ConnectWhatsAppCallResponse, error) {
return nil, psrpc.ErrUnimplemented
}
func (UnimplementedConnectorHandlerServer) DisconnectWhatsAppCall(context.Context, *livekit10.DisconnectWhatsAppCallRequest) (*livekit10.DisconnectWhatsAppCallResponse, error) {
return nil, psrpc.ErrUnimplemented
}
var psrpcFileDescriptor12 = []byte{
// 444 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4f, 0x8f, 0x94, 0x30,
0x18, 0xc6, 0x53, 0x4c, 0xd6, 0xa4, 0xfe, 0x09, 0x76, 0x93, 0xcd, 0xca, 0xc1, 0x05, 0x76, 0x5d,
0x3d, 0x41, 0x32, 0xde, 0xd4, 0xc4, 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