renote_dac 0.0.166 → 0.0.167

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 863d9881dbdb888fedc4e48c022713a9ad298203148ac872021c5c0a492d4581
4
- data.tar.gz: 35e831bfb7c74019a97b4033d0ef9c996af3aa87b6bb9c73c586f3739bad740b
3
+ metadata.gz: 28afa35fa2593b92bf799b7305d34c2d6e8a1e4545e3d3d6b21e808baefffa1c
4
+ data.tar.gz: fddd7575cef5d0b45136f304c59d7b5bbb9b2f43f82166f625ba49514bad0a6d
5
5
  SHA512:
6
- metadata.gz: 84173ebd24d7846846ff40417c161157f975a5a50dc946b5786fca43e98b66f2afdc209b3bba2021966a637d08796dae891856aad6d821cc2fc4b8b3db20917a
7
- data.tar.gz: 1633a6d1206ddb72d14b8bff09ab42388eed8adab29fff483d9fe46881b111baee7ef0fd424bf9dcb03afb6f699881701ad01f5216c2f9c49821e9e841b32bff
6
+ metadata.gz: 136cfa8b5d4c714b65970d4eb79017d45950bc4ec280887f8d2f24b4e8f91e0104f324440cd8ec2a9d8cee94b0aca840919d5775e20fe0ebf1737296fd914291
7
+ data.tar.gz: 782b05051b9ef295c5dd3e7e6361e3b4abb16bc8ff00b9e9492fa71c53695d2549f0ce2a79c23f0d339271a7d43c818cfe59633f99ccc02e6bf1d7a0e8ec361c
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  This is a set of libraries and dependencies which allow you to quickly spin up a RabbitMQ powered Email/Notification Service as part of a (S)ervice (O)riented (A)rchitechture.
3
3
 
4
4
  ## Usage
5
- To implement this gem it is necessary to implement the client-server RenoteDac configuration either manually or by installing the [renote_dac_client gem](https://github.com/leather-s/renote_dac)
5
+ To implement this gem it is necessary to implement the server/publisher RenoteDac configuration either manually or by installing the [publisher_renote_dac gem](https://github.com/leather-s/publisher_renote_dac)
6
6
 
7
7
  RenoteDac is the subscriber end of a pub/sub notification service thats been extracted for use as a gem. The publisher app publish messages to a RabbitMQ exchange which then pushes the messages to a queue.
8
8
 
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RenoteDac
4
+
5
+ class PushPendingEmailsJob < Que::Job
6
+
7
+ @priority = 10
8
+
9
+ def run
10
+ (destroy && return) unless obtained_lock?
11
+
12
+ begin
13
+ loop do
14
+ if Que.worker_count.zero?
15
+ raise 'Gracefully terminating job early...'
16
+ end
17
+
18
+ count = RenoteDac::Mailer::Client.new.process_batch
19
+
20
+ puts "This job expired #{count} auctions."
21
+
22
+ break if count.zero?
23
+ end
24
+ ensure
25
+ release_lock
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def obtained_lock?
32
+ ActiveRecord::Base.connection.select_value('SELECT pg_try_advisory_lock(1);')
33
+ end
34
+
35
+ def release_lock
36
+ ActiveRecord::Base.connection.select_value('SELECT pg_advisory_unlock(1);')
37
+ end
38
+ end
39
+
40
+ end
data/config/clock.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'clockwork'
4
+ require './config/boot'
5
+ require './config/environment'
6
+
7
+ module Clockwork
8
+
9
+ every(5.seconds, 'RenoteDac::PushPendingEmailsJob', tz: 'UTC') do
10
+ RenoteDac::PushPendingEmailsJob.enqueue
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ Que.mode = :off
4
+ Que.worker_count = 1
5
+ Que.wake_interval = 5.0
6
+ Que.logger = Logger.new(STDOUT)
7
+
8
+ Que.log_formatter = proc do |data|
9
+ # exclude :job_unavailable which creates a lot of chatter
10
+ if [:job_unavailable].exclude?(data[:event])
11
+ JSON.dump(data)
12
+ end
13
+ end
@@ -2,6 +2,8 @@ require 'bcrypt'
2
2
  require 'sneakers'
3
3
  require 'postmark'
4
4
  require 'jbuilder'
5
+ require 'que'
6
+ require 'clockwork'
5
7
 
6
8
  module RenoteDac
7
9
  class Engine < ::Rails::Engine
@@ -36,7 +36,7 @@ module RenoteDac
36
36
 
37
37
  def self.get_template_meta(template)
38
38
  meta = TEMPLATES[template.to_sym]
39
- raise RnoteDac::Mailer::InvalidTemplate unless meta
39
+ raise RenoteDac::Mailer::InvalidTemplate unless meta
40
40
  meta
41
41
  end
42
42
 
@@ -109,7 +109,7 @@ module RenoteDac
109
109
  private
110
110
 
111
111
  def handle_resp(ids, responses)
112
- raise 'Postmark response size mismatch' if ids.size != responses.size
112
+ raise 'Postmark response size mis-match' if ids.size != responses.size
113
113
 
114
114
  # http://developer.postmarkapp.com/developer-api-overview.html#error-codes
115
115
  #
@@ -1,3 +1,3 @@
1
1
  module RenoteDac
2
- VERSION = '0.0.166'
2
+ VERSION = '0.0.167'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renote_dac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.166
4
+ version: 0.0.167
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sidney Leatherwood
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.7'
111
+ - !ruby/object:Gem::Dependency
112
+ name: que
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: clockwork
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  description: Rails engine for bundling all the configurations and depencies necessary
112
140
  to run a remote mailing/notification service.
113
141
  email:
@@ -124,13 +152,15 @@ files:
124
152
  - app/controllers/renote_dac/api_controller.rb
125
153
  - app/controllers/renote_dac/application_controller.rb
126
154
  - app/helpers/renote_dac/application_helper.rb
127
- - app/jobs/renote_dac/application_job.rb
155
+ - app/jobs/renote_dac/push_pending_emails_job.rb
128
156
  - app/models/renote_dac/application_record.rb
129
157
  - app/models/renote_dac/email.rb
130
158
  - app/views/layouts/application.html.erb
131
159
  - app/views/layouts/renote_dac/api/v1/emails/_index.json.jbuilder
132
160
  - app/views/layouts/renote_dac/api/v1/emails/_show.json.jbuilder
133
161
  - app/workers/renote_dac/service_queue_worker.rb
162
+ - config/clock.rb
163
+ - config/initializers/que.rb
134
164
  - config/initializers/sneakers.rb
135
165
  - config/routes.rb
136
166
  - config/settings.local.yml
@@ -1,4 +0,0 @@
1
- module RenoteDac
2
- class ApplicationJob < ActiveJob::Base
3
- end
4
- end