/** * Creates a new {@link Origin} porting to a specified host and port. * * @param host host * @param port port * @return origin */ public static Origin origin(String host, int port) { return newOriginBuilder(host, port) .applicationId(randomUUID().toString()) .id(randomUUID().toString()) .build(); } }
com.hotels.styx.api.extension.service.BackendService createBackendService(String path) { requireNonNull(path, "path must not be null"); checkArgument(!origins.isEmpty(), "A backend service must have at least one origin"); String appId = newId(); Set<Origin> adaptedOrigins = this.origins.stream() .map(origin -> origin.newBuilder() .applicationId(appId) .id(newId()) .build()) .collect(toSet()); com.hotels.styx.api.extension.service.BackendService.Builder builder = newBackendServiceBuilder() .id(appId) .responseTimeoutMillis(responseTimeoutMillis) .origins(adaptedOrigins) .path(path); if (ssl) { builder = builder.https(new TlsSettings.Builder() .trustAllCerts(true) .build()); } return builder .build(); }
public static ConnectionPool create(String hostname, int port, ConnectionPoolSettings poolSettings) { return new SimpleConnectionPoolFactory.Builder() .connectionPoolSettings(poolSettings) .connectionFactory(new NettyConnectionFactory.Builder().build()) .metricRegistry(new CodaHaleMetricRegistry()) .build() .create(Origin.newOriginBuilder(hostname, port) .applicationId(format("%s:%d", hostname, port)) .id(format("%s:%d-01", hostname, port)) .build()); }