Class List Method List File List

# Class: VertxPgClient::PgConnection

Inherits:
  VertxSqlClient::SqlConnection
  - Object
  - VertxSqlClient::SqlClient
  - VertxSqlClient::SqlConnection
  - VertxPgClient::PgConnection
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb

## Overview

A connection to Postgres.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (void) connect(param_1 = nil, param_2 = nil)
  Like #connect with options build from connectionUri.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (::VertxSqlClient::Transaction) begin
  Begin a transaction and returns a for controlling and tracking this transaction.
- - (::VertxPgClient::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 { ... }
- - (self) exception_handler { ... }
- - (self) notification_handler { ... }
  Set an handler called when the connection receives notification on a channel.
- - (self) prepare(sql = nil) { ... }
- - (::VertxSqlClient::PreparedQuery) prepared_query(sql = nil)
  Create a prepared query, one of the or methods must be called to execute the query.
- - (Fixnum) process_id
  The process ID of the target backend.
- - (::VertxSqlClient::Query) query(sql = nil)
  Create a query, the method must be called to execute the query.
- - (Fixnum) secret_key
  The secret key for the target backend.
- - (true, false) ssl?
  Whether the connection uses SSL.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    26
    27
    28
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 26

    def @@j_api_type.accept?(obj)
      obj.class == PgConnection
    end

### + (`void`) connect(vertx, handler) { ... } + (`void`) connect(vertx, options, handler) { ... } + (`void`) connect(vertx, connectionUri, handler) { ... }

This method returns an undefined value.

Like #connect with options build from `connectionUri`.

Overloads:

- + (`void`) connect(vertx, handler) { ... }

  Parameters:

  - vertx (`::Vertx::Vertx`)

  Yields:

- + (`void`) connect(vertx, options, handler) { ... }

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the vertx instance
  - options (`Hash`) —
    the connect options

  Yields:

  - the handler called with the connection or the failure
- + (`void`) connect(vertx, connectionUri, handler) { ... }

  Parameters:

  - vertx (`::Vertx::Vertx`)
  - connectionUri (`String`)

  Yields:

Raises:

- (`ArgumentError`)

    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 99

    def self.connect(param_1=nil,param_2=nil)
      if param_1.class.method_defined?(:j_del) && block_given? && param_2 == nil
        return Java::IoVertxPgclient::PgConnection.java_method(:connect, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgConnection) : nil) }))
      elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && block_given?
        return Java::IoVertxPgclient::PgConnection.java_method(:connect, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxPgclient::PgConnectOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,Java::IoVertxPgclient::PgConnectOptions.new(::Vertx::Util::Utils.to_json_object(param_2)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgConnection) : nil) }))
      elsif param_1.class.method_defined?(:j_del) && param_2.class == String && block_given?
        return Java::IoVertxPgclient::PgConnection.java_method(:connect, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,param_2,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxPgClient::PgConnection) : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling connect(#{param_1},#{param_2})"
    end

### + (`Object`) j_api_type

    35
    36
    37
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 35

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    38
    39
    40
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 38

    def self.j_class
      Java::IoVertxPgclient::PgConnection.java_class
    end

### + (`Object`) unwrap(obj)

    32
    33
    34
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 32

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    29
    30
    31
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 29

    def @@j_api_type.wrap(obj)
      PgConnection.new(obj)
    end

## Instance Method Details

### - (`::VertxSqlClient::Transaction`) begin

Begin a transaction and returns a for controlling and tracking this transaction.

When the connection is explicitely closed, any inflight transaction is rollbacked.

Returns:

- (`::VertxSqlClient::Transaction`) —
  the transaction instance

Raises:

- (`ArgumentError`)

    65
    66
    67
    68
    69
    70
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 65

    def begin
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:begin, []).call(),::VertxSqlClient::Transaction)
      end
      raise ArgumentError, "Invalid arguments when calling begin()"
    end

### - (`::VertxPgClient::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.

Yields:

- the handler notified if cancelling request is sent

Returns:

- (`::VertxPgClient::PgConnection`) —
  a reference to this, so the API can be used fluently

Raises:

- (`ArgumentError`)

    126
    127
    128
    129
    130
    131
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 126

    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) })),::VertxPgClient::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.

Raises:

- (`ArgumentError`)

    80
    81
    82
    83
    84
    85
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 80

    def close
      if !block_given?
        return @j_del.java_method(:close, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling close()"
    end

### - (`self`) close_handler { ... }

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    169
    170
    171
    172
    173
    174
    175
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 169

    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 { ... }

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    160
    161
    162
    163
    164
    165
    166
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 160

    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.

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    115
    116
    117
    118
    119
    120
    121
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 115

    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) { ... }

Parameters:

- sql (`String`) (defaults to: `nil`)

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    150
    151
    152
    153
    154
    155
    156
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 150

    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,::VertxSqlClient::PreparedStatement) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling prepare(#{sql})"
    end

### - (`::VertxSqlClient::PreparedQuery`) prepared_query(sql = nil)

Create a prepared query, one of the or methods must be called to execute the query.

Parameters:

- sql (`String`) (defaults to: `nil`)

Returns:

- (`::VertxSqlClient::PreparedQuery`) —
  the prepared query

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 54

    def prepared_query(sql=nil)
      if sql.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class]).call(sql),::VertxSqlClient::PreparedQuery,::VertxSqlClient::RowSet.j_api_type)
      end
      raise ArgumentError, "Invalid arguments when calling prepared_query(#{sql})"
    end

### - (`Fixnum`) process_id

Returns The process ID of the target backend

Returns:

- (`Fixnum`) —
  The process ID of the target backend

Raises:

- (`ArgumentError`)

    133
    134
    135
    136
    137
    138
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 133

    def process_id
      if !block_given?
        return @j_del.java_method(:processId, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling process_id()"
    end

### - (`::VertxSqlClient::Query`) query(sql = nil)

Create a query, the method must be called to execute the query.

Parameters:

- sql (`String`) (defaults to: `nil`)

Returns:

- (`::VertxSqlClient::Query`) —
  the query

Raises:

- (`ArgumentError`)

    44
    45
    46
    47
    48
    49
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 44

    def query(sql=nil)
      if sql.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:query, [Java::java.lang.String.java_class]).call(sql),::VertxSqlClient::Query,::VertxSqlClient::RowSet.j_api_type)
      end
      raise ArgumentError, "Invalid arguments when calling query(#{sql})"
    end

### - (`Fixnum`) secret_key

Returns The secret key for the target backend

Returns:

- (`Fixnum`) —
  The secret key for the target backend

Raises:

- (`ArgumentError`)

    140
    141
    142
    143
    144
    145
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 140

    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

Returns:

- (`true`, `false`) —
  whether the connection uses SSL

Raises:

- (`ArgumentError`)

    72
    73
    74
    75
    76
    77
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-pg-client/pg_connection.rb', line 72

    def ssl?
      if !block_given?
        return @j_del.java_method(:isSSL, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling ssl?()"
    end