Class List Method List File List

# Class: VertxCassandra::CassandraClient

Inherits:
  Object
  - Object
  - VertxCassandra::CassandraClient
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb

## Overview

Eclipse Vert.x Cassandra client.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxCassandra::CassandraClient) create_non_shared(vertx = nil, options = nil)
  Create a Cassandra client which maintains its own driver session.
- + (::VertxCassandra::CassandraClient) create_shared(param_1 = nil, param_2 = nil, param_3 = nil)
  Create a Cassandra client that shares its driver session with any other client having the same name.
- + (Object) DEFAULT_SHARED_CLIENT_NAME
  The default shared client name.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (self) close { ... }
  Closes this client.
- - (true, false) connected?
  Whether this Cassandra client instance is connected.
- - (self) execute(query = nil) { ... }
  Execute the query and provide a handler for consuming results.
- - (self) query_stream(sql = nil) { ... }
  Executes the given SQL SELECT statement which returns the results of the query as a read stream.

## Class Method Details

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

Returns:

- (`Boolean`)

    20
    21
    22
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 20

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

### + (`::VertxCassandra::CassandraClient`) create_non_shared(vertx = nil, options = nil)

Create a Cassandra client which maintains its own driver session.

It is not recommended to create several non shared clients in an application.

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the Vert.x instance
- options (`Hash`) (defaults to: `nil`) —
  the options

Returns:

- (`::VertxCassandra::CassandraClient`) —
  the client

Raises:

- (`ArgumentError`)

    41
    42
    43
    44
    45
    46
    47
    48
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 41

    def self.create_non_shared(vertx=nil,options=nil)
      if vertx.class.method_defined?(:j_del) && !block_given? && options == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCassandra::CassandraClient.java_method(:createNonShared, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxCassandra::CassandraClient)
      elsif vertx.class.method_defined?(:j_del) && options.class == Hash && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCassandra::CassandraClient.java_method(:createNonShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCassandra::CassandraClientOptions.java_class]).call(vertx.j_del,Java::IoVertxCassandra::CassandraClientOptions.new(::Vertx::Util::Utils.to_json_object(options))),::VertxCassandra::CassandraClient)
      end
      raise ArgumentError, "Invalid arguments when calling create_non_shared(#{vertx},#{options})"
    end

### + (`::VertxCassandra::CassandraClient`) createShared(vertx) + (`::VertxCassandra::CassandraClient`) createShared(vertx, clientName) + (`::VertxCassandra::CassandraClient`) createShared(vertx, options) + (`::VertxCassandra::CassandraClient`) createShared(vertx, clientName, options)

Create a Cassandra client that shares its driver session with any other client having the same name.

Overloads:

- + (`::VertxCassandra::CassandraClient`) createShared(vertx)

  Parameters:

  - vertx (`::Vertx::Vertx`)
- + (`::VertxCassandra::CassandraClient`) createShared(vertx, clientName)

  Parameters:

  - vertx (`::Vertx::Vertx`)
  - clientName (`String`)
- + (`::VertxCassandra::CassandraClient`) createShared(vertx, options)

  Parameters:

  - vertx (`::Vertx::Vertx`)
  - options (`Hash`)
- + (`::VertxCassandra::CassandraClient`) createShared(vertx, clientName, options)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the Vert.x instance
  - clientName (`String`) —
    the shared client name
  - options (`Hash`) —
    the options

Returns:

- (`::VertxCassandra::CassandraClient`) —
  the client

Raises:

- (`ArgumentError`)

    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 63

    def self.create_shared(param_1=nil,param_2=nil,param_3=nil)
      if param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil && param_3 == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCassandra::CassandraClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class]).call(param_1.j_del),::VertxCassandra::CassandraClient)
      elsif param_1.class.method_defined?(:j_del) && param_2.class == String && !block_given? && param_3 == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCassandra::CassandraClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class]).call(param_1.j_del,param_2),::VertxCassandra::CassandraClient)
      elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given? && param_3 == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCassandra::CassandraClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCassandra::CassandraClientOptions.java_class]).call(param_1.j_del,Java::IoVertxCassandra::CassandraClientOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxCassandra::CassandraClient)
      elsif param_1.class.method_defined?(:j_del) && param_2.class == String && param_3.class == Hash && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCassandra::CassandraClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::IoVertxCassandra::CassandraClientOptions.java_class]).call(param_1.j_del,param_2,Java::IoVertxCassandra::CassandraClientOptions.new(::Vertx::Util::Utils.to_json_object(param_3))),::VertxCassandra::CassandraClient)
      end
      raise ArgumentError, "Invalid arguments when calling create_shared(#{param_1},#{param_2},#{param_3})"
    end

### + (`Object`) DEFAULT_SHARED_CLIENT_NAME

The default shared client name.

    118
    119
    120
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 118

    def self.DEFAULT_SHARED_CLIENT_NAME
      Java::IoVertxCassandra::CassandraClient.DEFAULT_SHARED_CLIENT_NAME
    end

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

    def self.j_class
      Java::IoVertxCassandra::CassandraClient.java_class
    end

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

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

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

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

    23
    24
    25
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 23

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

## Instance Method Details

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

Closes this client.

Yields:

- handler called when client is closed

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 107

    def close
      if !block_given?
        @j_del.java_method(:close, []).call()
        return self
      elsif block_given?
        @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling close()"
    end

### - (`true`, `false`) connected?

Returns whether this Cassandra client instance is connected

Returns:

- (`true`, `false`) —
  whether this Cassandra client instance is connected

Raises:

- (`ArgumentError`)

    76
    77
    78
    79
    80
    81
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 76

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

### - (`self`) execute(query = nil) { ... }

Execute the query and provide a handler for consuming results.

Parameters:

- query (`String`) (defaults to: `nil`) —
  the query to execute

Yields:

- handler called when result of execution is present, but can be not fully fetched

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    86
    87
    88
    89
    90
    91
    92
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 86

    def execute(query=nil)
      if query.class == String && block_given?
        @j_del.java_method(:execute, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(query,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxCassandra::ResultSet) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling execute(#{query})"
    end

### - (`self`) query_stream(sql = nil) { ... }

Executes the given SQL `SELECT` statement which returns the results of the query as a read stream.

Parameters:

- sql (`String`) (defaults to: `nil`) —
  the SQL to execute. For example `SELECT * FROM table ...`.

Yields:

- the handler which is called once the operation completes. It will return an instance of VertxCassandra::CassandraRowStream.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    97
    98
    99
    100
    101
    102
    103
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 97

    def query_stream(sql=nil)
      if sql.class == String && block_given?
        @j_del.java_method(:queryStream, [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,::VertxCassandra::CassandraRowStream) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling query_stream(#{sql})"
    end