mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Make the proxy to report the number of clients to the broker
So the assignment of proxies is based on the load. The number of clients is ronded down to 8. Existing proxies that doesn't report the number of clients will be distributed equaly to new proxies until they get 8 clients, that is okish as the existing proxies do have a maximum capacity of 10. Fixes #40048
This commit is contained in:
parent
74bdb85b30
commit
7a1857c42f
9 changed files with 165 additions and 77 deletions
28
proxy/tokens_test.go
Normal file
28
proxy/tokens_test.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestTokens(t *testing.T) {
|
||||
Convey("Tokens", t, func() {
|
||||
tokens := newTokens(2)
|
||||
So(tokens.count(), ShouldEqual, 0)
|
||||
tokens.get()
|
||||
So(tokens.count(), ShouldEqual, 1)
|
||||
tokens.ret()
|
||||
So(tokens.count(), ShouldEqual, 0)
|
||||
})
|
||||
Convey("Tokens capacity 0", t, func() {
|
||||
tokens := newTokens(0)
|
||||
So(tokens.count(), ShouldEqual, 0)
|
||||
for i := 0; i < 20; i++ {
|
||||
tokens.get()
|
||||
}
|
||||
So(tokens.count(), ShouldEqual, 20)
|
||||
tokens.ret()
|
||||
So(tokens.count(), ShouldEqual, 19)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue