Skip to content

Commit

Permalink
Rename keep_messages_around_for to message_retention to pair with pol…
Browse files Browse the repository at this point in the history
…ling_interval (#9)

* Rename keep_messages_around_for to message_retention to pair with polling_interval

Keeps parity in the config naming scheme.

* Fix after merge

---------

Co-authored-by: Nick Pezza <[email protected]>
  • Loading branch information
dhh and npezza93 authored Sep 12, 2024
1 parent a7a1aa3 commit 7d39483
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ production:
database:
writing: cable
polling_interval: 0.1.seconds
keep_messages_around_for: 1.day
message_retention: 1.day
```

The options are:

- `connects_to` - set the Active Record database configuration for the Solid Cable models. All options available in Active Record can be used here.
- `polling_interval` - sets the frequency of the polling interval.
- `keep_messages_around_for` - sets the retention time for messages kept in the database. Used as the cut-off when trimming is performed.
- `message_retention` - sets the retention time for messages kept in the database. Used as the cut-off when trimming is performed.

## Trimming

Currently, messages are kept around forever, and have to be manually pruned via the `SolidCable::PruneJob.perform_later` job.
This job uses the `keep_messages_around_for` setting to determine how long messages are to be kept around.
This job uses the `message_retention` setting to determine how long messages are to be kept around.

## License

Expand Down
2 changes: 1 addition & 1 deletion app/models/solid_cable/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module SolidCable
class Message < SolidCable::Record
scope :prunable, lambda {
where(created_at: ..::SolidCable.keep_messages_around_for.ago)
where(created_at: ..::SolidCable.message_retention.ago)
}
scope :broadcastable, lambda { |channels, last_id|
where(channel: channels).where(id: (last_id + 1)..).order(:id)
Expand Down
4 changes: 2 additions & 2 deletions bench/config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ development:
# adapter: redis
# url: redis://localhost:6379/1
adapter: solid_cable
keep_messages_around_for: 15.minutes
message_retention: 15.minutes
polling_interval: 0.1.seconds
connects_to:
database:
Expand All @@ -18,5 +18,5 @@ production:
# channel_prefix: cablebench_production

adapter: solid_cable
keep_messages_around_for: ever
message_retention: ever
polling_interval: 0.2.seconds
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ production:
database:
writing: cable
polling_interval: 0.1.seconds
keep_messages_around_for: 1.day
message_retention: 1.day
4 changes: 2 additions & 2 deletions lib/solid_cable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def polling_interval
parse_duration(cable_config.polling_interval, default: 0.1.seconds)
end

def keep_messages_around_for
parse_duration(cable_config.keep_messages_around_for, default: 1.day)
def message_retention
parse_duration(cable_config.message_retention, default: 1.day)
end

private
Expand Down

0 comments on commit 7d39483

Please sign in to comment.