explicit ScheduleItem()

in bistro/nodes/AddTimeFetcher.h [200:229]


    explicit ScheduleItem(const folly::dynamic& item_cfg)
      : lifetime_(0),  // Required; 0 is not a valid value
        enabled_lifetime_(-1) {  // Optional; defaults to "lifetime"
      if (!item_cfg.isObject()) {
        throw BistroException("\"schedule\" items must be objects");
      }
      for (const auto &p : item_cfg.items()) {
        if (p.first == "lifetime") {
          lifetime_ = p.second.asInt();
        } else if (p.first == "enabled_lifetime") {
          enabled_lifetime_ = p.second.asInt();
        } else if (p.first == "tags") {
          if (!p.second.isArray()) {
            throw BistroException("\"tags\" must be an array");
          }
          for (const auto &tag : p.second) {
            tags_.insert(tag.asString());
          }
        } else if (p.first == "cron") {
          boost::local_time::time_zone_ptr system_tz;  // null == system tz
          cron_ = CrontabItem::fromDynamic(p.second, system_tz);
        }
      }
      if (lifetime_ == 0) {
        throw BistroException("add_time: each item needs a lifetime");
      }
      if (enabled_lifetime_ == -1) {
        enabled_lifetime_ = lifetime_;
      }
    }