1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00
srs/trunk/src/kernel/srs_kernel_balance.cpp
ChenGH 13597d1b7f
update copyright to 2025. v5.0.218 v6.0.159 v7.0.21 (#4271)
update copyright to 2025

---------

Co-authored-by: john <hondaxiao@tencent.com>
Co-authored-by: winlin <winlinvip@gmail.com>
2025-01-14 17:35:18 +08:00

42 lines
606 B
C++

//
// Copyright (c) 2013-2025 The SRS Authors
//
// SPDX-License-Identifier: MIT
//
#include <srs_kernel_balance.hpp>
#include <srs_kernel_error.hpp>
using namespace std;
SrsLbRoundRobin::SrsLbRoundRobin()
{
index = -1;
count = 0;
}
SrsLbRoundRobin::~SrsLbRoundRobin()
{
}
uint32_t SrsLbRoundRobin::current()
{
return index;
}
string SrsLbRoundRobin::selected()
{
return elem;
}
string SrsLbRoundRobin::select(const vector<string>& servers)
{
srs_assert(!servers.empty());
index = (int)(count++ % servers.size());
elem = servers.at(index);
return elem;
}