Sidekiq Worker Strategies

Description

This project contains various types of strategies that handle communication between the accounts-cc and worker-cc.

Polling strategy

This strategy is a simple algorithm that basically follow these simple steps:

  1. Load account and transaction information.
  2. Establish connection with request and reply tubes.
  3. Validate if the account is in a valid state.
  4. Validate if there are available watchers (workers ready to process the job).
  5. Validate if the provider is available (pending implementation).
  6. Search for data in reply tube in case that previously a worker has processed the job.
  7. Search for an existing request job in buried state and put it back in the ready queue.
  8. Put a new request job if steps 6 and 7 are not meet and start polling on request tube to obatin a reply job.
  9. Process the reply job.

This strategy needs to be included on accounts-cc to see in the real world how it works, the only necessary files are:

  1. lib/account_handler.rb
  2. lib/beanstalk_handler.rb
  3. polling_strategy.rb

NOTES:

  • models.rb and models/* are like mocks used to run this strategy stand-alone.
  • lines commented with double '#' indicates that are lines that should be uncommented in accounts-cc
  • lines that have 'TODO: remove' indicates that are lines that should be commented or deleted on accounts-cc

SPECS

Pending