This repository has been archived by the owner on Apr 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
63 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# frozen_string_literal: true | ||
module PipefyMessage | ||
module Providers | ||
module Errors | ||
class ResourceError < StandardError | ||
def initialize(msg="ResourceError") | ||
super | ||
end | ||
end | ||
module Providers | ||
module Errors | ||
class ResourceError < RuntimeError | ||
def initialize(msg = "ResourceError") | ||
super | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'singleton' | ||
require "singleton" | ||
|
||
module PipefyMessage | ||
# ClassMethods | ||
module Worker | ||
def self.included(base) | ||
base.extend(ClassMethods) | ||
end | ||
|
||
# ClassMethods | ||
module ClassMethods | ||
def pipefymessage_options(opts = {}) | ||
module ClassMethods | ||
def pipefymessage_options(opts = {}) | ||
options_hash = PipefyMessage.default_worker_options.merge(opts.transform_keys(&:to_s)) | ||
options_hash.each do |k, v| | ||
singleton_class.class_eval { attr_accessor k } | ||
send("#{k}=", v) | ||
end | ||
end | ||
|
||
def perform_async() | ||
begin | ||
obj = self.new | ||
build_instance_broker.poller do |message| | ||
obj.perform(message) | ||
end | ||
rescue Exception => exception | ||
# TODO: Implement retry | ||
raise exception | ||
|
||
def perform_async | ||
obj = new | ||
build_instance_broker.poller do |message| | ||
obj.perform(message) | ||
end | ||
rescue Exception => e | ||
# TODO: Implement retry | ||
raise e | ||
end | ||
end | ||
|
||
def build_instance_broker() | ||
map = {"aws" => "PipefyMessage::Providers::AwsBroker"} | ||
require_relative "providers/#{self.broker}_broker" | ||
|
||
map[self.broker].constantize.new(self.queue) | ||
end | ||
def build_instance_broker | ||
map = { "aws" => "PipefyMessage::Providers::AwsBroker" } | ||
require_relative "providers/#{broker}_broker" | ||
|
||
map[broker].constantize.new(queue) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters