From b49b267420eef9fac6637d278371e5121f38483f Mon Sep 17 00:00:00 2001 From: Tobe O Date: Wed, 13 Feb 2019 00:07:54 -0500 Subject: [PATCH] rename postgres to conform w style guide --- angel_orm_postgres/example/main.dart | 2 +- .../lib/angel_orm_postgres.dart | 30 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/angel_orm_postgres/example/main.dart b/angel_orm_postgres/example/main.dart index 4f24f1df..ad376f1d 100644 --- a/angel_orm_postgres/example/main.dart +++ b/angel_orm_postgres/example/main.dart @@ -3,7 +3,7 @@ import 'package:angel_orm_postgres/angel_orm_postgres.dart'; import 'package:postgres/postgres.dart'; main() async { - var executor = new PostgreSQLExecutorPool(Platform.numberOfProcessors, () { + var executor = new PostgreSqlExecutorPool(Platform.numberOfProcessors, () { return new PostgreSQLConnection('localhost', 5432, 'angel_orm_test'); }); diff --git a/angel_orm_postgres/lib/angel_orm_postgres.dart b/angel_orm_postgres/lib/angel_orm_postgres.dart index a4fd269a..182370de 100644 --- a/angel_orm_postgres/lib/angel_orm_postgres.dart +++ b/angel_orm_postgres/lib/angel_orm_postgres.dart @@ -4,14 +4,21 @@ import 'package:logging/logging.dart'; import 'package:pool/pool.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. -class PostgreSQLExecutor extends QueryExecutor { +class PostgreSqlExecutor extends QueryExecutor { PostgreSQLExecutionContext _connection; /// An optional [Logger] to print information to. final Logger logger; - PostgreSQLExecutor(this._connection, {this.logger}); + PostgreSqlExecutor(this._connection, {this.logger}); /// The underlying 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. -class PostgreSQLExecutorPool extends QueryExecutor { +class PostgreSqlExecutorPool extends QueryExecutor { /// The maximum amount of concurrent connections. final int size; @@ -66,11 +82,11 @@ class PostgreSQLExecutorPool extends QueryExecutor { /// An optional [Logger] to print information to. final Logger logger; - final List _connections = []; + final List _connections = []; int _index = 0; 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) { assert(size > 0, 'Connection pool cannot be empty.'); } @@ -89,12 +105,12 @@ class PostgreSQLExecutorPool extends QueryExecutor { var conn = connectionFactory(); return conn .open() - .then((_) => new PostgreSQLExecutor(conn, logger: logger)); + .then((_) => new PostgreSqlExecutor(conn, logger: logger)); }))); } } - Future _next() { + Future _next() { return _connMutex.withResource(() async { await _open(); if (_index >= size) _index = 0;