<commit_before>local _M = {
  _VERSION = "1.7.0"
}

local HEALTHCHECK = ngx.shared.healthcheck

local function set_peer(upstream, peer, fun)
  if not upstream or not peer then
    ngx.status = ngx.HTTP_BAD_REQUEST
    ngx.say("upstream and peer arguments required")
    ngx.exit(ngx.status)
  end
  fun(HEALTHCHECK, upstream, peer)
end

local function set_ip(upstream, selected_ip, fun)
  local ok, upstreams, err = upstream.get_upstreams()
  if not ok then
    ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR
    ngx.say(err)
    ngx.exit(ngx.status)
  end

  for j=1,#upstreams
  do
    local u = upstreams[j]
    local ok, peers, err = upstream.get_peers(u)
    if not ok then
      ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR
      ngx.say(err)
      ngx.exit(ngx.status)
    end

    for i=1,#peers
    do
      local peer = peers[i]
      local ip, port = peer.name:match("(.+):(%d+)")
      if not selected_ip or selected_ip == ip then
        fun(HEALTHCHECK, u, peer.name)
        ngx.say(u .. " " .. peer.name)
      end<commit_msg>fix enable/diacble peer for sockets<commit_after>local _M = {
  _VERSION = "1.8.3"
}

local HEALTHCHECK = ngx.shared.healthcheck

local function set_peer(upstream, peer, fun)
  if not upstream or not peer then
    ngx.status = ngx.HTTP_BAD_REQUEST
    ngx.say("upstream and peer arguments required")
    ngx.exit(ngx.status)
  end
  fun(HEALTHCHECK, upstream, ngx.unescape_uri(peer))
end

local function set_ip(upstream, selected_ip, fun)
  local ok, upstreams, err = upstream.get_upstreams()
  if not ok then
    ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR
    ngx.say(err)
    ngx.exit(ngx.status)
  end

  for j=1,#upstreams
  do
    local u = upstreams[j]
    local ok, peers, err = upstream.get_peers(u)
    if not ok then
      ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR
      ngx.say(err)
      ngx.exit(ngx.status)
    end

    for i=1,#peers
    do
      local peer = peers[i]
      local ip, port = peer.name:match("(.+):(%d+)")
      if not selected_ip or selected_ip == ip then
        fun(HEALTHCHECK, u, peer.name)
        ngx.say(u .. " " .. peer.name)
      end
{'fraction_non_alphanumeric': 0.11153119092627599, 'fraction_numerical': 0.004725897920604915, 'mean_word_length': 2.870201096892139, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3167176', 'n_tokens_mistral': 814, 'n_tokens_neox': 787, 'n_words': 191}