Sha256: 0b91c10b3a29fa822ce69fa1747ea1034e9ea66b335b24524cfcfe1420285f6b

Contents?: true

Size: 633 Bytes

Versions: 4

Compression:

Stored size: 633 Bytes

Contents

# Encoding: utf-8

require 'timeout'

module Etcd
  module Mod
    # Implemetn Etcd's Leader module
    module Leader
      def mod_leader_endpoint
        '/mod/v2/leader'
      end

      def set_leader(key, value, ttl)
        path = mod_leader_endpoint + "#{key}?ttl=#{ttl}"
        api_execute(path, :put, params: { name: value }).body
      end

      def get_leader(key)
        api_execute(mod_leader_endpoint + key, :get).body
      end

      def delete_leader(key, value)
        path = mod_leader_endpoint + key + '?' + URI.encode_www_form(name: value)
        api_execute(path, :delete).body
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
etcd-0.2.3 lib/etcd/mod/leader.rb
etcd-0.2.2 lib/etcd/mod/leader.rb
etcd-0.2.1 lib/etcd/mod/leader.rb
etcd-0.2.0.beta.1 lib/etcd/mod/leader.rb