Class: ReactivePgClient::PgClient

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb

Overview

Defines the client operations with a Postgres Database.

Direct Known Subclasses

PgConnection, PgPool, PgTransaction

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

22
23
24
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 22

def @@j_api_type.accept?(obj)
  obj.class == PgClient
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)

81
82
83
84
85
86
87
88
89
90
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 81

def self.connect(param_1=nil,param_2=nil)
  if param_1.class.method_defined?(:j_del) && block_given? && param_2 == nil
    return Java::IoReactiversePgclient::PgClient.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,::ReactivePgClient::PgConnection) : nil) }))
  elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && block_given?
    return Java::IoReactiversePgclient::PgClient.java_method(:connect, [Java::IoVertxCore::Vertx.java_class,Java::IoReactiversePgclient::PgConnectOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,Java::IoReactiversePgclient::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,::ReactivePgClient::PgConnection) : nil) }))
  elsif param_1.class.method_defined?(:j_del) && param_2.class == String && block_given?
    return Java::IoReactiversePgclient::PgClient.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,::ReactivePgClient::PgConnection) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling connect(#{param_1},#{param_2})"
end

+ (Object) j_api_type


31
32
33
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 31

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


34
35
36
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 34

def self.j_class
  Java::IoReactiversePgclient::PgClient.java_class
end

+ (::ReactivePgClient::PgPool) pool + (::ReactivePgClient::PgPool) pool(connectionUri) + (::ReactivePgClient::PgPool) pool(vertx) + (::ReactivePgClient::PgPool) pool(options) + (::ReactivePgClient::PgPool) pool(vertx, connectionUri) + (::ReactivePgClient::PgPool) pool(vertx, options)

Like #pool with a specific instance.

Overloads:

Returns:

Raises:

  • (ArgumentError)

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 52

def self.pool(param_1=nil,param_2=nil)
  if !block_given? && param_1 == nil && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoReactiversePgclient::PgClient.java_method(:pool, []).call(),::ReactivePgClient::PgPool)
  elsif param_1.class == String && !block_given? && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoReactiversePgclient::PgClient.java_method(:pool, [Java::java.lang.String.java_class]).call(param_1),::ReactivePgClient::PgPool)
  elsif param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoReactiversePgclient::PgClient.java_method(:pool, [Java::IoVertxCore::Vertx.java_class]).call(param_1.j_del),::ReactivePgClient::PgPool)
  elsif param_1.class == Hash && !block_given? && param_2 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoReactiversePgclient::PgClient.java_method(:pool, [Java::IoReactiversePgclient::PgPoolOptions.java_class]).call(Java::IoReactiversePgclient::PgPoolOptions.new(::Vertx::Util::Utils.to_json_object(param_1))),::ReactivePgClient::PgPool)
  elsif param_1.class.method_defined?(:j_del) && param_2.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoReactiversePgclient::PgClient.java_method(:pool, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class]).call(param_1.j_del,param_2),::ReactivePgClient::PgPool)
  elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoReactiversePgclient::PgClient.java_method(:pool, [Java::IoVertxCore::Vertx.java_class,Java::IoReactiversePgclient::PgPoolOptions.java_class]).call(param_1.j_del,Java::IoReactiversePgclient::PgPoolOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::ReactivePgClient::PgPool)
  end
  raise ArgumentError, "Invalid arguments when calling pool(#{param_1},#{param_2})"
end

+ (Object) unwrap(obj)


28
29
30
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 28

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

+ (Object) wrap(obj)


25
26
27
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 25

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

Instance Method Details

- (self) prepared_batch(sql = nil, batch = nil) { ... }

Prepare and execute a createBatch.

Parameters:

  • sql (String) (defaults to: nil)
    the prepared query SQL
  • batch (Array<::ReactivePgClient::Tuple>) (defaults to: nil)
    the batch of tuples

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)

122
123
124
125
126
127
128
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 122

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

Prepare and execute a query.

Parameters:

  • sql (String) (defaults to: nil)
    the prepared query SQL
  • arguments (::ReactivePgClient::Tuple) (defaults to: nil)
    the list of arguments

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)

107
108
109
110
111
112
113
114
115
116
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 107

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

- (self) query(sql = nil) { ... }

Execute a simple query.

Parameters:

  • sql (String) (defaults to: nil)
    the query SQL

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)

95
96
97
98
99
100
101
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_client.rb', line 95

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