Boutons
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/boutons
. To experiment with that code, run bin/console
for an interactive prompt.
TODO: Delete this and the text above, and describe your gem
Installation
Add this line to your application's Gemfile:
gem 'boutons'
And then execute:
$ bundle
Or install it yourself as:
$ gem install boutons
Usage
Add boutons.tml
to your Project (or config subfolder).
It has the following format:
[registry.registry_name] "key" = "value" [services] "name" = [ "registry_name://path" ]
The registry section is optional. Boutons will read this file on demand and checks if a service is listed there. The service-uri will be parsed and Boutons instruct Synapse (AirBnb) to link to this service. Portnumber is choosen randomly at high-port-range (1024+).
The local address can be found with Boutons.name.to_s (or .s).
Example
boutons.tml [registry.zookeeper] "hosts" = ["localhost:2181"] [services] "postgresql" = [ "zookeeper:///nerve/postgresql/services"]
irb require "boutons" puts Boutons.postgresql.s
Live connections
Boutons can also add synapses at runtime.
Boutons.provide "smtp", "zookeeper://zookeeper.mail.company.com:2181/outbound-relay/smtp" puts Boutons.smtp.to_s("%h:%p")
A bit more complex
Boutons.provide "weather", "zookeeper+http://zk.weather.earth:2181/europe#/health"
Will set the type to http and check if the server by GETting /health.
String-Format
the to_s method prints the local uri as default. You may provide some kind of format-string to your needs. The following placeholders will be replaces by it's value:
%P = Procotol (tcp or http) %h = Hostname %i = IP-Address %p = Portnumber
Boutons.postgresql.s("%i:%p") => "127.0.0.1:23412"
Development
After checking out the repo, run bin/setup
to install dependencies. Then, 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
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
- Fork it ( https://github.com/[my-github-username]/boutons/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request