mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2026-04-23 17:11:21 +08:00
0a92e96f20
* [Feature] add golang router * [Feature] add golang router * [Feature] add golang router * [Feature] add golang router * [Feature] add golang router * [Feature] Add Golang-based Router for Request Scheduling and Load Balancing * [Feature] Add Golang-based Router for Request Scheduling and Load Balancing * [Feature] Add Golang-based Router for Request Scheduling and Load Balancing * [Feature] Add Golang-based Router for Request Scheduling and Load Balancing --------- Co-authored-by: mouxin <mouxin@baidu.com>
22 lines
457 B
Go
22 lines
457 B
Go
package handler
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
func RoundRobinSelectWorker(ctx context.Context, workers []string, message string) (string, error) {
|
|
if len(workers) == 0 {
|
|
return "", nil
|
|
}
|
|
|
|
var count uint64
|
|
if DefaultCounterPolicy.workerType == "prefill" {
|
|
count = DefaultCounterPolicy.prefillCounter.Add(1) - 1
|
|
} else {
|
|
count = DefaultCounterPolicy.counter.Add(1) - 1
|
|
}
|
|
|
|
selectedNum := count % uint64(len(workers))
|
|
return workers[selectedNum], nil
|
|
}
|