rename postgres to conform w style guide
This commit is contained in:
parent
d2d3e7b93d
commit
b49b267420
2 changed files with 24 additions and 8 deletions
|
@ -3,7 +3,7 @@ import 'package:angel_orm_postgres/angel_orm_postgres.dart';
|
||||||
import 'package:postgres/postgres.dart';
|
import 'package:postgres/postgres.dart';
|
||||||
|
|
||||||
main() async {
|
main() async {
|
||||||
var executor = new PostgreSQLExecutorPool(Platform.numberOfProcessors, () {
|
var executor = new PostgreSqlExecutorPool(Platform.numberOfProcessors, () {
|
||||||
return new PostgreSQLConnection('localhost', 5432, 'angel_orm_test');
|
return new PostgreSQLConnection('localhost', 5432, 'angel_orm_test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,21 @@ import 'package:logging/logging.dart';
|
||||||
import 'package:pool/pool.dart';
|
import 'package:pool/pool.dart';
|
||||||
import 'package:postgres/postgres.dart';
|
import 'package:postgres/postgres.dart';
|
||||||
|
|
||||||
|
/// Use the renamed [PostgreSqlExecutor] instead.
|
||||||
|
@deprecated
|
||||||
|
class PostgreSQLExecutor extends PostgreSqlExecutor {
|
||||||
|
PostgreSQLExecutor(PostgreSQLExecutionContext connection, {Logger logger})
|
||||||
|
: super(connection, logger: logger);
|
||||||
|
}
|
||||||
|
|
||||||
/// A [QueryExecutor] that queries a PostgreSQL database.
|
/// A [QueryExecutor] that queries a PostgreSQL database.
|
||||||
class PostgreSQLExecutor extends QueryExecutor {
|
class PostgreSqlExecutor extends QueryExecutor {
|
||||||
PostgreSQLExecutionContext _connection;
|
PostgreSQLExecutionContext _connection;
|
||||||
|
|
||||||
/// An optional [Logger] to print information to.
|
/// An optional [Logger] to print information to.
|
||||||
final Logger logger;
|
final Logger logger;
|
||||||
|
|
||||||
PostgreSQLExecutor(this._connection, {this.logger});
|
PostgreSqlExecutor(this._connection, {this.logger});
|
||||||
|
|
||||||
/// The underlying connection.
|
/// The underlying connection.
|
||||||
PostgreSQLExecutionContext get connection => _connection;
|
PostgreSQLExecutionContext get connection => _connection;
|
||||||
|
@ -53,8 +60,17 @@ class PostgreSQLExecutor extends QueryExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Use the renamed [PostgreSqlExecutorPool] instead.
|
||||||
|
@deprecated
|
||||||
|
class PostgreSQLExecutorPool extends PostgreSqlExecutorPool {
|
||||||
|
PostgreSQLExecutorPool(
|
||||||
|
int size, PostgreSQLConnection Function() connectionFactory,
|
||||||
|
{Logger logger})
|
||||||
|
: super(size, connectionFactory, logger: logger);
|
||||||
|
}
|
||||||
|
|
||||||
/// A [QueryExecutor] that manages a pool of PostgreSQL connections.
|
/// A [QueryExecutor] that manages a pool of PostgreSQL connections.
|
||||||
class PostgreSQLExecutorPool extends QueryExecutor {
|
class PostgreSqlExecutorPool extends QueryExecutor {
|
||||||
/// The maximum amount of concurrent connections.
|
/// The maximum amount of concurrent connections.
|
||||||
final int size;
|
final int size;
|
||||||
|
|
||||||
|
@ -66,11 +82,11 @@ class PostgreSQLExecutorPool extends QueryExecutor {
|
||||||
/// An optional [Logger] to print information to.
|
/// An optional [Logger] to print information to.
|
||||||
final Logger logger;
|
final Logger logger;
|
||||||
|
|
||||||
final List<PostgreSQLExecutor> _connections = [];
|
final List<PostgreSqlExecutor> _connections = [];
|
||||||
int _index = 0;
|
int _index = 0;
|
||||||
final Pool _pool, _connMutex = new Pool(1);
|
final Pool _pool, _connMutex = new Pool(1);
|
||||||
|
|
||||||
PostgreSQLExecutorPool(this.size, this.connectionFactory, {this.logger})
|
PostgreSqlExecutorPool(this.size, this.connectionFactory, {this.logger})
|
||||||
: _pool = new Pool(size) {
|
: _pool = new Pool(size) {
|
||||||
assert(size > 0, 'Connection pool cannot be empty.');
|
assert(size > 0, 'Connection pool cannot be empty.');
|
||||||
}
|
}
|
||||||
|
@ -89,12 +105,12 @@ class PostgreSQLExecutorPool extends QueryExecutor {
|
||||||
var conn = connectionFactory();
|
var conn = connectionFactory();
|
||||||
return conn
|
return conn
|
||||||
.open()
|
.open()
|
||||||
.then((_) => new PostgreSQLExecutor(conn, logger: logger));
|
.then((_) => new PostgreSqlExecutor(conn, logger: logger));
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<PostgreSQLExecutor> _next() {
|
Future<PostgreSqlExecutor> _next() {
|
||||||
return _connMutex.withResource(() async {
|
return _connMutex.withResource(() async {
|
||||||
await _open();
|
await _open();
|
||||||
if (_index >= size) _index = 0;
|
if (_index >= size) _index = 0;
|
||||||
|
|
Loading…
Reference in a new issue