outboxer 0.1.2 → 0.1.5

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: 99b8c36fa2db36b780ca732a63aba4df7f38ccd06d7a2403961a2cb483085153
4
- data.tar.gz: 33db69284cdbc1fbf8398c98799deabd2a09b38eb863df2e2f88943db2bfa25d
3
+ metadata.gz: '09cf4072016f1a5b13d16bbef92f26ac4efaaa1d953b0a4752440e4acfda203a'
4
+ data.tar.gz: 7dd61b6f0bb552fd13e6e9f607c34fce18c44095c5902edc09b4cbfec0009e30
5
5
  SHA512:
6
- metadata.gz: 5191c2ba363decec6729efd72dbaadd697241f74c11f07dfd722874fdc6df8be0b5001e696159f0ba17e2c744447dc11c256f90af17edb6bb03c68452e237c31
7
- data.tar.gz: fdd2cfaecfa7d2972566ef340a164992325a1c08cc5810c7eee20a4218901082fb2ce45dcd10cb66ecd3747ffc55b5a3f135cb8a0acb7fb80a74f2c4d9e012c0
6
+ metadata.gz: fcc1a3b0e3cf6c7b29ede1469148d78a567456726a87113f5355209fa3623b35ec8e401ad3dcd155888d057c1c45bb95893c613aee5f849448a9a6eca6b5de2a
7
+ data.tar.gz: 84f3e8873c693f8c0652561a848f0da423764de489902456c335d9f638882964052f08e7a63e2d65fd020a0338110df8b84cf789a9b1fe87936b0ee68ed2ee14
data/README.md CHANGED
@@ -51,11 +51,12 @@ end
51
51
 
52
52
  ```ruby
53
53
  Outboxer::Publisher.publish do |args|
54
- args.logger.info("[#{message.id}] publishing")
54
+ logger = args.logger
55
+ message = args.message
55
56
 
56
- Worker.perform_async({ message_id: args.message.id })
57
-
58
- args.logger.info("[#{message.id}] published")
57
+ logger.info("[#{message.id}] publishing")
58
+ HardJob.perform_async({ "message_id" => message.id })
59
+ logger.info("[#{message.id}] published")
59
60
  end
60
61
  ```
61
62
 
data/Rakefile CHANGED
@@ -1,10 +1,14 @@
1
- require "bundler/gem_tasks"
1
+ # require "bundler/gem_tasks"
2
+ # require "bundler/setup"
2
3
  require "rspec/core/rake_task"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
7
+ require 'pry'
6
8
  require "rubocop/rake_task"
7
9
 
8
10
  RuboCop::RakeTask.new
9
11
 
10
12
  task default: %i[spec rubocop]
13
+
14
+ load 'lib/tasks/gem.rake'
@@ -7,8 +7,6 @@ Outboxer::Publisher.publish do |args|
7
7
  message = args.message
8
8
 
9
9
  logger.info("[#{message.id}] publishing")
10
-
11
10
  HardJob.perform_async({ "message_id" => message.id })
12
-
13
11
  logger.info("[#{message.id}] published")
14
12
  end
@@ -0,0 +1,9 @@
1
+ require "active_record"
2
+
3
+ module Outboxer
4
+ class Exception < ::ActiveRecord::Base
5
+ self.table_name = :outboxer_exceptions
6
+
7
+ belongs_to :message, class_name: "::Outboxer::Message"
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require "active_record"
2
+
3
+ module Outboxer
4
+ class Message < ::ActiveRecord::Base
5
+ self.table_name = :outboxer_messages
6
+
7
+ STATUS = {
8
+ unpublished: "unpublished",
9
+ publishing: "publishing",
10
+ failed: "failed"
11
+ }.freeze
12
+
13
+ belongs_to :message, polymorphic: true
14
+
15
+ has_many :exceptions, -> { order(created_at: :asc) },
16
+ class_name: "::Outboxer::Exception",
17
+ dependent: :destroy
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ module Outboxer
2
+ module Outboxable
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+
6
+ base.class_eval do
7
+ has_one :message, class_name: "::Outboxer::Message", as: :outbox_message,
8
+ dependent: :destroy
9
+
10
+ after_create :create_outbox_message!
11
+ end
12
+ end
13
+
14
+ def create_outbox_message!
15
+ Message.create!(message: self, status: Message::STATUS[:unpublished])
16
+ end
17
+
18
+ module ClassMethods
19
+ end
20
+ end
21
+ end
@@ -54,14 +54,14 @@ module Outboxer
54
54
  def dequeue(backoff:)
55
55
  retry_on_error(backoff: backoff) do
56
56
  ActiveRecord::Base.transaction do
57
- message = Models::Message
58
- .where(status: Models::Message::STATUS[:unpublished])
57
+ message = Message
58
+ .where(status: Message::STATUS[:unpublished])
59
59
  .order(created_at: :asc)
60
60
  .limit(1)
61
61
  .lock("FOR UPDATE SKIP LOCKED")
62
62
  .first
63
63
 
64
- message&.update!(status: Models::Message::STATUS[:publishing])
64
+ message&.update!(status: Message::STATUS[:publishing])
65
65
 
66
66
  message
67
67
  end
@@ -81,7 +81,7 @@ module Outboxer
81
81
 
82
82
  retry_on_error(backoff: backoff) do
83
83
  ActiveRecord::Base.transaction do
84
- outboxer_message.update!(status: Models::Message::STATUS[:failed])
84
+ outboxer_message.update!(status: Message::STATUS[:failed])
85
85
 
86
86
  outboxer_message.exceptions.create!(
87
87
  class_name: exception.class.name,
@@ -1,3 +1,3 @@
1
1
  module Outboxer
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/outboxer.rb CHANGED
@@ -2,14 +2,12 @@ require "active_support"
2
2
 
3
3
  require_relative "outboxer/version"
4
4
  require_relative "outboxer/railtie" if defined?(Rails)
5
- require_relative "outboxer/models/outboxable"
6
- require_relative "outboxer/models/message"
7
- require_relative "outboxer/models/exception"
5
+
6
+ require_relative "outboxer/outboxable"
7
+ require_relative "outboxer/message"
8
+ require_relative "outboxer/exception"
8
9
 
9
10
  require_relative "outboxer/publisher"
10
11
 
11
12
  module Outboxer
12
- Outboxable = Models::Outboxable
13
- Message = Models::Message
14
- Exception = Models::Exception
15
13
  end
data/outboxer.gemspec CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
16
  spec.metadata["source_code_uri"] = "https://github.com/fast-programmer/outboxer"
17
- # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
18
- spec.metadata['yard.run'] = 'yard'
17
+ spec.metadata["documentation_uri"] = "https://rubydoc.info/github/fast-programmer/outboxer/master"
18
+ spec.metadata["changelog_uri"] = "https://github.com/fast-programmer/outboxer/blob/master/CHANGELOG.md"
19
19
  spec.metadata["rubygems_mfa_required"] = "true"
20
20
 
21
21
  spec.files = Dir.chdir(__dir__) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outboxer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Mikulasev
@@ -38,37 +38,14 @@ files:
38
38
  - LICENSE.txt
39
39
  - README.md
40
40
  - Rakefile
41
- - doc/Outboxer.html
42
- - doc/Outboxer/Models.html
43
- - doc/Outboxer/Models/Exception.html
44
- - doc/Outboxer/Models/Message.html
45
- - doc/Outboxer/Models/Outboxable.html
46
- - doc/Outboxer/Models/Outboxable/ClassMethods.html
47
- - doc/Outboxer/Publisher.html
48
- - doc/Outboxer/Publisher/Args.html
49
- - doc/Outboxer/Railtie.html
50
- - doc/_index.html
51
- - doc/class_list.html
52
- - doc/css/common.css
53
- - doc/css/full_list.css
54
- - doc/css/style.css
55
- - doc/file.README.html
56
- - doc/file_list.html
57
- - doc/frames.html
58
- - doc/index.html
59
- - doc/js/app.js
60
- - doc/js/full_list.js
61
- - doc/js/jquery.js
62
- - doc/method_list.html
63
- - doc/top-level-namespace.html
64
41
  - generators/outboxer/install_generator.rb
65
42
  - generators/outboxer/templates/bin/publisher.rb
66
43
  - generators/outboxer/templates/migrations/create_outboxer_exceptions.rb
67
44
  - generators/outboxer/templates/migrations/create_outboxer_messages.rb
68
45
  - lib/outboxer.rb
69
- - lib/outboxer/models/exception.rb
70
- - lib/outboxer/models/message.rb
71
- - lib/outboxer/models/outboxable.rb
46
+ - lib/outboxer/exception.rb
47
+ - lib/outboxer/message.rb
48
+ - lib/outboxer/outboxable.rb
72
49
  - lib/outboxer/publisher.rb
73
50
  - lib/outboxer/railtie.rb
74
51
  - lib/outboxer/version.rb
@@ -80,7 +57,8 @@ licenses:
80
57
  metadata:
81
58
  homepage_uri: https://github.com/fast-programmer/outboxer
82
59
  source_code_uri: https://github.com/fast-programmer/outboxer
83
- yard.run: yard
60
+ documentation_uri: https://rubydoc.info/github/fast-programmer/outboxer/master
61
+ changelog_uri: https://github.com/fast-programmer/outboxer/blob/master/CHANGELOG.md
84
62
  rubygems_mfa_required: 'true'
85
63
  post_install_message:
86
64
  rdoc_options: []
@@ -1,124 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Class: Outboxer::Models::Exception
8
-
9
- &mdash; Documentation by YARD 0.9.34
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "Outboxer::Models::Exception";
19
- relpath = '../../';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="../../class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="../../_index.html">Index (E)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../../Outboxer.html" title="Outboxer (module)">Outboxer</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Models.html" title="Outboxer::Models (module)">Models</a></span></span>
41
- &raquo;
42
- <span class="title">Exception</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="../../class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Class: Outboxer::Models::Exception
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
- <dl>
70
- <dt>Inherits:</dt>
71
- <dd>
72
- <span class="inheritName">ActiveRecord::Base</span>
73
-
74
- <ul class="fullTree">
75
- <li>Object</li>
76
-
77
- <li class="next">ActiveRecord::Base</li>
78
-
79
- <li class="next">Outboxer::Models::Exception</li>
80
-
81
- </ul>
82
- <a href="#" class="inheritanceTree">show all</a>
83
-
84
- </dd>
85
- </dl>
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
- <dl>
98
- <dt>Defined in:</dt>
99
- <dd>lib/outboxer/models/exception.rb</dd>
100
- </dl>
101
-
102
- </div>
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
- </div>
115
-
116
- <div id="footer">
117
- Generated on Sat Aug 5 04:37:46 2023 by
118
- <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
- 0.9.34 (ruby-2.7.8).
120
- </div>
121
-
122
- </div>
123
- </body>
124
- </html>
@@ -1,144 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Class: Outboxer::Models::Message
8
-
9
- &mdash; Documentation by YARD 0.9.34
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "Outboxer::Models::Message";
19
- relpath = '../../';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="../../class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="../../_index.html">Index (M)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../../Outboxer.html" title="Outboxer (module)">Outboxer</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Models.html" title="Outboxer::Models (module)">Models</a></span></span>
41
- &raquo;
42
- <span class="title">Message</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="../../class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Class: Outboxer::Models::Message
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
- <dl>
70
- <dt>Inherits:</dt>
71
- <dd>
72
- <span class="inheritName">ActiveRecord::Base</span>
73
-
74
- <ul class="fullTree">
75
- <li>Object</li>
76
-
77
- <li class="next">ActiveRecord::Base</li>
78
-
79
- <li class="next">Outboxer::Models::Message</li>
80
-
81
- </ul>
82
- <a href="#" class="inheritanceTree">show all</a>
83
-
84
- </dd>
85
- </dl>
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
- <dl>
98
- <dt>Defined in:</dt>
99
- <dd>lib/outboxer/models/message.rb</dd>
100
- </dl>
101
-
102
- </div>
103
-
104
-
105
-
106
- <h2>
107
- Constant Summary
108
- <small><a href="#" class="constants_summary_toggle">collapse</a></small>
109
- </h2>
110
-
111
- <dl class="constants">
112
-
113
- <dt id="STATUS-constant" class="">STATUS =
114
-
115
- </dt>
116
- <dd><pre class="code"><span class='lbrace'>{</span>
117
- <span class='label'>unpublished:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>unpublished</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
118
- <span class='label'>publishing:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>publishing</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
119
- <span class='label'>failed:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>failed</span><span class='tstring_end'>&quot;</span></span>
120
- <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
121
-
122
- </dl>
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
- </div>
135
-
136
- <div id="footer">
137
- Generated on Sat Aug 5 04:37:46 2023 by
138
- <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
139
- 0.9.34 (ruby-2.7.8).
140
- </div>
141
-
142
- </div>
143
- </body>
144
- </html>
@@ -1,105 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Module: Outboxer::Models::Outboxable::ClassMethods
8
-
9
- &mdash; Documentation by YARD 0.9.34
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="../../../css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="../../../css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "Outboxer::Models::Outboxable::ClassMethods";
19
- relpath = '../../../';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="../../../class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="../../../_index.html">Index (C)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../../../Outboxer.html" title="Outboxer (module)">Outboxer</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Models.html" title="Outboxer::Models (module)">Models</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Outboxable.html" title="Outboxer::Models::Outboxable (module)">Outboxable</a></span></span>
41
- &raquo;
42
- <span class="title">ClassMethods</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="../../../class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Module: Outboxer::Models::Outboxable::ClassMethods
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- <dl>
80
- <dt>Defined in:</dt>
81
- <dd>lib/outboxer/models/outboxable.rb</dd>
82
- </dl>
83
-
84
- </div>
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
- </div>
96
-
97
- <div id="footer">
98
- Generated on Sat Aug 5 04:37:46 2023 by
99
- <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
100
- 0.9.34 (ruby-2.7.8).
101
- </div>
102
-
103
- </div>
104
- </body>
105
- </html>