Project

pubilion

0.0
The project is in a healthy, maintained state
ActiveJob Backend for Google Cloud Pub/Sub
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Pubilion

Pubilion is a Ruby gem that provides a simple way to use ActiveJob with Cloud Pub/Sub.

Installation

Add this line to your application's Gemfile:

gem 'pubilion'

And execute command:

bundle install

Usage

Note

This gem is built to be used with rails. There is currently no usage in Plain Ruby.

Configuration

  1. Generate initializer file.
rails generate pubilion:install
  1. Specify settings in the initializer file. See your config/initializers/pubilion.rb for details.

Message Publish

  1. Set queue adapter to pub_sub.
# config/application.rb
config.active_job.queue_adapter = :pub_sub

or

# app/jobs/application_job.rb (or any other job file)
class ApplicationJob < ActiveJob::Base
  self.queue_adapter = :pub_sub
end
  1. Create a job class.
# app/jobs/hello_job.rb
class HelloJob < ApplicationJob
  # `queue_as` is recognized as a Topic name.
  queue_as :topic_name

  def perform(*args)
    puts "Hello, World!"
  end
end
  1. Call perform_later.
HelloJob.perform_later

Message Subscribe

Note

Currently, the worker is support only single subscription. If you want to use multiple subscriptions, you need to create worker per subscription.

  1. Run the worker.
bundle exec rake pubilion:worker:start

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/LruLab/pubilion.

License

The gem is available as open source under the terms of the MIT License.