Skip to content

Commit 0b62b25

Browse files
committed
优化Open
1 parent 0be90f2 commit 0b62b25

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

src/Apache.IoTDB/SessionPool.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public SessionPool(
8989
string password = "root",
9090
int fetchSize = 1000,
9191
string zoneId = "UTC+08:00",
92-
int poolSize = 8)
92+
int poolSize = 8,
93+
bool enableRpcCompression = true
94+
)
9395
{
9496
_host = host;
9597
_port = port;
@@ -99,7 +101,9 @@ public SessionPool(
99101
_fetchSize = fetchSize;
100102
_debugMode = false;
101103
_poolSize = poolSize;
102-
}
104+
_enableRpcCompression = enableRpcCompression;
105+
}
106+
103107
ILoggerFactory factory;
104108
public void OpenDebugMode(Action<ILoggingBuilder> configure)
105109
{
@@ -111,16 +115,22 @@ public void OpenDebugMode(Action<ILoggingBuilder> configure)
111115
public void CloseDebugMode()
112116
{
113117
_debugMode = false;
114-
}
115-
118+
}
119+
116120
public async Task Open(bool enableRpcCompression, CancellationToken cancellationToken = default)
121+
{
122+
_enableRpcCompression = enableRpcCompression;
123+
await Open(cancellationToken);
124+
}
125+
126+
public async Task Open(CancellationToken cancellationToken = default)
117127
{
118-
_clients = new ConcurrentClientQueue();
119-
_enableRpcCompression = enableRpcCompression;
120-
128+
_clients = new ConcurrentClientQueue();
129+
130+
121131
for (var index = 0; index < _poolSize; index++)
122132
{
123-
_clients.Add(await CreateAndOpen(enableRpcCompression, cancellationToken));
133+
_clients.Add(await CreateAndOpen(_enableRpcCompression, cancellationToken));
124134
}
125135
}
126136

0 commit comments

Comments
 (0)