All Projects → mercadolibre → toiler

mercadolibre / toiler

Licence: LGPL-3.0 license
Toiler is a AWS SQS long-polling thread-based message processor.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to toiler

Simpleue
PHP queue worker and consumer - Ready for AWS SQS, Redis, Beanstalkd and others.
Stars: ✭ 124 (+726.67%)
Mutual labels:  workers, sqs
celery-connectors
Want to handle 100,000 messages in 90 seconds? Celery and Kombu are that awesome - Multiple publisher-subscriber demos for processing json or pickled messages from Redis, RabbitMQ or AWS SQS. Includes Kombu message processors using native Producer and Consumer classes as well as ConsumerProducerMixin workers for relay publish-hook or caching
Stars: ✭ 37 (+146.67%)
Mutual labels:  workers, sqs
aws-developer-associate-certificate
Note to pass the AWS Developer Associate Exam
Stars: ✭ 53 (+253.33%)
Mutual labels:  sqs
mq-go
SQS Consumer Server for Go
Stars: ✭ 28 (+86.67%)
Mutual labels:  sqs
jobqueue
Jobqueue manages running and scheduling jobs (think Sidekiq or Resque for Go).
Stars: ✭ 37 (+146.67%)
Mutual labels:  workers
cloudflare-worker-router
A super lightweight router (1.3K) with middleware support and ZERO dependencies for CloudFlare Workers.
Stars: ✭ 144 (+860%)
Mutual labels:  workers
python-task-queue
Asynchronous serverless task queue with timed leasing of tasks. Threaded implementations for SQS and local filesystem.
Stars: ✭ 24 (+60%)
Mutual labels:  sqs
amazon-sns-java-extended-client-lib
This AWS SNS client library allows to publish messages to SNS that exceed the 256 KB message size limit.
Stars: ✭ 23 (+53.33%)
Mutual labels:  sqs
sqsiphon
No description or website provided.
Stars: ✭ 19 (+26.67%)
Mutual labels:  sqs
terraform-aws-eks-workers
Terraform module to provision an AWS AutoScaling Group, IAM Role, and Security Group for EKS Workers
Stars: ✭ 82 (+446.67%)
Mutual labels:  workers
django-eb-sqs-worker
Django Background Tasks for Amazon Elastic Beanstalk
Stars: ✭ 27 (+80%)
Mutual labels:  sqs
Bitpoll
A web application for scheduling meetings and general polling.
Stars: ✭ 182 (+1113.33%)
Mutual labels:  polling
taskinator
A simple orchestration library for running complex processes or workflows in Ruby
Stars: ✭ 25 (+66.67%)
Mutual labels:  workers
ontopic
Display SNS messages on your terminal
Stars: ✭ 20 (+33.33%)
Mutual labels:  sqs
worker-template-postgres
Reference demo and modified PostgreSQL driver to connect Cloudflare Workers to a relational database.
Stars: ✭ 75 (+400%)
Mutual labels:  workers
handbook
We're a small high-trust livelihood pod doing tech consulting within Enspiral.
Stars: ✭ 35 (+133.33%)
Mutual labels:  workers
qlicker
Open Source Clicker
Stars: ✭ 23 (+53.33%)
Mutual labels:  polling
PyRSMQ
Python Implementation of Redis Simple Message Queue Algorithm
Stars: ✭ 35 (+133.33%)
Mutual labels:  sqs
university
proof of concept to detect website visits from a university
Stars: ✭ 17 (+13.33%)
Mutual labels:  workers
appium-device-farm
This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
Stars: ✭ 124 (+726.67%)
Mutual labels:  polling

Toiler

Toiler is a AWS SQS long-polling thread-based message processor. It's based on shoryuken but takes a different approach at loadbalancing and uses long-polling.

Features

Concurrency

Toiler allows to specify the amount of processors (threads) that should be spawned for each queue. Instead of shoryuken's loadbalancing approach, Toiler delegates this work to the kernel scheduling threads.

Long-Polling

A Fetcher thread is spawned for each queue. Fetchers are resposible for polling SQS/PubSub and retreiving messages. They are optimised to not bring more messages than the amount of processors avaiable for such queue. By long-polling fetchers wait for a configurable amount of time for messages to become available on a single request, this prevents unneccesarilly requesting messages when there are none.

Message Parsing

Workers can configure a parser Class or Proc to parse a message body before being processed.

Deadline Extension

Toiler has the ability to automatically extend the ack deadline of and messages to prevent the message from re-entering the queue if processing of such message is taking longer than the queue's ack deadline or visibility timeout.

Instalation

Add this line to your application's Gemfile:

gem 'toiler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install toiler

Usage

Worker class

class MyWorker
  include Toiler::Worker

  toiler_options queue: 'default', concurrency: 5, auto_delete: true
  toiler_options parser: :json

  # toiler_options parser: ->(sqs_msg){ REXML::Document.new(sqs_msg.body) }
  # toiler_options parser: MultiJson
  # toiler_options deadline_extension: true
  # toiler_options batch: true
  # toiler_options queue: 'subscription', concurrency: 5, auto_delete: true, provider: :gcp

  #Example connection client that should be shared across all instances of MyWorker
  @@client = ConnectionClient.new
    
  def initialize
    @last_message = nil
  end

  def perform(sqs_msg, body)
    #Workers are thread safe, yay!
    #Each worker instance is assured to be processing only one message at a time
    @last_message = sqs_msg 
    puts body
  end
end

Configuration

aws:
  access_key_id:     ...             # or <%= ENV['AWS_ACCESS_KEY_ID'] %>
  secret_access_key: ...             # or <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
  region:            us-east-1       # or <%= ENV['AWS_REGION'] %>
gcp:
  project_id:  my-project            # or <%= ENV['GCP_PROJECT'] %>
  credentials: /path/to/keyfile.json # or <%= ENV['GCP_CREDENTIALS'] %>
wait: 20                             # The time in seconds to wait for messages during long-polling

Rails Integration

You can tell Toiler to load your Rails application by passing the -R or --rails flag to the "toiler" command.

If you load Rails, and assuming your workers are located in the app/workers directory, they will be auto-loaded. This means you don't need to require them explicitly with -r.

Start Toiler

bundle exec toiler -r worker.rb -C toiler.yml

Other options:

toiler --help

    -d, --daemon                     Daemonize process
    -r, --require [PATH|DIR]         Location of the worker
    -q, --queue QUEUE1,QUEUE2,...    Queues to process
    -C, --config PATH                Path to YAML config file
    -R, --rails                      Load Rails
    -L, --logfile PATH               Path to writable logfile
    -P, --pidfile PATH               Path to pidfile
    -v, --verbose                    Print more verbose output
    -h, --help                       Show help

Credits

Sebastian Schepens for the creation of the proyect. But much of the credit goes to Pablo Cantero, creator of Shoryuken, and everybody who contributed to it.

Contributing

  1. Fork it ( https://github.com/sschepens/toiler/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].