Class: EventMeter::Stores::Rollup::ActiveRecordPostgres
- Defined in:
- lib/event_meter/stores/rollup/active_record_postgres.rb
Defined Under Namespace
Classes: Connection
Constant Summary
Constants inherited from Postgres
Postgres::BIGINT_DIGITS, Postgres::BIGINT_MAX, Postgres::BIGINT_MIN_ABS, Postgres::KEY_VALUE_PARAM_COUNT, Postgres::LOCK_ID_MASK, Postgres::LOCK_REFRESH_RATIO, Postgres::MAX_ENTRY_ID_QUERY_PARAMS, Postgres::MAX_KEY_VALUE_ROWS, Postgres::MAX_QUERY_PARAMS, Postgres::SCOPED_QUERY_PARAMS
Instance Attribute Summary collapse
-
#connection_class ⇒ Object
readonly
Returns the value of attribute connection_class.
Attributes inherited from Postgres
#connection, #connection_lock, #lock_scope, #namespace, #report_name, #table_prefix, #version
Class Method Summary collapse
- .default_connection_class ⇒ Object
- .install!(connection_class: default_connection_class, table_prefix: "event_meter") ⇒ Object
Instance Method Summary collapse
- #for_report(name:, version:) ⇒ Object
-
#initialize(connection_class: self.class.default_connection_class, lock_connection: nil, **options) ⇒ ActiveRecordPostgres
constructor
A new instance of ActiveRecordPostgres.
Methods inherited from Postgres
#apply, #cleanup_history, #cleanup_watermark, #ensure_definition, #forget_processed_ids, #get, #hgetall_many, #keys_matching, #processed_ids, #report_definition, schema_sql, validate_identifier!, #with_lock, #write_cleanup_watermark
Constructor Details
#initialize(connection_class: self.class.default_connection_class, lock_connection: nil, **options) ⇒ ActiveRecordPostgres
Returns a new instance of ActiveRecordPostgres.
107 108 109 110 111 112 113 114 |
# File 'lib/event_meter/stores/rollup/active_record_postgres.rb', line 107 def initialize(connection_class: self.class.default_connection_class, lock_connection: nil, **) @connection_class = connection_class super( connection: Connection.new(connection_class), lock_connection: lock_connection || Connection.new(connection_class), ** ) end |
Instance Attribute Details
#connection_class ⇒ Object (readonly)
Returns the value of attribute connection_class.
90 91 92 |
# File 'lib/event_meter/stores/rollup/active_record_postgres.rb', line 90 def connection_class @connection_class end |
Class Method Details
.default_connection_class ⇒ Object
101 102 103 104 105 |
# File 'lib/event_meter/stores/rollup/active_record_postgres.rb', line 101 def self.default_connection_class return ::ActiveRecord::Base if defined?(::ActiveRecord::Base) raise ConfigurationError, "ActiveRecord is required for active_record_postgres rollup storage" end |
.install!(connection_class: default_connection_class, table_prefix: "event_meter") ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/event_meter/stores/rollup/active_record_postgres.rb', line 92 def self.install!(connection_class: default_connection_class, table_prefix: "event_meter") connection_class.connection_pool.with_connection do |connection| Postgres.install!( connection: connection.raw_connection, table_prefix: table_prefix ) end end |
Instance Method Details
#for_report(name:, version:) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/event_meter/stores/rollup/active_record_postgres.rb', line 116 def for_report(name:, version:) name = name.to_s version = version.to_i self.class.new( connection_class: connection_class, connection_lock: connection_lock, lock_connection: lock_connection, lock_connection_lock: lock_connection_lock, namespace: namespace, table_prefix: table_prefix, report_name: name, version: version, lock_scope: "#{Keys.event_name(name)}:#{Keys.version_key(version)}" ) end |