ErrorCode WdtResourceController::createSender()

in WdtResourceController.cpp [359:398]


ErrorCode WdtResourceController::createSender(
    const std::string &wdtNamespace, const std::string &identifier,
    const WdtTransferRequest &wdtOperationRequest, SenderPtr &sender) {
  NamespaceControllerPtr controller = nullptr;
  sender = nullptr;
  {
    GuardLock lock(controllerMutex_);
    controller = getNamespaceController(wdtNamespace);
    if (!controller) {
      if (strictRegistration_) {
        WLOG(WARNING) << "Couldn't find controller for " << wdtNamespace;
        return NOT_FOUND;
      } else {
        WLOG(INFO) << "First time "
                   << (wdtNamespace.empty() ? "(default)" : wdtNamespace)
                   << " is seen, creating.";
        controller = createNamespaceController(wdtNamespace);
      }
    }
    if (!hasSenderQuotaInternal(controller)) {
      WLOG(ERROR) << "No quota for more sender.";
      return QUOTA_EXCEEDED;
    }
    ++numSenders_;
  }
  // TODO: not thread safe reading from options_
  throttler_->setThrottlerRates(options_.getThrottlerOptions());
  ErrorCode code =
      controller->createSender(wdtOperationRequest, identifier, sender);
  if (code != OK) {
    GuardLock lock(controllerMutex_);
    --numSenders_;
    WLOG(ERROR) << "Failed in creating sender for " << wdtNamespace << " "
                << errorCodeToStr(code);
  } else {
    WLOG(INFO) << "Successfully added a sender for " << wdtNamespace
               << " identifier " << identifier;
  }
  return code;
}