outboxer 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 020ece7302e6b90b26324561e37c0527e4158df1c5587d651fbe61a83703cbfe
4
- data.tar.gz: 745ae13e8adffe84a0b9656caba022ebece21d3ca03b28cc809044ff56bbf461
3
+ metadata.gz: f881a119f2c2123b34c0a7153590c2eab9907b44045e64d51e16ce914e731bb6
4
+ data.tar.gz: d30a09f38f02fea3bce19895922d294e40dfb25555e1fcf4fd06b33560d1e2db
5
5
  SHA512:
6
- metadata.gz: cd880961d6f47f62b0a728684a11af3ffd47390f0620ea0fc8869903fdc35de6fd470c6538a2b52c009902134c3065e27fa262fc8df495ef3db0b0ea93e5829b
7
- data.tar.gz: 59836e830ccc65e075dad400d56be7c6db9b36584522091f68c9a0983a07ff5bdc392679b231f1442f40e830919bd552d9d2d4f843db10d852405b536c330673
6
+ metadata.gz: df0a95d0f24b7ff85038711be1acd4aec4dc5760accb390fb40fdf07342d911b5b07373c4eacbc2e05e25a7a89137ef26c20e201b556c6e07973469806eddaff
7
+ data.tar.gz: 1d329faae4668703b51cd5becdce8215e4251e1217d9c8311795ab602d71e140511b79874908963a947c24939025bd2dbcd8af0497aa985d9478f7919d7602d7
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Outboxer
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/outboxer.svg)](https://badge.fury.io/rb/outboxer)
4
+ ![Ruby](https://github.com/fast-programmer/outboxer/actions/workflows/master.yml/badge.svg)
5
+
3
6
  ## Background
4
7
 
5
8
  Typically in event driven Ruby on Rails applications:
@@ -50,12 +53,11 @@ end
50
53
  #### 2. Update the generated bin/publish block e.g.
51
54
 
52
55
  ```ruby
53
- Outboxer::Publisher.publish do |args|
54
- logger = args.logger
55
- message = args.message
56
-
56
+ Outboxer::Publisher.publish do |message:, logger:|
57
57
  logger.info("[#{message.id}] publishing")
58
+
58
59
  HardJob.perform_async({ "message_id" => message.id })
60
+
59
61
  logger.info("[#{message.id}] published")
60
62
  end
61
63
  ```
@@ -85,11 +87,13 @@ To see all the parts working together in a single place, check out the [publishe
85
87
 
86
88
  ## Motivation
87
89
 
88
- Outboxer was created with 4 key benefits in mind:
90
+ Outboxer was created to help high growth SAAS companies transition to event driven architecture quickly.
91
+
92
+ Specifically this means:
89
93
 
90
- 1. speed of integration into existing Ruby on Rails applications (< 1 hour)
91
- 2. comprehensive documentation that is easy to understand
92
- 3. high reliability in production environments (100% code coverage)
94
+ 1. fast integration into existing Ruby on Rails applications (< 1 hour)
95
+ 2. comprehensive documentation
96
+ 3. high reliability in production environments
93
97
  4. forever free to use in commerical applications (MIT licence)
94
98
 
95
99
  ## Contributing
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- # require "bundler/gem_tasks"
2
- # require "bundler/setup"
3
1
  require "rspec/core/rake_task"
4
2
 
5
3
  RSpec::Core::RakeTask.new(:spec)
@@ -7,19 +7,36 @@ module Outboxer
7
7
  @publishing = false
8
8
  @logger = Logger.new($stdout)
9
9
 
10
- Args = Struct.new(:message, :logger)
11
-
12
- # This method initiates the publishing process. It dequeues the messages one by one
13
- # and yields to a block that should contain the publishing logic.
10
+ # Publishes messages from the Outboxer queue.
11
+ #
12
+ # This method will continue to publish messages from the queue as long
13
+ # as @publishing is set to true. It uses an ActiveRecord connection to
14
+ # handle database interactions.
15
+ #
16
+ # @param poll [Integer] the interval (in seconds) at which the method
17
+ # should poll the database for new messages.
18
+ # @param backoff [Proc] a callable object that defines how to increase the
19
+ # backoff time when an error occurs. It should accept the current backoff
20
+ # time as a parameter and return the new backoff time.
21
+ #
22
+ # @yield [Hash] once a message is dequeued, the method yields a hash to
23
+ # the given block. The hash contains the :message (the dequeued message)
24
+ # and :logger (the logger object).
25
+ #
26
+ # @yieldparam message [Message] the dequeued message from the Outboxer queue.
27
+ # @yieldparam logger [Logger] the logger instance to log any information or errors.
14
28
  #
15
- # @param [Integer] poll
16
- # Sleep time in seconds between polling the queue when it's empty.
29
+ # @raise [StandardError] if an error occurs during the yield, it is rescued,
30
+ # logged, and then the failed method is invoked to handle the error. The
31
+ # method then moves on to the next message in the queue.
17
32
  #
18
- # @param [Proc] backoff
19
- # A Proc that takes the current backoff time and returns the new backoff time.
33
+ # @return [void] This method does not have a meaningful return value.
20
34
  #
21
- # @yieldparam [Args] args
22
- # An Args object containing the message to publish and a logger.
35
+ # @example Basic usage
36
+ # Outboxer::Publisher.publish(poll: 1) do |hash|
37
+ # puts hash[:message]
38
+ # puts hash[:logger]
39
+ # end
23
40
  def publish(poll: 1, backoff: ->(current_backoff) { [current_backoff * 2, 5 * 60].min })
24
41
  @publishing = true
25
42
 
@@ -34,7 +51,7 @@ module Outboxer
34
51
  end
35
52
 
36
53
  begin
37
- yield Args.new(outboxer_message.message, @logger)
54
+ yield message: outboxer_message.message, logger: @logger
38
55
  rescue StandardError => exception
39
56
  failed(
40
57
  outboxer_message: outboxer_message,
@@ -1,3 +1,3 @@
1
1
  module Outboxer
2
- VERSION = "0.1.10".freeze
2
+ VERSION = "0.1.11".freeze
3
3
  end
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.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Mikulasev