<commit_before>package com.avsystem.commons
package redis.actor

import akka.actor.{Actor, ActorRef, Props}
import com.avsystem.commons.redis.actor.RedisConnectionActor.PacksResult
import com.avsystem.commons.redis.commands.{PubSubEvent, Subscribe}
import com.avsystem.commons.redis.config.MasterSlaveConfig
import com.avsystem.commons.redis.exception.MasterSlaveInitializationException
import com.avsystem.commons.redis.protocol.BulkStringMsg
import com.avsystem.commons.redis.util.ActorLazyLogging
import com.avsystem.commons.redis.{NodeAddress, RedisApi, RedisBatch, RedisNodeClient}

class SentinelsMonitoringActor(
  masterName: String,
  seedSentinels: Seq[NodeAddress],
  config: MasterSlaveConfig,
  onInitFailure: Throwable => Unit,
  onMasterChange: RedisNodeClient => Unit,
) extends Actor with ActorLazyLogging {

  import RedisApi.Batches.StringTyped._
  import SentinelsMonitoringActor._
  import context._

  private val sentinels = new MHashMap[NodeAddress, ActorRef]
  private val seedFailures = new MArrayBuffer[Throwable]
  private var master = Opt.empty[RedisNodeClient]

  private val FetchState: RedisBatch[(NodeAddress, Set[NodeAddress])] =
    sentinelGetMasterAddrByName(masterName) zip
      sentinelSentinels(masterName).map(_.flatMap(extractSentinelAddress).toSet)

  private def extractSentinelAddress(info: BMap[String, String]): Opt[NodeAddress] =
    Try(NodeAddress(info("ip"), info("port").toInt)).toOpt

  seedSentinels.foreach(getConnection(_, seed = true))

  private def getConnection(addr: NodeAddress, seed: Boolean): ActorRef =
    sentinels.getOrElse(addr, openConnection(addr, seed))<commit_msg>-trailing comma<commit_after>package com.avsystem.commons
package redis.actor

import akka.actor.{Actor, ActorRef, Props}
import com.avsystem.commons.redis.actor.RedisConnectionActor.PacksResult
import com.avsystem.commons.redis.commands.{PubSubEvent, Subscribe}
import com.avsystem.commons.redis.config.MasterSlaveConfig
import com.avsystem.commons.redis.exception.MasterSlaveInitializationException
import com.avsystem.commons.redis.protocol.BulkStringMsg
import com.avsystem.commons.redis.util.ActorLazyLogging
import com.avsystem.commons.redis.{NodeAddress, RedisApi, RedisBatch, RedisNodeClient}

class SentinelsMonitoringActor(
  masterName: String,
  seedSentinels: Seq[NodeAddress],
  config: MasterSlaveConfig,
  onInitFailure: Throwable => Unit,
  onMasterChange: RedisNodeClient => Unit
) extends Actor with ActorLazyLogging {

  import RedisApi.Batches.StringTyped._
  import SentinelsMonitoringActor._
  import context._

  private val sentinels = new MHashMap[NodeAddress, ActorRef]
  private val seedFailures = new MArrayBuffer[Throwable]
  private var master = Opt.empty[RedisNodeClient]

  private val FetchState: RedisBatch[(NodeAddress, Set[NodeAddress])] =
    sentinelGetMasterAddrByName(masterName) zip
      sentinelSentinels(masterName).map(_.flatMap(extractSentinelAddress).toSet)

  private def extractSentinelAddress(info: BMap[String, String]): Opt[NodeAddress] =
    Try(NodeAddress(info("ip"), info("port").toInt)).toOpt

  seedSentinels.foreach(getConnection(_, seed = true))

  private def getConnection(addr: NodeAddress, seed: Boolean): ActorRef =
    sentinels.getOrElse(addr, openConnection(addr, seed))
{'fraction_non_alphanumeric': 0.09520903265181568, 'fraction_numerical': 0.0, 'mean_word_length': 6.641025641025641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7594646', 'n_tokens_mistral': 1032, 'n_tokens_neox': 999, 'n_words': 188}