Class: ReactivePgClient::PgConnection
- Inherits:
-
PgClient
- Object
- PgClient
- ReactivePgClient::PgConnection
- Defined in:
- /Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb
Overview
A connection to Postgres.
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (::ReactivePgClient::PgTransaction) begin
Begin a transaction and returns a PgTransaction for controlling and tracking this transaction.
-
- (::ReactivePgClient::PgConnection) cancel_request { ... }
Send a request cancellation message to tell the server to cancel processing request in this connection.
-
- (void) close
Close the current connection after all the pending commands have been processed.
-
- (self) close_handler { ... }
Set an handler called when the connection is closed.
-
- (self) exception_handler { ... }
Set an handler called with connection errors.
-
- (self) notification_handler { ... }
Set an handler called when the connection receives notification on a channel.
-
- (self) prepare(sql = nil) { ... }
Create a prepared query.
- - (self) prepared_batch(sql = nil, batch = nil) { ... }
- - (self) prepared_query(sql = nil, arguments = nil) { ... }
-
- (Fixnum) process_id
The process ID of the target backend.
- - (self) query(sql = nil) { ... }
-
- (Fixnum) secret_key
The secret key for the target backend.
-
- (true, false) ssl?
Whether the connection uses SSL.
Methods inherited from PgClient
Class Method Details
+ (Boolean) accept?(obj)
23 24 25 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 23 def @@j_api_type.accept?(obj) obj.class == PgConnection end |
+ (Object) j_api_type
32 33 34 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 32 def self.j_api_type @@j_api_type end |
+ (Object) j_class
35 36 37 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 35 def self.j_class Java::IoReactiversePgclient::PgConnection.java_class end |
+ (Object) unwrap(obj)
29 30 31 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 29 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
26 27 28 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 26 def @@j_api_type.wrap(obj) PgConnection.new(obj) end |
Instance Method Details
- (::ReactivePgClient::PgTransaction) begin
Begin a transaction and returns a ReactivePgClient::PgTransaction for controlling and tracking
this transaction.
When the connection is explicitely closed, any inflight transaction is rollbacked.
74 75 76 77 78 79 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 74 def begin if !block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:begin, []).call(),::ReactivePgClient::PgTransaction) end raise ArgumentError, "Invalid arguments when calling begin()" end |
- (::ReactivePgClient::PgConnection) cancel_request { ... }
Send a request cancellation message to tell the server to cancel processing request in this connection.
Note: Use this with caution because the cancellation signal may or may not have any effect.
Note: Use this with caution because the cancellation signal may or may not have any effect.
111 112 113 114 115 116 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 111 def cancel_request if block_given? return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:cancelRequest, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })),::ReactivePgClient::PgConnection) end raise ArgumentError, "Invalid arguments when calling cancel_request()" end |
- (void) close
This method returns an undefined value.
Close the current connection after all the pending commands have been processed.
126 127 128 129 130 131 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 126 def close if !block_given? return @j_del.java_method(:close, []).call() end raise ArgumentError, "Invalid arguments when calling close()" end |
- (self) close_handler { ... }
Set an handler called when the connection is closed.
62 63 64 65 66 67 68 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 62 def close_handler if block_given? @j_del.java_method(:closeHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield }) return self end raise ArgumentError, "Invalid arguments when calling close_handler()" end |
- (self) exception_handler { ... }
Set an handler called with connection errors.
52 53 54 55 56 57 58 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 52 def exception_handler if block_given? @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) })) return self end raise ArgumentError, "Invalid arguments when calling exception_handler()" end |
- (self) notification_handler { ... }
Set an handler called when the connection receives notification on a channel.
The handler is called with the Hash and has access to the channel name
and the notification payload.
86 87 88 89 90 91 92 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 86 def notification_handler if block_given? @j_del.java_method(:notificationHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.toJson.encode) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling notification_handler()" end |
- (self) prepare(sql = nil) { ... }
Create a prepared query.
42 43 44 45 46 47 48 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 42 def prepare(sql=nil) if sql.class == String && block_given? @j_del.java_method(:prepare, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::ReactivePgClient::PgPreparedQuery) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling prepare(#{sql})" end |
- (self) prepared_batch(sql = nil, batch = nil) { ... }
160 161 162 163 164 165 166 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 160 def prepared_batch(sql=nil,batch=nil) if sql.class == String && batch.class == Array && block_given? @j_del.java_method(:preparedBatch, [Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,batch.map { |element| element.j_del },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::ReactivePgClient::PgRowSet) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling prepared_batch(#{sql},#{batch})" end |
- (self) prepared_query(sql = nil, arguments = nil) { ... }
136 137 138 139 140 141 142 143 144 145 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 136 def prepared_query(sql=nil,arguments=nil) if sql.class == String && block_given? && arguments == nil @j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::ReactivePgClient::PgRowSet) : nil) })) return self elsif sql.class == String && arguments.class.method_defined?(:j_del) && block_given? @j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class,Java::IoReactiversePgclient::Tuple.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,arguments.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::ReactivePgClient::PgRowSet) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling prepared_query(#{sql},#{arguments})" end |
- (Fixnum) process_id
Returns The process ID of the target backend
94 95 96 97 98 99 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 94 def process_id if !block_given? return @j_del.java_method(:processId, []).call() end raise ArgumentError, "Invalid arguments when calling process_id()" end |
- (self) query(sql = nil) { ... }
149 150 151 152 153 154 155 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 149 def query(sql=nil) if sql.class == String && block_given? @j_del.java_method(:query, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::ReactivePgClient::PgRowSet) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling query(#{sql})" end |
- (Fixnum) secret_key
Returns The secret key for the target backend
101 102 103 104 105 106 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 101 def secret_key if !block_given? return @j_del.java_method(:secretKey, []).call() end raise ArgumentError, "Invalid arguments when calling secret_key()" end |
- (true, false) ssl?
Returns whether the connection uses SSL
118 119 120 121 122 123 |
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_connection.rb', line 118 def ssl? if !block_given? return @j_del.java_method(:isSSL, []).call() end raise ArgumentError, "Invalid arguments when calling ssl?()" end |