github.com/whoyao/protocol@v0.0.0-20230519045905-2d8ace718ca5/rpc/ingress_client.go (about)

     1  package rpc
     2  
     3  import (
     4  	"github.com/livekit/psrpc"
     5  	"github.com/whoyao/protocol/livekit"
     6  )
     7  
     8  type IngressClient interface {
     9  	IngressInternalClient
    10  	IngressHandlerClient
    11  }
    12  
    13  type ingressClient struct {
    14  	IngressInternalClient
    15  	IngressHandlerClient
    16  }
    17  
    18  func NewIngressClient(nodeID livekit.NodeID, bus psrpc.MessageBus) (IngressClient, error) {
    19  	if bus == nil {
    20  		return nil, nil
    21  	}
    22  
    23  	clientID := string(nodeID)
    24  	internalClient, err := NewIngressInternalClient(clientID, bus)
    25  	if err != nil {
    26  		return nil, err
    27  	}
    28  	handlerClient, err := NewIngressHandlerClient(clientID, bus)
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  	return &ingressClient{
    33  		IngressInternalClient: internalClient,
    34  		IngressHandlerClient:  handlerClient,
    35  	}, nil
    36  }