No commit activity in last 3 years
No release in over 3 years
Client for registering an Instructure service via etcd.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
~> 10.0

Runtime

~> 0.3
 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:

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.load

InstructureRegistrar.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'}
end

if 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
end

Then, 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.