Net::Async::CassandraCQL::Connection - connect to a single Cassandra database node
Net::Async::CassandraCQL::Connection
TODO
A registered event occurred. @args will depend on the event name. Each is also available as its own event, with the name in lowercase. If the event is not one of the types recognised below, @args will contain the actual Protocol::CassandraCQL::Frame object.
@args
The cluster topology has changed. $node is a packed socket address.
$node
The node's status has changed. $node is a packed socket address.
A keyspace or table schema has changed.
The following named parameters may be passed to new or configure:
new
configure
Optional. Authentication details to use for PasswordAuthenticator.
PasswordAuthenticator
Returns the connection's node ID (the string form of its IP address), which is used as its ID in the system.peers table.
system.peers
Connects to the Cassandra node an send the OPCODE_STARTUP message. The returned Future will yield the connection itself on success.
OPCODE_STARTUP
Takes the following named arguments:
Sends a message with the given opcode and Protocol::CassandraCQL::Frame for the message body. The returned Future will yield the response opcode and frame.
This is a low-level method; applications should instead use one of the wrapper methods below.
Sends the initial connection setup message. On success, the returned Future yields nothing.
Normally this is not required as the connect method performs it implicitly.
connect
Requests the list of supported options from the server node. On success, the returned Future yields a HASH reference mapping option names to ARRAY references containing valid values.
Performs a CQL query. On success, the values returned from the Future will depend on the type of query.
For USE queries, the type is keyspace and $result is a string giving the name of the new keyspace.
USE
keyspace
$result
For CREATE, ALTER and DROP queries, the type is schema_change and $result is a 3-element ARRAY reference containing the type of change, the keyspace and the table name.
CREATE
ALTER
DROP
schema_change
For SELECT queries, the type is rows and $result is an instance of Protocol::CassandraCQL::Result containing the returned row data.
SELECT
rows
For other queries, such as INSERT, UPDATE and DELETE, the future returns nothing.
INSERT
UPDATE
DELETE
Prepares a CQL query for later execution. On success, the returned Future yields an instance of Net::Async::CassandraCQL::Query.
Executes a previously-prepared statement, given its ID and the binding data. On success, the returned Future will yield results of the same form as the query method. $data should contain a list of encoded byte-string values.
query
$data
Normally this method is not directly required - instead, use the execute method on the query object itself, as this will encode the parameters correctly.
execute
Registers the connection's interest in receiving events of the types given in the ARRAY reference. Event names may be TOPOLOGY_CHANGE, STATUS_CHANGE or SCHEMA_CHANGE. On success, the returned Future yields nothing.
TOPOLOGY_CHANGE
STATUS_CHANGE
SCHEMA_CHANGE
If the connection is idle (has no outstanding queries), then it is closed immediately. If not, it is put into close-pending mode, where it will accept no more queries, and will close when the last pending one is complete.
This code was paid for by
Perceptyx http://www.perceptyx.com/
Shadowcat Systems http://www.shadow.cat
Paul Evans <leonerd@leonerd.org.uk>
To install Net::Async::CassandraCQL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Async::CassandraCQL
CPAN shell
perl -MCPAN -e shell install Net::Async::CassandraCQL
For more information on module installation, please visit the detailed CPAN module installation guide.