示例#1
0
  public Collection<String> getConfigPathsForProject(ServiceInfo serviceInfo) {
    final Collection<String> paths = Lists.newArrayListWithCapacity(templates.size());

    for (Template template : templates) {
      final String filename = String.format(template.getFilename(), serviceInfo.getName());
      paths.add(String.format("%s/%s", loadBalancerConfiguration.getRootPath(), filename));
    }

    return paths;
  }
示例#2
0
  public Collection<LbConfigFile> generateConfigsForProject(ServiceSnapshot snapshot) {
    if (snapshot.getHealthyUpstreams().isEmpty()) {
      return ImmutableList.of(); // nginx doesnt take kindly to zero upstreams.
    }

    final Collection<LbConfigFile> files = Lists.newArrayListWithCapacity(templates.size());

    for (Template template : templates) {
      final String filename =
          String.format(template.getFilename(), snapshot.getServiceInfo().getName());
      final StringWriter content = new StringWriter();
      template.getTemplate().execute(content, snapshot);
      files.add(
          new LbConfigFile(
              String.format("%s/%s", loadBalancerConfiguration.getRootPath(), filename),
              content.toString()));
    }

    return files;
  }