mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
42 lines
606 B
C++
42 lines
606 B
C++
//
|
|
// Copyright (c) 2013-2023 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;
|
|
}
|
|
|