Skip to content

Commit be1da4a

Browse files
committed
add connectionString
1 parent 2f216c8 commit be1da4a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Apache.IoTDB/SessionPool.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,24 @@ public SessionPool(string host, int port, int poolSize)
4545
_zoneId = "UTC+08:00";
4646
_fetchSize = 1024;
4747
_poolSize = poolSize;
48+
}
49+
public SessionPool(string connectionString)
50+
{
51+
Dictionary<string, string> pairs = new Dictionary<string, string>();
52+
connectionString.Split(';', StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(f =>
53+
{
54+
var kv = f.Split('=');
55+
pairs.TryAdd(key: kv[0], value: kv[1]);
56+
});
57+
_host = pairs.GetValueOrDefault("Server") ?? "127.0.0.1";
58+
_port = int.Parse(pairs.GetValueOrDefault("Port") ?? "6667");
59+
_username = pairs.GetValueOrDefault("User") ?? "root";
60+
_password = pairs.GetValueOrDefault("Password") ?? "root";
61+
_fetchSize = int.Parse(pairs.GetValueOrDefault("fetchSize") ?? "1800");
62+
_enableRpcCompression = bool.Parse(pairs.GetValueOrDefault("enableRpcCompression") ?? "false");
63+
_poolSize = int.Parse(pairs.GetValueOrDefault("poolSize") ?? "8");
64+
_zoneId = pairs.GetValueOrDefault("zoneId") ?? "UTC+08:00";
4865
}
49-
5066
public SessionPool(
5167
string host,
5268
int port,

0 commit comments

Comments
 (0)