Module: Shoryuken
- Defined in:
- lib/shoryuken.rb,
lib/shoryuken/cli.rb,
lib/shoryuken/util.rb,
lib/shoryuken/queue.rb,
lib/shoryuken/topic.rb,
lib/shoryuken/client.rb,
lib/shoryuken/worker.rb,
lib/shoryuken/fetcher.rb,
lib/shoryuken/logging.rb,
lib/shoryuken/manager.rb,
lib/shoryuken/message.rb,
lib/shoryuken/sns_arn.rb,
lib/shoryuken/version.rb,
lib/shoryuken/core_ext.rb,
lib/shoryuken/launcher.rb,
lib/shoryuken/processor.rb,
lib/shoryuken/aws_config.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/auto_extend_visibility.rb,
lib/shoryuken/middleware/server/exponential_backoff_retry.rb
Defined Under Namespace
Modules: HashExt, Logging, Middleware, StringExt, Util, Worker
Classes: AwsConfig, 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.1.1'
- @@queues =
[]
- @@worker_registry =
DefaultWorkerRegistry.new
- @@active_job_queue_name_prefixing =
false
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.aws_initialization_callback ⇒ Object
Returns the value of attribute aws_initialization_callback.
152
153
154
|
# File 'lib/shoryuken.rb', line 152
def aws_initialization_callback
@aws_initialization_callback
end
|
.start_callback ⇒ Object
Returns the value of attribute start_callback.
152
153
154
|
# File 'lib/shoryuken.rb', line 152
def start_callback
@start_callback
end
|
.stop_callback ⇒ Object
Returns the value of attribute stop_callback.
152
153
154
|
# File 'lib/shoryuken.rb', line 152
def stop_callback
@stop_callback
end
|
Class Method Details
.active_job_queue_name_prefixing ⇒ Object
68
69
70
|
# File 'lib/shoryuken.rb', line 68
def active_job_queue_name_prefixing
@@active_job_queue_name_prefixing
end
|
.active_job_queue_name_prefixing=(prefixing) ⇒ Object
72
73
74
|
# File 'lib/shoryuken.rb', line 72
def active_job_queue_name_prefixing=(prefixing)
@@active_job_queue_name_prefixing = prefixing
end
|
.client_middleware {|@client_chain| ... } ⇒ Object
102
103
104
105
106
|
# File 'lib/shoryuken.rb', line 102
def client_middleware
@client_chain ||= default_client_middleware
yield @client_chain if block_given?
@client_chain
end
|
Configuration for Shoryuken client, use like:
Shoryuken.configure_client do |config|
config.aws = { :sqs_endpoint => '...', :access_key_id: '...', :secret_access_key: '...', region: '...' }
end
98
99
100
|
# File 'lib/shoryuken.rb', line 98
def configure_client
yield self unless server?
end
|
Configuration for Shoryuken server, use like:
Shoryuken.configure_server do |config|
config.aws = { :sqs_endpoint => '...', :access_key_id: '...', :secret_access_key: '...', region: '...' }
end
82
83
84
|
# File 'lib/shoryuken.rb', line 82
def configure_server
yield self if server?
end
|
.default_worker_options ⇒ Object
108
109
110
111
112
113
114
115
116
|
# File 'lib/shoryuken.rb', line 108
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
118
119
120
|
# File 'lib/shoryuken.rb', line 118
def default_worker_options=(options)
@@default_worker_options = options
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
146
147
148
149
150
|
# File 'lib/shoryuken.rb', line 146
def on(event, &block)
fail ArgumentError, "Symbols only please: #{event}" unless event.is_a?(Symbol)
fail ArgumentError, "Invalid event name: #{event}" unless options[:lifecycle_events].key?(event)
options[:lifecycle_events][event] << block
end
|
.on_aws_initialization(&block) ⇒ Object
122
123
124
|
# File 'lib/shoryuken.rb', line 122
def on_aws_initialization(&block)
@aws_initialization_callback = block
end
|
.on_start(&block) ⇒ Object
126
127
128
|
# File 'lib/shoryuken.rb', line 126
def on_start(&block)
@start_callback = block
end
|
.on_stop(&block) ⇒ Object
130
131
132
|
# File 'lib/shoryuken.rb', line 130
def on_stop(&block)
@stop_callback = block
end
|
.options ⇒ Object
44
45
46
|
# File 'lib/shoryuken.rb', line 44
def options
@options ||= DEFAULTS.dup
end
|
.queues ⇒ Object
48
49
50
|
# File 'lib/shoryuken.rb', line 48
def queues
@@queues
end
|
.register_worker(*args) ⇒ Object
56
57
58
|
# File 'lib/shoryuken.rb', line 56
def register_worker(*args)
worker_registry.register_worker(*args)
end
|
.server_middleware {|@server_chain| ... } ⇒ Object
86
87
88
89
90
|
# File 'lib/shoryuken.rb', line 86
def server_middleware
@server_chain ||= default_server_middleware
yield @server_chain if block_given?
@server_chain
end
|
.worker_registry ⇒ Object
64
65
66
|
# File 'lib/shoryuken.rb', line 64
def worker_registry
@@worker_registry
end
|
.worker_registry=(worker_registry) ⇒ Object
60
61
62
|
# File 'lib/shoryuken.rb', line 60
def worker_registry=(worker_registry)
@@worker_registry = worker_registry
end
|