Module: Sidekiq::AWS::SQS::Worker
- Includes:
- Helpers
- Defined in:
- lib/sidekiq/aws/sqs/worker.rb
Instance Method Summary
collapse
Methods included from Helpers
#sqs_options_struct, #validate_sqs_options!
Instance Method Details
#pause_polling ⇒ Object
50
51
52
53
54
|
# File 'lib/sidekiq/aws/sqs/worker.rb', line 50
def pause_polling
Sidekiq::AWS::SQS.logger.debug("Pausing polling for #{self}")
@poller&.pause
end
|
#paused? ⇒ Boolean
66
67
68
|
# File 'lib/sidekiq/aws/sqs/worker.rb', line 66
def paused?
@poller&.paused? || false
end
|
#poller ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/sidekiq/aws/sqs/worker.rb', line 12
def poller
validate_sqs_options!
@poller ||= SafePoller.poll do
sqs_options_struct
.client
.receive_message(queue_url: sqs_options_struct.queue_url,
wait_time_seconds: sqs_options_struct.wait_time_seconds)
.messages
.each do |message|
Sidekiq::AWS::SQS.logger.debug("Received message #{message.message_id} from #{sqs_options_struct.queue_url} for #{self}")
perform_async(message.to_json)
Sidekiq::AWS::SQS.logger.debug("Enqueued message #{message.message_id} from #{sqs_options_struct.queue_url} for #{self}")
next unless need_to_destroy_on_received?
sqs_options_struct.client.delete_message(queue_url: sqs_options_struct.queue_url,
receipt_handle: message.receipt_handle)
Sidekiq::AWS::SQS.logger.debug("Deleted message #{message.message_id} from #{sqs_options_struct.queue_url} for #{self}")
end
end
end
|
#resume_polling ⇒ Object
56
57
58
59
60
|
# File 'lib/sidekiq/aws/sqs/worker.rb', line 56
def resume_polling
Sidekiq::AWS::SQS.logger.debug("Resuming polling for #{self}")
@poller&.resume
end
|
#running? ⇒ Boolean
62
63
64
|
# File 'lib/sidekiq/aws/sqs/worker.rb', line 62
def running?
@poller&.running? || false
end
|
#sqs_options(**options) ⇒ Object
70
71
72
|
# File 'lib/sidekiq/aws/sqs/worker.rb', line 70
def sqs_options(**options)
@sqs_options = options || {}
end
|
#start_polling ⇒ Object
38
39
40
41
42
|
# File 'lib/sidekiq/aws/sqs/worker.rb', line 38
def start_polling
Sidekiq::AWS::SQS.logger.debug("Starting polling for #{self}")
@poller&.start || poller
end
|
#stop_polling ⇒ Object
44
45
46
47
48
|
# File 'lib/sidekiq/aws/sqs/worker.rb', line 44
def stop_polling
Sidekiq::AWS::SQS.logger.debug("Stopping polling for #{self}")
@poller&.stop
end
|