Module: Shoryuken

Defined in:
lib/shoryuken.rb,
lib/shoryuken/cli.rb,
lib/shoryuken/util.rb,
lib/shoryuken/topic.rb,
lib/shoryuken/queue.rb,
lib/shoryuken/client.rb,
lib/shoryuken/worker.rb,
lib/shoryuken/manager.rb,
lib/shoryuken/fetcher.rb,
lib/shoryuken/message.rb,
lib/shoryuken/version.rb,
lib/shoryuken/logging.rb,
lib/shoryuken/sns_arn.rb,
lib/shoryuken/launcher.rb,
lib/shoryuken/processor.rb,
lib/shoryuken/worker_registry.rb,
lib/shoryuken/middleware/chain.rb,
lib/shoryuken/environment_loader.rb,
lib/shoryuken/default_worker_registry.rb,
lib/shoryuken/middleware/server/timing.rb,
lib/shoryuken/middleware/server/auto_delete.rb,
lib/shoryuken/middleware/server/active_record.rb,
lib/shoryuken/middleware/server/exponential_backoff_retry.rb

Defined Under Namespace

Modules: Logging, Middleware, Util, Worker Classes: CLI, Client, DefaultWorkerRegistry, EnvironmentLoader, Fetcher, Launcher, Manager, Message, Processor, Queue, Shutdown, SnsArn, Topic, WorkerRegistry

Constant Summary collapse

DEFAULTS =
{
  concurrency: 25,
  queues: [],
  aws: {},
  delay: 0,
  timeout: 8,
  lifecycle_events: {
    startup: [],
    quiet: [],
    shutdown: [],
  }
}
VERSION =
'2.0.2'
@@queues =
[]
@@worker_registry =
DefaultWorkerRegistry.new
@@active_job_queue_name_prefixing =
false

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.aws_initialization_callbackObject (readonly)

Returns the value of attribute aws_initialization_callback


134
135
136
# File 'lib/shoryuken.rb', line 134

def aws_initialization_callback
  @aws_initialization_callback
end

.start_callbackObject (readonly)

Returns the value of attribute start_callback


134
135
136
# File 'lib/shoryuken.rb', line 134

def start_callback
  @start_callback
end

.stop_callbackObject (readonly)

Returns the value of attribute stop_callback


134
135
136
# File 'lib/shoryuken.rb', line 134

def stop_callback
  @stop_callback
end

Class Method Details

.active_job_queue_name_prefixingObject


66
67
68
# File 'lib/shoryuken.rb', line 66

def active_job_queue_name_prefixing
  @@active_job_queue_name_prefixing
end

.active_job_queue_name_prefixing=(prefixing) ⇒ Object


70
71
72
# File 'lib/shoryuken.rb', line 70

def active_job_queue_name_prefixing=(prefixing)
  @@active_job_queue_name_prefixing = prefixing
end

.client_middleware {|@client_chain| ... } ⇒ Object

Yields:

  • (@client_chain)

88
89
90
91
92
# File 'lib/shoryuken.rb', line 88

def client_middleware
  @client_chain ||= default_client_middleware
  yield @client_chain if block_given?
  @client_chain
end

.configure_client {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Shoryuken)

    the object that the method was called on


84
85
86
# File 'lib/shoryuken.rb', line 84

def configure_client
  yield self
end

.configure_server {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Shoryuken)

    the object that the method was called on


74
75
76
# File 'lib/shoryuken.rb', line 74

def configure_server
  yield self if server?
end

.default_worker_optionsObject


94
95
96
97
98
99
100
101
102
# File 'lib/shoryuken.rb', line 94

def default_worker_options
  @@default_worker_options ||= {
    'queue'                   => 'default',
    'delete'                  => false,
    'auto_delete'             => false,
    'auto_visibility_timeout' => false,
    'retry_intervals'         => nil,
    'batch'                   => false }
end

.default_worker_options=(options) ⇒ Object


104
105
106
# File 'lib/shoryuken.rb', line 104

def default_worker_options=(options)
  @@default_worker_options = options
end

.loggerObject


50
51
52
# File 'lib/shoryuken.rb', line 50

def logger
  Shoryuken::Logging.logger
end

.on(event, &block) ⇒ Object

Register a block to run at a point in the Shoryuken lifecycle. :startup, :quiet or :shutdown are valid events.

Shoryuken.configure_server do |config|
  config.on(:shutdown) do
    puts "Goodbye cruel world!"
  end
end

Raises:

  • (ArgumentError)

128
129
130
131
132
# File 'lib/shoryuken.rb', line 128

def on(event, &block)
  raise ArgumentError, "Symbols only please: #{event}" unless event.is_a?(Symbol)
  raise ArgumentError, "Invalid event name: #{event}" unless options[:lifecycle_events].key?(event)
  options[:lifecycle_events][event] << block
end

.on_aws_initialization(&block) ⇒ Object


108
109
110
# File 'lib/shoryuken.rb', line 108

def on_aws_initialization(&block)
  @aws_initialization_callback = block
end

.on_start(&block) ⇒ Object


112
113
114
# File 'lib/shoryuken.rb', line 112

def on_start(&block)
  @start_callback = block
end

.on_stop(&block) ⇒ Object


116
117
118
# File 'lib/shoryuken.rb', line 116

def on_stop(&block)
  @stop_callback = block
end

.optionsObject


42
43
44
# File 'lib/shoryuken.rb', line 42

def options
  @options ||= DEFAULTS.dup
end

.queuesObject


46
47
48
# File 'lib/shoryuken.rb', line 46

def queues
  @@queues
end

.register_worker(*args) ⇒ Object


54
55
56
# File 'lib/shoryuken.rb', line 54

def register_worker(*args)
  worker_registry.register_worker(*args)
end

.server_middleware {|@server_chain| ... } ⇒ Object

Yields:

  • (@server_chain)

78
79
80
81
82
# File 'lib/shoryuken.rb', line 78

def server_middleware
  @server_chain ||= default_server_middleware
  yield @server_chain if block_given?
  @server_chain
end

.worker_registryObject


62
63
64
# File 'lib/shoryuken.rb', line 62

def worker_registry
  @@worker_registry
end

.worker_registry=(worker_registry) ⇒ Object


58
59
60
# File 'lib/shoryuken.rb', line 58

def worker_registry=(worker_registry)
  @@worker_registry = worker_registry
end