Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 7 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jul 10, 2012
@jlouis jlouis Provide configuration documentation. c1b759e
@jlouis jlouis Fix cassanderl application dependency.
When cassanderl is starting up, it needs to be dependent on `thrift`
and `cassandra_thrift`. None of these start anything but the
dependency needs to be there so the reltool can automatically figure
out the dependency. It also means errors will make the application
startup fail, which is what we want over a half-running system.
3535195
@lpgauth lpgauth Merge pull request #3 from jlouis/jlouis-documentation
Provide configuration documentation.
eb749d4
@lpgauth lpgauth Merge pull request #4 from jlouis/jlouis-config-dependency
Fix cassanderl application dependency.
1382ca3
Commits on Jul 12, 2012
@jlouis jlouis Update README.md with more information. 2b8e7d8
@jlouis jlouis Implement the `add` command. 4168fc8
@lpgauth lpgauth Merge pull request #5 from jlouis/jlouis-command-add
Jlouis command add
33eca4d
Showing with 94 additions and 5 deletions.
  1. +65 −2 README.md
  2. +3 −1 src/cassanderl.app.src
  3. +26 −2 src/cassanderl.erl
View
67 README.md
@@ -1,7 +1,70 @@
## Cassanderl version 0.4 ##
-TODO
+## Configuration ##
+
+To start cassanderl, you will need to configure a section in your
+application config file:
+
+ {cassanderl,
+ [{hostname, "cassandra.talented-startup.com"},
+ {port, 9160},
+ {default_keyspace, "big_data"},
+ {worker_pool_size, 10}
+ ]},
+
+The options are as follows:
+
+* `hostname` - The hostname to connect to
+* `port` - The port to connect to. Cassandra RPC is on port 9160 by default
+* `default_keyspace` - If you omit setting a keyspace, this keyspace
+will be used for a newly formed connection.
+* `worker_pool_size` - The size of the worker pool. How many concurrent
+resource-connections do you allow to the cassandra cluster.
+
+Second, you will need to start up cassanderl (or make it part of your
+boot script):
+
+ application:start(cassanderl).
+
+## Example of Usage ##
+
+To use Cassanderl, you must first ask it for the current
+configuration.
+
+ {ok, Config} = cassanderl:get_info().
+
+This will return the current dispatcher configuration. Cassanderl
+spawns a pool of dispatchers by default which it then uses whenever
+you want to access your Cassandra cluster. The hostname and portname
+of the cluster will be the defaults as well when doing this.
+
+To issue a call to Cassandra, issue:
- {ok, Config} = cassanderl_sup:get_info().
cassanderl:call(Config, describe_keyspace, ["keyspace1"]).
+Which performs a low-level call to Cassandra with the given
+configuration, the given (thrift) method and the given parameters to
+the call.
+
+The module `cassanderl` has certain helpers as well for often-executed
+functions.
+
+### Commands ###
+
+### Add ###
+
+To issue an `add` towards Cassandra, do the following:
+
+ {ok, Config} = cassanderl:get_info(),
+ CP = cassanderl:column_parent(<<"superhero_stats">>),
+ {ok, CassandraResult} =
+ add(Config, <<"gotham city">>, CP, {<<"batmans_spotted">>, 7}, 1).
+
+In this example, we first generate a "column parent" for the column
+family. There are no super-columns here, so just referring to the
+superhero stats is enough. The `CP` acts like an accessor pattern on
+the data we wish to update and can be reused in subsequent calls if we
+want.
+
+Finally, we increment a counter on the *Gotham City* row. We spotted
+some Batmans. The last parameter is the consistency level desired.
View
4 src/cassanderl.app.src
@@ -4,7 +4,9 @@
{registered, []},
{applications, [
kernel,
- stdlib
+ stdlib,
+ thrift,
+ cassandra_thrift
]},
{mod, { cassanderl_app, []}},
{env, [
View
28 src/cassanderl.erl
@@ -4,7 +4,17 @@
%% ------------------------------------------------------------------
%% API Function Exports
%% ------------------------------------------------------------------
--export([get_info/0, call/2, call/3, set_keyspace/2, get/6, insert/9, describe_keyspace/2]).
+-export([column_parent/1, column_parent/2,
+ get_info/0
+ ]).
+
+-export([add/5,
+ call/2, call/3,
+ describe_keyspace/2,
+ get/6,
+ insert/9,
+ set_keyspace/2
+ ]).
%% ------------------------------------------------------------------
%% API Function Definitions
@@ -13,6 +23,13 @@
get_info() ->
cassanderl_sup:get_info().
+column_parent(Family) ->
+ #columnParent { column_family = Family }.
+
+column_parent(Super, Family) ->
+ #columnParent { super_column = Super,
+ column_family = Family }.
+
call(Function, Args) ->
{ok, Config} = get_info(),
call(Config, Function, Args).
@@ -75,4 +92,11 @@ insert(Info, Key, ColumnFamily, SuperColumn, Name, Value, Timestamp, Ttl, Consis
call(Info, insert, [Key, ColumnParent, Column, ConsistencyLevel]).
describe_keyspace(Info, Keyspace) ->
- call(Info, describe_keyspace, [Keyspace]).
+ call(Info, describe_keyspace, [Keyspace]).
+
+add(Config, Key, ColumnParent, {Name, Value}, ConsistencyLevel) ->
+ add(Config, Key, ColumnParent, #counterColumn {
+ name = Name,
+ value = Value }, ConsistencyLevel);
+add(Config, Key, ColumnParent, #counterColumn{} = Col, ConsistencyLevel) ->
+ call(Config, add, [Key, ColumnParent, Col, ConsistencyLevel]).

No commit comments for this range

Something went wrong with that request. Please try again.