<commit_before>#
# Services Module
#
#  Uses etcd to manage state of Service Endpoint & Members
#
module Services
  require_relative 'services/version'
  require_relative 'services/connection'
  require_relative 'services/entity'
  require_relative 'services/service'
  require_relative 'services/endpoint'
  require_relative 'services/member'

  # this will  change or be slurped up from a config/node attrib
  KEY = '/services'

  #
  # Share a connection between all classess using this module
  #
  class << self
    attr_accessor :connection, :run_context

    def get(*args)
      Chef::Log.debug "connection.get args #{args}" unless run_context.nil?
      @connection.get(*args)
    end

    def set(*args)
      Chef::Log.debug "connection.set args #{args}" unless run_context.nil?
      @connection.set(*args)
    end

    # return a list of all services
    def all
      services = []
      get(KEY).each do |s|
        name = File.basename s.key
        puts "loading #{name}"
        services << Services::Service.new(name)
      end
      services
    end

    # return all services a node is subscribed to<commit_msg>@connection was unneeded<commit_after>#
# Services Module
#
#  Uses etcd to manage state of Service Endpoint & Members
#
module Services
  require_relative 'services/version'
  require_relative 'services/connection'
  require_relative 'services/entity'
  require_relative 'services/service'
  require_relative 'services/endpoint'
  require_relative 'services/member'

  # this will  change or be slurped up from a config/node attrib
  KEY = '/services'

  #
  # Share a connection between all classess using this module
  #
  class << self
    attr_accessor :connection, :run_context

    def get(*args)
      Chef::Log.debug "connection.get args #{args}" unless run_context.nil?
      connection.get(*args)
    end

    def set(*args)
      Chef::Log.debug "connection.set args #{args}" unless run_context.nil?
      connection.set(*args)
    end

    # return a list of all services
    def all
      services = []
      get(KEY).each do |s|
        name = File.basename s.key
        puts "loading #{name}"
        services << Services::Service.new(name)
      end
      services
    end

    # return all services a node is subscribed to
{'fraction_non_alphanumeric': 0.09106907171139464, 'fraction_numerical': 0.0, 'mean_word_length': 3.039076376554174, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1625842', 'n_tokens_mistral': 665, 'n_tokens_neox': 654, 'n_words': 209}