-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
Scott Hill edited this page Jul 21, 2020
·
4 revisions
Subserver can be used with any ruby app but takes special care to integrate with Rails.
- Add Subserver to your Gemfile:
gem 'subserver'
- Add a Subscriber in
app/subscribers
to process messages asynchronously:
class TestSubscriber
include Subserver::Subscriber
subserver_options subscription: 'your-gcloud-subscription-name'
def perform(message)
# do something with message
message.acknowledge!
end
end
- Add configuration file `config/subserver.yml' to add Google Cloud credentials
---
project_id: 'subserver-test-id'
credentails: 'path/to/credentails.json'
Note: Subserver respects Google's Credential Enviroment variables like PUBSUB_PROJECT and GOOGLE_APPLICATION_CREDENTIALS. If no config is provided the default env varriables will be used. See Google's authentication guide for more info.
- Start subserver from the root of your Rails application so the jobs will be processed:
bundle exec subserver
Plain ruby applications can follow the same setup as the Rails application. Simply put your Subscriber classes in the ./subscribers
directory and your config file in ./config/subserver.yml
.
Next: Configuration