@override
Future<PostgreSQLResult> query(
String fmtString, {
Map<String, dynamic> substitutionValues,
bool allowReuse,
int timeoutInSeconds,
}) =>
_query(
fmtString,
substitutionValues: substitutionValues,
allowReuse: allowReuse,
timeoutInSeconds: timeoutInSeconds,
);
И есть:
class PostgreSQLConnection extends Object
with _PostgreSQLExecutionContextMixin
implements PostgreSQLExecutionContext {
/// Creates an instance of [PostgreSQLConnection].
///
/// [host] must be a hostname, e.g. "foobar.com" or IP address. Do not include scheme or port.
/// [port] is the port to connect to the database on. It is typically 5432 for default PostgreSQL settings.
/// [databaseName] is the name of the database to connect to.
/// [username] and [password] are optional if the database requires user authentication.
/// [timeoutInSeconds] refers to the amount of time [PostgreSQLConnection] will wait while establishing a connection before it gives up.
/// [queryTimeoutInSeconds] refers to the default timeout for [PostgreSQLExecutionContext]'s execute and query methods.
/// [timeZone] is the timezone the connection is in. Defaults to 'UTC'.
/// [useSSL] when true, uses a secure socket when connecting to a PostgreSQL database.
PostgreSQLConnection(
this.host,
this.port,
this.databaseName, {
this.username,
this.password,
this.timeoutInSeconds = 30,
this.queryTimeoutInSeconds = 30,
this.timeZone = 'UTC',
this.useSSL = false,
this.isUnixSocket = false,
}) {
_connectionState = _PostgreSQLConnectionStateClosed();
_connectionState.connection = this;
}
Вопрос какой таймаут юзать?
Сейчас у меня так:
List<List<dynamic>> result = await connection.query(body['sql']).timeout(Duration(seconds: 90));
Но код периодически падает с: "TimeoutException after 0:00:30.000000: Future not completed" как если бы он не 90 секунд был, а 30. Соответсвенно 30 секунд в PostgreSQLConnection установлен.
Но чем один таймаут от другого отличается я понять не могу.
void main() async {
connection = PostgreSQLConnection('localhost', 5432, 'db', username: 'postgres', password: '123456');
await connection.open();
// далее сам код.
Подключение вроде бы по идее один раз должно создаваться? Как тогда оно падать может?