
Security News
Python Adopts Standard Lock File Format for Reproducible Installs
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
Relax is a Ruby client/consumer library for relax – which is a multitenant message broker for Slack.
Add this line to your application's Gemfile:
gem 'relax-rb', require: 'relax'
And then execute:
$ bundle
Relax is meant to be used in conjunction with a web app such as Rails. There are two primary functions that this library lets you perform:
Start Slack bots on Relax
Listen for events generated by Relax.
The Relax Ruby client requires a few environment variables to be set up (these same environment variables are also used to set up the relax message broker).
RELAX_BOTS_KEY
: This can be any string value and is used to store state
about all Slack clients currently controlled by Relax in Redis. (Used by
Relax::Bot
)
RELAX_BOTS_PUBSUB
: This can be any string value and is used to notify
Relax brokers that a new Slack bot has been started. (Used by
Relax::Bot
)
RELAX_EVENTS_QUEUE
: This can be any string value and is used by Relax
brokers to send events to the client. (Used by Relax::EventListener
)
For a full list of events that are sent from Relax brokers, visit the Relax Github page.
To start a bot, or update a bot with a new token, call
Relax::Bot.start!(team_uid, token)
where team_uid
is the UID of the
team (generated by the Slack API) and token
is the API token for the
bot (again generated by the Slack API).
If a token is invalid or a bot connection is unsuccesful, you will
receive a disable_bot
event.
Events are queued in Redis by Relax brokers in the REDIS_EVENTS_QUEUE
key and Relax::EventListener.listen!
listens for events and invokes
the callback that is set by Relax::EventListener.callback=
.
The recommended way to set the callback method for events in Rails is an
initializer, for e.g. in a file config/initializers/relax.rb
:
callback = Proc.new do |event|
Rails.logger.info "received event: #{event}"
# handle event
end
Relax::EventListener.callback = callback
The callback can also be a class (or instance) method, in which case you should do something like this:
class RelaxEventHandler
def self.handle_event(event)
Rails.logger.info "received event: #{event}"
# handle event
end
end
Relax::EventListener.callback = RelaxEventHandler.method(:handle_event)
The recommended way to start the listener in a Rails app is to use Foreman. In your Procfile, create an entry like this:
relax: bundle exec rake relax:listen_for_events
And this will invoke Relax::EventListener.listen!
as part your of your
Rails application.
This process can be scaled indepedently from the rest of your web application, and so the more events you get, the more "relax" listener processes you can have.
An Event is an instance of the
[Relax::Event](https://github.com/zerobotlabs/relax-rb/blob/master/lib/relax/event.rb)
class.
Read more about the different types of events generated by Relax here
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 tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/zerobotlabs/relax-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that relax-rb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
Security News
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.