No commit activity in last 3 years
No release in over 3 years
The library allows to archive destroyed record to cassandra. For that moment ActiveRecord is supported.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.0.0
>= 0.12.2
 Project Readme

Description

The active record extension implements the archive functionality to cassandra database. After record get deleted it replicates the copy of all attributes of that object to cassandra.

Example of usage

Before you start using library you need to create column family where archived records will be stored

create keyspace CassandraArchive_test;
create column family DeletedRecords with column_type='Super' and comparator='UTF8Type' and subcomparator='UTF8Type';

initialize cassandra connection

::CASSANDRA_CLIENT = Cassandra.new(keyspace, hosts)

and include module into model you want to archive after destroying

class Service < ActiveRecord::Base
  include CassandraArchive
end

After you delete a record, it will be automatically replicated to cassandra in the following format

column_family will be 'DeletedRecords'
row_id will be the same as table name, for example above it will be 'services'
column_name is the removal timestamp, it looks like '1361974054666398'
column_attributes will contain the active record attributes

The model will be extended with :archived method

Service.archived                      # returns list of all archived records for that model
Service.archived(:after => 3.day.ago) # returns list of archived records for last 3 days

Service.archived do |timestamp, attributes|
  # the block is called for each archived record
  # timestamp shows when record has been archived
end

You may want to store the data which is not presented as active record attribute, it can be dynamic attribute or something like that. For that purpose you define :cassandra_archive_attributes method where you define the list of attributes you want to archive.

class Service < ActiveRecord::Base
  include CassandraArchive

  def cassandra_archive_attributes
    # all active record attributes will be archived plus :account_name
    attributes.keys + [:account_name]
  end

  def account_name
    # the code here does request to the service in order to get account name
  end
end

Running tests

Before you run tests do this in cassandra-cli:

use CassandraArchive_test; # create it first if it doesn't exist
create column family DeletedRecords with column_type='Super' and comparator='UTF8Type' and subcomparator='UTF8Type';

then run rake