Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/instructure/instructure_registrar
https://github.com/instructure/instructure_registrar
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/instructure/instructure_registrar
- Owner: instructure
- Created: 2015-08-28T19:23:01.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-05T20:50:14.000Z (about 9 years ago)
- Last Synced: 2024-04-14T20:25:53.841Z (7 months ago)
- Language: Ruby
- Size: 152 KB
- Stars: 0
- Watchers: 17
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# InstructureRegistrar
InstructureRegistrar is a Ruby library for registering and retrieving service
information from a central etcd service registry.## Installation
Add this line to your application's Gemfile:
```ruby
gem 'instructure_registrar'
```And then execute:
$ bundle
## Usage
Make sure that the following environment variables are set with the appropriate
information for your local etcd instance:REGISTRY_HOST
REGISTRY_PORT### Integrating with a service
In your service's project folder, create a configuration file with the following contents:
#/config/initializers/instructure_registrar.rb
require 'instructure_registrar'
require 'dotenv'
Dotenv.loadInstructureRegistrar.configure do |config|
config.registry_host = ENV['REGISTRY_HOST']# || "http://instructure-etcd.docker"
config.registry_port = ENV['REGISTRY_PORT']# || 12379
config.service_name = "sample_service_3"
config.service_config = {
host: "http://someservice.docker",
token: 'foo',
option: 'bar'}
endif ENV['RAILS_ENV'] == "development"
InstructureRegistrar.register
at_exit { InstructureRegistrar.unregister }
end### Looking up a service
Note that your client application will need a config file similar to that in the section above, but
unless you plan on registering your app as a service your config file will be simpler:#/config/initializers/instructure_registrar.rb
require 'dotenv'
Dotenv.load
require 'instructure_registrar'InstructureRegistrar.configure do |config|
config.registry_host = ENV.fetch('REGISTRY_HOST') || "http://instructure-etcd.docker"
config.registry_port = ENV.fetch("REGISTRY_PORT") || 12379
endThen, to fetch connection information for a given service:
require 'instructure_registrar'
@some_service_url = InstructureRegistrar.get_service('some_service_name')This will return all keys and values associated with the service.