inboxable 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -3
- data/README.md +5 -2
- data/lib/inboxable/polling_receiver_worker.rb +5 -5
- data/lib/inboxable/version.rb +1 -1
- data/lib/templates/mongoid_inbox.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4d81533a77f953ec0b2e7b5b7b86dee4da59cfec008aedad5a9234a8303d7dd
|
4
|
+
data.tar.gz: ac85e6bb520fed77412e3c233dd6ac9385f828244f744d79da820a964c3f2e55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84cbdd6b4070185a8ce0322225c76b4490b0ec78e415c924c47ba0bc0c0a632170e9ba946a17cebb992b372422cd2a3ef05890b8a6baeb8f67e365779539c007
|
7
|
+
data.tar.gz: ad3d25d9823c1a45288c49b402b2f92de3ff519415a02bbe3a40ced00b8c2f2316e795e6282911869c8136158552be696caa26d52543c5fbb288edb93184269d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
|
+
This file is used to list changes made in each version of the inboxable gem.
|
2
3
|
|
3
|
-
##
|
4
|
+
## Inboxable 0.1.2 (2024-01-22)
|
4
5
|
|
5
|
-
|
6
|
+
* Added scope for each status key in the `Inbox` model to fetch the
|
7
|
+
corresponding records.
|
8
|
+
|
9
|
+
## Inboxable 0.1.1 (2024-01-22)
|
10
|
+
|
11
|
+
* Added `inbox_model` configuration to the `Configuration` class to allow for custom
|
12
|
+
inbox models.
|
13
|
+
|
14
|
+
## Inboxable 0.1.0 (2024-01-22)
|
15
|
+
|
16
|
+
* Initial release
|
data/README.md
CHANGED
@@ -80,7 +80,9 @@ The options are as follows:
|
|
80
80
|
|
81
81
|
## Inbox Model
|
82
82
|
|
83
|
-
The Inbox model is used to store the messages in the inbox. The Inbox model is generated by the gem when you run the `rails g inboxable:install --orm <orm>` command. Based on the ORM that you are using, the gem will generate the appropriate model.
|
83
|
+
The Inbox model is used to store the messages in the inbox. The Inbox model is generated by the gem when you run the `rails g inboxable:install --orm <orm>` command. Based on the ORM that you are using, the gem will generate the appropriate model.The following is the structure of the Inbox model for ActiveRecord and Mongoid.
|
84
|
+
|
85
|
+
If you would like to use a different name for the Inbox model. You can configure it by setting the `inbox_model` config to the name of you custom defined model. See the [Configuration](#configuration) section below for more information.
|
84
86
|
|
85
87
|
### Fields & Attributes
|
86
88
|
|
@@ -123,7 +125,8 @@ The Inboxable gem provides a number of configuration options that can be used to
|
|
123
125
|
---
|
124
126
|
| Option | Description | Default Value | Applied To |
|
125
127
|
| --- | --- |------------------|---|
|
126
|
-
| `orm` | The ORM that is used in the application. | `:active_record` | `/config/initializers/
|
128
|
+
| `orm` | The ORM that is used in the application. | `:active_record` | `/config/initializers/z_inboxable.rb` |
|
129
|
+
| `inbox_model` | The name of the Inbox model. | `Inbox` | `/config/initializers/z_inboxable.rb` |
|
127
130
|
|`INBOXABLE__CRON_POLL_INTERVAL` | The interval in seconds between each poll of the inbox. | `5` | Can be overridden by providing an environment variable with the same name. |
|
128
131
|
|`INBOXABLE__CRON` | The cron expression that is used to poll the inbox. | `*/5 * * * * *` | Can be overridden by providing an environment variable with the same name. |
|
129
132
|
|`INBOXABLE__BATCH_SIZE` | The number of messages to be processed in each batch. | `100` | Can be overridden by providing an environment variable with the same name. |
|
@@ -10,9 +10,9 @@ module Inboxable
|
|
10
10
|
|
11
11
|
def perform_activerecord
|
12
12
|
Inboxable.inbox_model.pending
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
.where(last_attempted_at: [..Time.zone.now, nil])
|
14
|
+
.find_in_batches(batch_size: ENV.fetch('INBOXABLE__BATCH_SIZE', 100).to_i)
|
15
|
+
.each do |batch|
|
16
16
|
batch.each do |inbox|
|
17
17
|
inbox.processor_class_name.constantize.perform_async(inbox.id)
|
18
18
|
inbox.update(last_attempted_at: 1.minute.from_now, status: :processed, allow_processing: false)
|
@@ -23,8 +23,8 @@ module Inboxable
|
|
23
23
|
def perform_mongoid
|
24
24
|
batch_size = ENV.fetch('INBOXABLE__BATCH_SIZE', 100).to_i
|
25
25
|
Inboxable.inbox_model.pending
|
26
|
-
|
27
|
-
|
26
|
+
.any_of({ last_attempted_at: ..Time.zone.now }, { last_attempted_at: nil })
|
27
|
+
.each_slice(batch_size) do |batch|
|
28
28
|
batch.each do |inbox|
|
29
29
|
inbox.processor_class_name.constantize.perform_async(inbox.id.to_s)
|
30
30
|
inbox.update(last_attempted_at: 1.minute.from_now, status: :processed, allow_processing: false)
|
data/lib/inboxable/version.rb
CHANGED
@@ -19,6 +19,10 @@ class Inbox
|
|
19
19
|
|
20
20
|
as_enum :status, %i[pending processed failed], field: { type: String, default: 'pending' }, map: :string
|
21
21
|
|
22
|
+
statuses.each_key do |key|
|
23
|
+
scope key, -> { where(status_cd: key) }
|
24
|
+
end
|
25
|
+
|
22
26
|
validates :processor_class_name, presence: true
|
23
27
|
|
24
28
|
after_create :process, if: proc { |resource| resource.allow_processing == true }
|