Class: SolidObserver::Services::StorageInfoSnapshot::Component
- Inherits:
-
Struct
- Object
- Struct
- SolidObserver::Services::StorageInfoSnapshot::Component
- Defined in:
- lib/solid_observer/services/storage_info_snapshot.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#key ⇒ Object
Returns the value of attribute key.
-
#label ⇒ Object
Returns the value of attribute label.
-
#model ⇒ Object
Returns the value of attribute model.
-
#record_label ⇒ Object
Returns the value of attribute record_label.
Instance Method Summary collapse
- #available_snapshot(db_size_bytes:, event_count:) ⇒ Object
- #data_source_exists?(connection, table_name) ⇒ Boolean
- #database_size(connection, table_name) ⇒ Object
- #enabled? ⇒ Boolean
- #snapshot ⇒ Object
- #solid_cache? ⇒ Boolean
- #storage_model ⇒ Object
- #unavailable_snapshot(reason:) ⇒ Object
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled
8 9 10 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 8 def enabled @enabled end |
#key ⇒ Object
Returns the value of attribute key
8 9 10 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 8 def key @key end |
#label ⇒ Object
Returns the value of attribute label
8 9 10 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 8 def label @label end |
#model ⇒ Object
Returns the value of attribute model
8 9 10 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 8 def model @model end |
#record_label ⇒ Object
Returns the value of attribute record_label
8 9 10 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 8 def record_label @record_label end |
Instance Method Details
#available_snapshot(db_size_bytes:, event_count:) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 38 def available_snapshot(db_size_bytes:, event_count:) { component: key, label: label, available: true, db_size_bytes: db_size_bytes, event_count: event_count, record_label: record_label, recorded_at: Time.current, unavailable_reason: nil } end |
#data_source_exists?(connection, table_name) ⇒ Boolean
21 22 23 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 21 def data_source_exists?(connection, table_name) connection.data_source_exists?(table_name) end |
#database_size(connection, table_name) ⇒ Object
25 26 27 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 25 def database_size(connection, table_name) DatabaseSize.call(connection: connection, table_name: table_name) end |
#enabled? ⇒ Boolean
9 10 11 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 9 def enabled? enabled.call end |
#snapshot ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 29 def snapshot return unless enabled? return unavailable_snapshot(reason: "SolidCache is unavailable") if unavailable_solid_cache? existing_data_source_snapshot rescue *StorageInfoSnapshot::CONNECTION_ERRORS, TypeError unavailable_snapshot(reason: "Storage unavailable") end |
#solid_cache? ⇒ Boolean
13 14 15 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 13 def solid_cache? key == "solid_cache" end |
#storage_model ⇒ Object
17 18 19 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 17 def storage_model model.call end |
#unavailable_snapshot(reason:) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/solid_observer/services/storage_info_snapshot.rb', line 51 def unavailable_snapshot(reason:) { component: key, label: label, available: false, db_size_bytes: nil, event_count: nil, record_label: record_label, recorded_at: nil, unavailable_reason: reason } end |