lib/odania/service.rb in odania-0.0.4 vs lib/odania/service.rb in odania-0.0.5

- old
+ new

@@ -1,29 +1,26 @@ module Odania class Service < Odania::Consul - def register_service(plugin_name, plugin_instance_name, ip) - puts "Registering service #{plugin_name} as instance #{plugin_instance_name}" - if Diplomat::Service.register consul_service_config(plugin_name, plugin_instance_name, ip) + def register_service(consul_config) + if Diplomat::Service.register consul_config puts 'Service registered' else puts 'Error registering service' end end - private - - def consul_service_config(plugin_name, plugin_instance_name, ip) + def consul_service_config(plugin_name, plugin_instance_name, ip, tags=[], port=80) { 'id' => plugin_instance_name, 'name' => plugin_name, - 'tags' => ['odania-static'], - 'port' => 80, + 'tags' => tags, + 'port' => port, 'token' => plugin_instance_name, 'checks' => [ { 'id' => plugin_name, - 'name' => 'HTTP on port 80', - 'http' => "http://#{ip}:80/health", + 'name' => "HTTP on port #{port}", + 'http' => "http://#{ip}:#{port}/health", 'interval' => '10s', 'timeout' => '1s' } ] }