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, cassandraClientOptions = nil)
  Create a Cassandra client which maintains its own data source.
- + (::VertxCassandra::CassandraClient) create_shared(param_1 = nil, param_2 = nil, param_3 = nil)
  Create a Cassandra client which shares its data source with any other Cassandra clients created with the same data source name.
- + (Object) DEFAULT_POOL_NAME
  The name of the default pool.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (self) connect(keyspace = nil) { ... }
  Connect to a Cassandra service.
- - (true, false) connected?
  Whether this Cassandra client instance connected.
- - (self) disconnect { ... }
  Disconnects from the Cassandra service.
- - (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, cassandraClientOptions = nil)

Create a Cassandra client which maintains its own data source.

It is not recommended to create several non shared clients in an application. Your application should either use only single non shared client, or use shared client. This is because VertxCassandra::CassandraClient backed by Session. And Datastax does not recommended to have several Session instances. Better to have only one, and share it.

Parameters:

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

Returns:

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

Raises:

- (`ArgumentError`)

    45
    46
    47
    48
    49
    50
    51
    52
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 45

    def self.create_non_shared(vertx=nil,cassandraClientOptions=nil)
      if vertx.class.method_defined?(:j_del) && !block_given? && cassandraClientOptions == 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) && cassandraClientOptions.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(cassandraClientOptions))),::VertxCassandra::CassandraClient)
      end
      raise ArgumentError, "Invalid arguments when calling create_non_shared(#{vertx},#{cassandraClientOptions})"
    end

### + (`::VertxCassandra::CassandraClient`) createShared(vertx) + (`::VertxCassandra::CassandraClient`) createShared(vertx, datasourceName) + (`::VertxCassandra::CassandraClient`) createShared(vertx, cassandraClientOptions) + (`::VertxCassandra::CassandraClient`) createShared(vertx, datasourceName, cassandraClientOptions)

Create a Cassandra client which shares its data source with any other Cassandra clients created with the same data source name.

Overloads:

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

  Parameters:

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

  Parameters:

  - vertx (`::Vertx::Vertx`)
  - datasourceName (`String`)
- + (`::VertxCassandra::CassandraClient`) createShared(vertx, cassandraClientOptions)

  Parameters:

  - vertx (`::Vertx::Vertx`)
  - cassandraClientOptions (`Hash`)
- + (`::VertxCassandra::CassandraClient`) createShared(vertx, datasourceName, cassandraClientOptions)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the Vert.x instance
  - datasourceName (`String`) —
    the data source name
  - cassandraClientOptions (`Hash`) —
    the options

Returns:

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

Raises:

- (`ArgumentError`)

    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 68

    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_POOL_NAME

The name of the default pool

    140
    141
    142
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 140

    def self.DEFAULT_POOL_NAME
      Java::IoVertxCassandra::CassandraClient.DEFAULT_POOL_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`) connect(keyspace = nil) { ... }

Connect to a Cassandra service.

Parameters:

- keyspace (`String`) (defaults to: `nil`) —
  The name of the keyspace to use for the created connection.

Yields:

- handler called when asynchronous connect call ends

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

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

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

Returns whether this Cassandra client instance connected.

Returns:

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

Raises:

- (`ArgumentError`)

    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 98

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

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

Disconnects from the Cassandra service.

Yields:

- handler called when asynchronous disconnect call ends

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 129

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

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

    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`)

    119
    120
    121
    122
    123
    124
    125
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-cassandra/cassandra_client.rb', line 119

    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