diff --git a/pg/connection/conversation.pony b/pg/connection/conversation.pony index 79ae069..8581737 100644 --- a/pg/connection/conversation.pony +++ b/pg/connection/conversation.pony @@ -8,15 +8,15 @@ use "pg" trait Conversation - be apply(c: _Connection) + be apply(c: BEConnection tag) be message(m: ServerMessage val) actor _NullConversation is Conversation - let _conn: _Connection + let _conn: BEConnection tag - new create(c: _Connection) => _conn = c - be apply(c: _Connection) => None + new create(c: BEConnection tag) => _conn = c + be apply(c: BEConnection tag) => None be message(m: ServerMessage val) => _conn.handle_message(m) @@ -24,8 +24,8 @@ actor _NullConversation is Conversation actor _AuthConversation is Conversation let _pool: ConnectionManager let _params: Array[(String, String)] val - let _conn: _Connection - new create(p: ConnectionManager, c: _Connection, params: Array[(String, String)] val) => + let _conn: BEConnection tag + new create(p: ConnectionManager, c: BEConnection tag, params: Array[(String, String)] val) => _pool=p _conn=c _params=params @@ -33,7 +33,7 @@ actor _AuthConversation is Conversation be log(msg: String) => _pool.log(msg) - be apply(c: _Connection) => + be apply(c: BEConnection tag) => let data = recover val let msg = StartupMessage(_params) msg.done() @@ -149,19 +149,19 @@ actor ExecuteConversation is Conversation actor QueryConversation is Conversation let query: String val - let _conn: _Connection + let _conn: BEConnection tag let _handler: ResultCB val var _rows: (Rows val | Rows trn ) = recover trn Rows end var _tuple_desc: (TupleDescription val | None) = None - new create(c: _Connection, q: String, h: ResultCB val) => + new create(c: BEConnection tag, q: String, h: ResultCB val) => query = q _conn = c _handler = h be log(msg: String) => _conn.log(msg) - be apply(c: _Connection) => + be apply(c: BEConnection tag) => c.writev(recover val QueryMessage(query).done() end) be call_back() => @@ -196,7 +196,7 @@ actor TerminateConversation is Conversation be log(msg: String) => _conn.log(msg) - be apply(c: _Connection) => + be apply(c: BEConnection tag) => c.writev(recover val TerminateMessage.done() end) be message(m: ServerMessage val)=> diff --git a/pg/connection/listener.pony b/pg/connection/listener.pony index e179568..47e7f2d 100644 --- a/pg/connection/listener.pony +++ b/pg/connection/listener.pony @@ -16,12 +16,12 @@ class PGParseError is ParseEvent actor Listener - let _conn: _Connection + let _conn: BEConnection tag var r: Reader iso = Reader // current reader var _ctype: U8 = 0 // current type (keep it if the data is chuncked) var _clen: USize = 0 // current message len (as given by server) - new create(c: _Connection) => + new create(c: BEConnection tag) => _conn = c be received(data: Array[U8] iso) => diff --git a/pg/connection/manager.pony b/pg/connection/manager.pony index eb457d0..900f05a 100644 --- a/pg/connection/manager.pony +++ b/pg/connection/manager.pony @@ -4,24 +4,28 @@ use "promises" use "pg" actor ConnectionManager - let _connections: Array[_Connection] = Array[_Connection tag] + let _connections: Array[BEConnection tag] = Array[BEConnection tag] let _params: Array[(String, String)] val let _host: String let _service: String let _user: String let _passwd_provider: PasswordProvider tag var _password: (String | None) = None + let _max_size: USize new create(host: String, service: String, user: String, passwd_provider: PasswordProvider tag, - params: Array[Param] val) => + params: Array[Param] val, + pool_size: USize = 1 + ) => _params = params _host = host _service = service _passwd_provider = passwd_provider _user = user + _max_size = pool_size be log(msg: String) => None diff --git a/pg/connection/tcp.pony b/pg/connection/tcp.pony index e64d794..5eb8861 100644 --- a/pg/connection/tcp.pony +++ b/pg/connection/tcp.pony @@ -22,6 +22,7 @@ interface BEConnection be next() be schedule(conv: Conversation tag) be terminate() + be received(s: ServerMessage val) be do_terminate() be cursor(query: String, notify: CursorNotify iso) => None