mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 15:35:41 +00:00
* Some misc clean up. - Have been seeing counterfeiter warnings about efficiency for a while with go:generate declaration multiple times in the same package. Address that: https://github.com/maxbrunsfeld/counterfeiter?tab=readme-ov-file#step-2b---add-counterfeitergenerate-directives - A bit more readability on parameters passed to `sendLeave` * spacing * revert some deletes as the complaint was in analytics service only * Declare in package only once. Although the warning is about go:generate multiple times when directly giving the interface to generate, have `go:generate` multiple times in a package even with `-generate` ends up generating once per invocation. Once per package is enough to run the generation just once.
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
// Copyright 2023 LiveKit, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package routing
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/livekit/livekit-server/pkg/config"
|
|
"github.com/livekit/protocol/livekit"
|
|
"github.com/livekit/protocol/rpc"
|
|
"github.com/livekit/psrpc"
|
|
"github.com/livekit/psrpc/pkg/middleware"
|
|
)
|
|
|
|
//counterfeiter:generate . RoomManagerClient
|
|
type RoomManagerClient interface {
|
|
rpc.TypedRoomManagerClient
|
|
}
|
|
|
|
type roomManagerClient struct {
|
|
config config.RoomConfig
|
|
client rpc.TypedRoomManagerClient
|
|
}
|
|
|
|
func NewRoomManagerClient(clientParams rpc.ClientParams, config config.RoomConfig) (RoomManagerClient, error) {
|
|
c, err := rpc.NewTypedRoomManagerClient(
|
|
clientParams.Bus,
|
|
psrpc.WithClientChannelSize(clientParams.BufferSize),
|
|
middleware.WithClientMetrics(clientParams.Observer),
|
|
rpc.WithClientLogger(clientParams.Logger),
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &roomManagerClient{
|
|
config: config,
|
|
client: c,
|
|
}, nil
|
|
}
|
|
|
|
func (c *roomManagerClient) CreateRoom(ctx context.Context, nodeID livekit.NodeID, req *livekit.CreateRoomRequest, opts ...psrpc.RequestOption) (*livekit.Room, error) {
|
|
return c.client.CreateRoom(ctx, nodeID, req, append(opts, psrpc.WithRequestInterceptors(middleware.NewRPCRetryInterceptor(middleware.RetryOptions{
|
|
MaxAttempts: c.config.CreateRoomAttempts,
|
|
Timeout: c.config.CreateRoomTimeout,
|
|
})))...)
|
|
}
|
|
|
|
func (c *roomManagerClient) Close() {
|
|
c.client.Close()
|
|
}
|