The CassandraActor
is a Coral Actor that enables communication with a Cassandra database. The actor receives queries in the trigger field and emits the results.
All valid CQL queries can be executed, including creating keyspaces and inserting, deleting and updating values.
The params
value is a JSON object with the following fields:
field | type | required | description |
---|---|---|---|
seeds |
List[String] | yes | A JSON list of the IP addresses of seed nodes. |
keyspace |
String | yes | The name of the keyspace to connect to initially. |
port |
Int | no | The port to connect to, when omitted default Cassandra port 9042 is used. |
user |
String | no | The user name to connect to Cassandra. |
password |
String | no | The password to connect to Cassandra. |
The CassandraActor can process any valid CQL query. The keyspace
will be connected to initially, but it can later be changed by sending the CassandraActor a “use keyspace” statement:
This will create a CassandraActor connecting to seed nodes 192.168.0.2 and 192.168.0.3 on port 9042, to keyspace “coral”, using user “admin” and password “admin”.
The CassandraActor
receives the CQL statement in the query field of the trigger JSON.
The CassandraActor does not emit its result to other actors, but instead should return the answer only to the caller. Thus, the CassandraActor can only be used with a collect procedure.
The answer that the CassandraActor returns is JSON, and looks as follows:
The CassandraActor automatically converts the result of the query into a JSON object. It converts each Cassandra data type to a JSON type as in the following table:
Cassandra type | JSON type |
---|---|
ascii |
JString |
bigint |
JInt |
boolean |
JBool |
int |
JInt |
decimal |
JDecimal |
double |
JDouble |
float |
JDouble |
text |
JString |
varchar |
JString |
varint |
JInt |
timestamp |
JInt |
uuid |
JString |
An example of each of these data types is given below:
The CassandraActor
returns its state as follows:
field | type | description |
---|---|---|
connected |
boolean | Whether there is still an active connection to the Cassandra database at the time of collecting the state. |
keyspace |
String | The name of the keyspace the actor is currently connected to. |
schema |
Array | A JSON representation of the schema of the keyspace currently connected to. |
An example of a schema is as follows:
The CassandraActor
does not collect state from other actors.
The CassandraActor
does not provide timer actions.