Cassandra Configuration setting for initialization session between cassandra and application.
require 'cassandra'
class CassandraPushCluster
CASSANDRA_KEYSPACE = 'mmm_push_event'
CASSANDRA_HOSTS = ["127.0.0.1"]
def self.session
@@session ||= Cassandra.cluster(hosts: CASSANDRA_HOSTS).connect(CASSANDRA_KEYSPACE)
end
def self.validate_date(date)
formated_date = date.nil? ? Cassandra::Types::Timestamp.new(Time.zone.now) : Cassandra::Types::Timestamp.new(date)
end
end
-------------query for session prepare--------------------
event_tracking = CassandraPushCluster.session.prepare("INSERT INTO push_event_tracking_#{params[:account_id].to_i} (account_id, push_application_id, push_device_id, name, content_id, title, description, category, total_value, latitude, longitude, created_at, session_id, platform) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
--------- execute session query -----------
CassandraPushCluster.session.execute(event_tracking, arguments: [params[:account_id].to_i, params[:push_application_id].to_i, params[:push_device_id].to_i, params[:event_name], params[:content_id].to_i, params[:title], params[:description], params[:category], params[:value].to_f, params[:latitude].to_f, params[:longitude].to_f, Time.zone.now, params[:session_id].to_i, params[:platform].to_i])
No comments:
Post a Comment