dart_cassandra_cql 0.1.5

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 48

Dart Driver for Apache Cassandra

Build Status Coverage Status

Dart driver for Apache Cassandra that supports Cassandra Query Language version 3.0+ (CQL3).

The driver has a small dependency tree and implements Cassandra binary protocol (versions 2 and 3) for communicating with Cassandra servers. The protocol and CQL versions to be used are both configurable by the user.

Features

  • Asynchronous API based on Future and Streams
  • Connection management via connection pools
  • Connection load-balancing and failover
  • Server event handling (node/topology/schema change events)
  • Query multiplexing on each connection
  • Batch and prepared queries with either positional or named placeholders
  • Query result streaming
  • Support for all Cassandra types including user defined types (UDT), tuples and custom types (via user-defined Codecs)

Quick start

import "dart:async";
import 'package:dart_cassandra_cql/dart_cassandra_cql.dart' as cql;

void main() {
  // Create a client for connecting to our cluster using native
  // protocol V2 and sensible defaults. The client will setup
  // a connection pool for you and connect automatically when
  // you execute a query.
  cql.Client client = new cql.Client.fromHostList([
      "10.0.0.1:9042"
      , "10.0.0.2:9042"
  ]);

  // Perform a select with positional bindings
  client.query(
      new cql.Query("SELECT * from test.type_test WHERE id=?", bindings : [123])
  ).then((Iterable<Map<String, Object>> rows) {
    // ...
  });

  // Perform an prepared insert with named bindings, a time-based uuid and tuneable consistency
  client.execute(
      new cql.Query("INSERT INTO test.type_test (id, uuid_value) VALUES (:id, :uuid)", bindings : {
          "id" : 1
          , "uuid" : new cql.Uuid.timeBased()
      }, consistency : cql.Consistency.LOCAL_QUORUM
       , prepared : true)
  ).then((cql.ResultMessage res) {
    // ...
  });

  // Perform a batch insert query
  client.execute(
      new cql.BatchQuery()
        ..add(
          new cql.Query("INSERT INTO test.type_test (id, uuid_value) VALUES (:id, :uuid)", bindings : {
              "id" : 1
              , "uuid" : new cql.Uuid.timeBased()
          })
      )
        ..add(
          new cql.Query("INSERT INTO test.type_test (id, uuid_value) VALUES (:id, :uuid)", bindings : {
              "id" : 2
              , "uuid" : new cql.Uuid.timeBased()
          })
      )
        ..consistency = cql.Consistency.TWO
  ).then((cql.ResultMessage res) {
    // ...
  }).catchError((e) {
    // Handle errors
  });

  // Stream (paginated) query
  StreamSubscription sub;
  sub = client.stream(
      new cql.Query("SELECT * from test.type_test")
      , pageSize : 200
  ).listen((Map<String, Object> row) {
    // Handle incoming row
    print("Next row: ${row}");
    // ... or manipulate stream
    sub.cancel();
  });

}

Api

See the Api documentation.

Contributing

See the Contributing Guide.

Acknowledgements

License

dart_cassandra_cql is distributed under the MIT license.

0.1.5 (Feb 18, 2016)

Fixed another socket flush race condition (#2)

0.1.4 (April 17, 2015)

Added the preferBiggerTcpPackets option (defaults to false). When enabled, the driver will join together protocol frame chunks before piping them to the underlying TCP socket. This option will improve performance at the expense of slightly higher memory consumption.

0.1.3 (December 20, 2014)

Improved support for compression codecs Driver is now compatible with dart_lz4

0.1.2 (December 6, 2014)

Renamed lib/driver to lib/src so that docgen works Fixed race condition while flushing data to sockets (#1)

0.1.1 (November 26, 2014)

Restructured folders to align with pub requirements

0.1.0 (November 24, 2014)

Initial release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_cassandra_cql: "^0.1.5"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:dart_cassandra_cql/dart_cassandra_cql.dart';
  
Version Uploaded Documentation Archive
0.1.5 Feb 18, 2016 Go to the documentation of dart_cassandra_cql 0.1.5 Download dart_cassandra_cql 0.1.5 archive
0.1.3 Dec 20, 2014 Go to the documentation of dart_cassandra_cql 0.1.3 Download dart_cassandra_cql 0.1.3 archive
0.1.2 Dec 6, 2014 Go to the documentation of dart_cassandra_cql 0.1.2 Download dart_cassandra_cql 0.1.2 archive
0.1.1 Nov 26, 2014 Go to the documentation of dart_cassandra_cql 0.1.1 Download dart_cassandra_cql 0.1.1 archive
0.1.0 Nov 26, 2014 Go to the documentation of dart_cassandra_cql 0.1.0 Download dart_cassandra_cql 0.1.0 archive

Analysis

We analyzed this package on May 22, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.54.0
  • pana: 0.11.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
45 / 100
Health:
Code health derived from static analysis. [more]
85 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]
48
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:dart_cassandra_cql/dart_cassandra_cql.dart with components: io.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 9 errors 79 hints.

    Strong-mode analysis of lib/src/client/client.dart failed with the following error:

    line: 48 col: 39
    The argument type '(RowsResultMessage) → List<Map<String, Object>>' can't be assigned to the parameter type '(ResultMessage) → FutureOr<Iterable<Map<String, Object>>>'.

    Strong-mode analysis of lib/src/client/result_stream.dart failed with the following error:

    line: 24 col: 12
    The argument type '(RowsResultMessage) → Null' can't be assigned to the parameter type '(dynamic) → FutureOr<dynamic>'.

    Similar analysis of the following files failed:

    • lib/src/connection/connection.dart (error)
    • lib/src/protocol/messages/requests/execute_message.dart (error)
    • lib/dart_cassandra_cql.dart (hint)
    • lib/src/connection/async_queue.dart (hint)
    • lib/src/connection/connection_pool.dart (hint)
    • lib/src/connection/pool_configuration.dart (hint)
    • lib/src/connection/simple_connection_pool.dart (hint)
    • lib/src/exception/authentication_exception.dart (hint)
    • lib/src/exception/cassandra_exception.dart (hint)
    • lib/src/exception/connection_failed_exception.dart (hint)
    • lib/src/exception/connection_lost_exception.dart (hint)
    • lib/src/exception/driver_exception_exception.dart (hint)
    • lib/src/exception/no_healthy_connections_exception.dart (hint)
    • lib/src/exception/stream_reservation_exception.dart (hint)
    • lib/src/protocol/authentication/authenticator.dart (hint)
    • lib/src/protocol/authentication/password_authenticator.dart (hint)
    • lib/src/protocol/frame/frame_decompressor.dart (hint)
    • lib/src/protocol/frame/frame_parser.dart (hint)
    • lib/src/protocol/frame/frame_reader.dart (hint)
    • lib/src/protocol/frame/frame_writer.dart (hint)
    • lib/src/protocol/messages/internal/exception_message.dart (hint)
    • lib/src/protocol/messages/message.dart (hint)
    • lib/src/protocol/messages/requests/auth_response_message.dart (hint)
    • lib/src/protocol/messages/requests/batch_message.dart (hint)
    • lib/src/protocol/messages/requests/prepare_message.dart (hint)
    • lib/src/protocol/messages/requests/query_message.dart (hint)
    • lib/src/protocol/messages/requests/register_message.dart (hint)
    • lib/src/protocol/messages/requests/startup_message.dart (hint)
    • lib/src/protocol/messages/responses/auth_challenge_message.dart (hint)
    • lib/src/protocol/messages/responses/auth_success_message.dart (hint)
    • lib/src/protocol/messages/responses/authenticate_message.dart (hint)
    • lib/src/protocol/messages/responses/error_message.dart (hint)
    • lib/src/protocol/messages/responses/event_message.dart (hint)
    • lib/src/protocol/messages/responses/prepared_result_message.dart (hint)
    • lib/src/protocol/messages/responses/result_message.dart (hint)
    • lib/src/protocol/messages/responses/rows_result_message.dart (hint)
    • lib/src/protocol/messages/responses/schema_change_result_message.dart (hint)
    • lib/src/protocol/messages/responses/set_keyspace_result_message.dart (hint)
    • lib/src/protocol/messages/responses/void_result_message.dart (hint)
    • lib/src/query/batch_query.dart (hint)
    • lib/src/query/query.dart (hint)
    • lib/src/query/query_interface.dart (hint)
    • lib/src/stream/chunked_input_reader.dart (hint)
    • lib/src/stream/chunked_output_writer.dart (hint)
    • lib/src/stream/type_decoder.dart (hint)
    • lib/src/stream/type_encoder.dart (hint)
    • lib/src/types.dart (hint)
    • lib/src/types/codec_registry.dart (hint)
    • lib/src/types/custom_type.dart (hint)
    • lib/src/types/enums/batch_type.dart (hint)
    • lib/src/types/enums/consistency.dart (hint)
    • lib/src/types/enums/data_type.dart (hint)
    • lib/src/types/enums/enum.dart (hint)
    • lib/src/types/enums/error_code.dart (hint)
    • lib/src/types/enums/event_registration_type.dart (hint)
    • lib/src/types/enums/event_type.dart (hint)
    • lib/src/types/enums/header_version.dart (hint)
    • lib/src/types/enums/opcode.dart (hint)
    • lib/src/types/enums/result_type.dart (hint)
    • lib/src/types/frame.dart (hint)
    • lib/src/types/frame_header.dart (hint)
    • lib/src/types/tuple.dart (hint)
    • lib/src/types/type_spec.dart (hint)
    • lib/src/types/uuid.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use dart_cassandra_cql.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
collection >=1.1.0 <2.0.0 1.14.9
logging ^0.11.2 0.11.3+1
uuid >=0.4.1 <0.5.0 0.4.1 1.0.0
Transitive dependencies
bignum 0.0.7 0.1.0
charcode 1.1.1
cipher 0.7.1
convert 1.1.1 2.0.1
crypto 0.9.2+1 2.0.3
fixnum 0.9.1+2 0.10.7
typed_data 1.1.5
Dev dependencies
unittest >=0.11.0+5 <0.12.0