Implement per-backend session limit for clusters.

This commit is contained in:
Joachim Bauch
2022-07-13 11:52:20 +02:00
parent 12a8fa98d0
commit deaa17acc5
9 changed files with 287 additions and 105 deletions
+23 -4
View File
@@ -42,10 +42,11 @@ var (
)
type Backend struct {
id string
url string
secret []byte
compat bool
id string
url string
parsedUrl *url.URL
secret []byte
compat bool
allowHttp bool
@@ -80,6 +81,24 @@ func (b *Backend) IsUrlAllowed(u *url.URL) bool {
}
}
func (b *Backend) Url() string {
return b.url
}
func (b *Backend) ParsedUrl() *url.URL {
return b.parsedUrl
}
func (b *Backend) Limit() int {
return int(b.sessionLimit)
}
func (b *Backend) Len() int {
b.sessionsLock.Lock()
defer b.sessionsLock.Unlock()
return len(b.sessions)
}
func (b *Backend) AddSession(session Session) error {
if session.ClientType() == HelloClientTypeInternal || session.ClientType() == HelloClientTypeVirtual {
// Internal and virtual sessions are not counting to the limit.