Class: Snails::QueueOccurrence
- Inherits:
-
Sqlx::Base
- Object
- Sqlx::Base
- Snails::QueueOccurrence
- Defined in:
- runtime/snails/queue_occurrence.rbs,
runtime/snails/queue_occurrence.rb
Constant Summary collapse
- COLUMNS =
The projected columns — the ledger's identity and its write stamp, with a reader generated for each (the hash-backed accessor loop: one list,
only_columnsderives from it). %w[job_name scheduled_at created_at].each { |column| define_method(column) { read_attribute(column) } }
Constants inherited from Sqlx::Base
Instance Attribute Summary collapse
-
#created_at ⇒ Time?
readonly
Returns the value of attribute created_at.
-
#job_name ⇒ String
readonly
Returns the value of attribute job_name.
-
#scheduled_at ⇒ Time?
readonly
Returns the value of attribute scheduled_at.
Class Method Summary collapse
-
.datetime_columns ⇒ Object
Time columns: identity (
scheduled_at) and stamp (created_at) come back asTime; the list replaces the default pair. -
.insert!(job_name, scheduled_at, now) ⇒ void
put one occurrence on the ledger.
- .only_columns ⇒ Object
-
.prune_before!(scheduled_before, limit:) ⇒ Integer
retention delete for the ledger in bounded batches: occurrences past the window go, recent ones stay, and one call removes at most
limitrows (the caller repeats —Snails::QueuePruneJobowns the loop). - .table_name ⇒ Object
Methods inherited from Sqlx::Base
all, boolean_columns, date_columns, from_row, json_columns, transaction
Methods included from Sqlx::Query
#count, #create!, #delete!, #delete_all!, #exists?, #fetch_many, #find, #find_by, #find_by!, #find_by_sql, #find_each, #find_in_batches, #projection, #row_by_sql, #rows_by_sql, #update!, #update_all!, #upsert_all!, #where_clause, #write
Methods included from Sqlx::Model
Methods included from Sqlx::Row
Instance Attribute Details
#created_at ⇒ Time? (readonly)
Returns the value of attribute created_at.
7 8 9 |
# File 'runtime/snails/queue_occurrence.rbs', line 7 def created_at @created_at end |
#job_name ⇒ String (readonly)
Returns the value of attribute job_name.
5 6 7 |
# File 'runtime/snails/queue_occurrence.rbs', line 5 def job_name @job_name end |
#scheduled_at ⇒ Time? (readonly)
Returns the value of attribute scheduled_at.
6 7 8 |
# File 'runtime/snails/queue_occurrence.rbs', line 6 def scheduled_at @scheduled_at end |
Class Method Details
.datetime_columns ⇒ Object
Time columns: identity (scheduled_at) and stamp (created_at)
come back as Time; the list replaces the default pair.
26 |
# File 'runtime/snails/queue_occurrence.rb', line 26 def self.datetime_columns = %w[scheduled_at created_at] |
.insert!(job_name, scheduled_at, now) ⇒ void
put one occurrence on the ledger. The primary key is the idempotency: a
duplicate (job_name, scheduled_at) raises instead of overwriting, and the
caller turns that into "already queued". The row has no id column (the
key IS the pair), which is why the ledger brings its own insert instead of
the id-based create! re-read.
40 |
# File 'runtime/snails/queue_occurrence.rb', line 40
def self.insert!: (String job_name, Time scheduled_at, Time now) -> void
|
.only_columns ⇒ Object
22 |
# File 'runtime/snails/queue_occurrence.rb', line 22 def self.only_columns = COLUMNS.map { |c| c.to_sym } |
.prune_before!(scheduled_before, limit:) ⇒ Integer
retention delete for the ledger in bounded batches: occurrences past the
window go, recent ones stay, and one call removes at most limit rows
(the caller repeats — Snails::QueuePruneJob owns the loop). The pair IN
the subquery is the ledger's primary key, so the delete needs no id
column; it works on both backends.
56 |
# File 'runtime/snails/queue_occurrence.rb', line 56
def self.prune_before!: (Time scheduled_before, limit: Integer) -> Integer
|
.table_name ⇒ Object
15 |
# File 'runtime/snails/queue_occurrence.rb', line 15 def self.table_name = "snails_queue_occurrences" |