-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #890 from ydb-platform/balancer-config-name
balancer config name
- Loading branch information
Showing
10 changed files
with
162 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,52 @@ | ||
package config | ||
|
||
import "github.com/ydb-platform/ydb-go-sdk/v3/internal/conn" | ||
import ( | ||
"fmt" | ||
|
||
"github.com/ydb-platform/ydb-go-sdk/v3/internal/conn" | ||
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xstring" | ||
) | ||
|
||
// Dedicated package need for prevent cyclo dependencies config -> balancer -> config | ||
|
||
type Config struct { | ||
IsPreferConn PreferConnFunc | ||
AllowFalback bool | ||
Filter Filter | ||
AllowFallback bool | ||
SingleConn bool | ||
DetectlocalDC bool | ||
DetectLocalDC bool | ||
} | ||
|
||
func (c Config) String() string { | ||
if c.SingleConn { | ||
return "SingleConn" | ||
} | ||
|
||
buffer := xstring.Buffer() | ||
defer buffer.Free() | ||
|
||
buffer.WriteString("RandomChoice{") | ||
|
||
buffer.WriteString("DetectLocalDC=") | ||
fmt.Fprintf(buffer, "%t", c.DetectLocalDC) | ||
|
||
buffer.WriteString(",AllowFallback=") | ||
fmt.Fprintf(buffer, "%t", c.AllowFallback) | ||
|
||
if c.Filter != nil { | ||
buffer.WriteString(",Filter=") | ||
fmt.Fprint(buffer, c.Filter.String()) | ||
} | ||
|
||
buffer.WriteByte('}') | ||
|
||
return buffer.String() | ||
} | ||
|
||
type Info struct { | ||
SelfLocation string | ||
} | ||
|
||
type PreferConnFunc func(info Info, c conn.Conn) bool | ||
type Filter interface { | ||
Allow(info Info, c conn.Conn) bool | ||
String() string | ||
} |
Oops, something went wrong.