class Fluent::Counter::Server

def init(params, scope, options)

def init(params, scope, options)
  validator = Fluent::Counter::HashValidator.new(:empty, :name, :reset_interval)
  valid_params, errors = validator.call(params)
  res = Response.new(errors)
  key_hash = valid_params.reduce({}) do |acc, vp|
    acc.merge(Store.gen_key(scope, vp['name']) => vp)
  end
  do_init = lambda do |store, key|
    begin
      param = key_hash[key]
      v = store.init(key, param, ignore: options['ignore'])
      @log.debug("Create new key: #{param['name']}")
      res.push_data v
    rescue => e
      res.push_error e
    end
  end
  if options['random']
    @mutex_hash.synchronize_keys(*(key_hash.keys), &do_init)
  else
    @mutex_hash.synchronize(*(key_hash.keys), &do_init)
  end
  res.to_hash
end