本文整理了Java中com.linecorp.armeria.client.Endpoint.authority()
方法的一些代码示例,展示了Endpoint.authority()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Endpoint.authority()
方法的具体详情如下:
包路径:com.linecorp.armeria.client.Endpoint
类名称:Endpoint
方法名:authority
[英]Converts this endpoint into the authority part of a URI.
[中]将此端点转换为URI的授权部分。
代码示例来源:origin: line/armeria
@Override
public int hashCode() {
return (authority().hashCode() * 31 + Objects.hashCode(ipAddr)) * 31 + port;
}
代码示例来源:origin: line/armeria
private State state(Endpoint endpoint) {
final String authority = endpoint.authority();
return map.computeIfAbsent(authority, e -> new State(eventLoops));
}
代码示例来源:origin: line/armeria
@Override
public String toString() {
final ToStringHelper helper = MoreObjects.toStringHelper(this);
helper.addValue(authority());
if (!isGroup()) {
if (hostType == HostType.HOSTNAME_AND_IPv4 ||
hostType == HostType.HOSTNAME_AND_IPv6) {
helper.add("ipAddr", ipAddr);
}
helper.add("weight", weight);
}
return helper.toString();
}
}
代码示例来源:origin: line/armeria
@Override
public String toString() {
String strVal = this.strVal;
if (strVal != null) {
return strVal;
}
final StringBuilder buf = new StringBuilder(96);
// Prepend the current channel information if available.
final Channel ch = channel();
final boolean hasChannel = ch != null;
if (hasChannel) {
buf.append(ch);
}
buf.append('[')
.append(sessionProtocol().uriText())
.append("://")
.append(endpoint.authority())
.append(path())
.append('#')
.append(method())
.append(']');
strVal = buf.toString();
if (hasChannel) {
this.strVal = strVal;
}
return strVal;
}
代码示例来源:origin: line/armeria
@Override
public void accept(List<Endpoint> endpoints) {
final Map<Endpoint, Boolean> endpointsToUpdate = new HashMap<>();
endpoints.forEach(e -> endpointsToUpdate.put(e, true));
endpointGroup.allServers.forEach(
conn -> endpointsToUpdate.putIfAbsent(conn.endpoint(), false));
// Update the previously appeared endpoints.
healthMap.entrySet().forEach(e -> {
final Endpoint authority = e.getKey();
final Boolean healthy = endpointsToUpdate.remove(authority);
e.setValue(Boolean.TRUE.equals(healthy));
});
// Process the newly appeared endpoints.
endpointsToUpdate.forEach((endpoint, healthy) -> {
healthMap.put(endpoint, healthy);
final List<Tag> tags = new ArrayList<>(2);
tags.add(Tag.of("authority", endpoint.authority()));
final String ipAddr = endpoint.hasIpAddr() ? endpoint.ipAddr() : "";
assert ipAddr != null;
tags.add(Tag.of("ip", ipAddr));
registry.gauge(idPrefix.name(), idPrefix.tags(tags),
this, unused -> healthMap.get(endpoint) ? 1 : 0);
});
}
}
代码示例来源:origin: line/armeria
logPrefix(),
endpoints.stream()
.map(e -> e.authority() + '/' + e.weight())
.collect(Collectors.joining(", ")),
ttl);
代码示例来源:origin: line/armeria
private HttpEndpointHealthChecker(
ClientFactory clientFactory, Endpoint endpoint,
SessionProtocol protocol, String healthCheckPath, int healthCheckPort,
Function<? super ClientOptionsBuilder, ClientOptionsBuilder> configurator) {
final String scheme = protocol.uriText();
final String ipAddr = endpoint.ipAddr();
final HttpClientBuilder builder;
if (ipAddr == null) {
builder = new HttpClientBuilder(scheme + "://" + endpoint.authority());
} else {
final int port = healthCheckPort > 0 ? healthCheckPort : endpoint.port(protocol.defaultPort());
if (endpoint.ipFamily() == StandardProtocolFamily.INET) {
builder = new HttpClientBuilder(scheme + "://" + ipAddr + ':' + port);
} else {
builder = new HttpClientBuilder(scheme + "://[" + ipAddr + "]:" + port);
}
builder.setHttpHeader(HttpHeaderNames.AUTHORITY, endpoint.authority());
}
httpClient = builder.factory(clientFactory)
.options(configurator.apply(new ClientOptionsBuilder()).build())
.build();
this.healthCheckPath = healthCheckPath;
}
代码示例来源:origin: line/armeria
final Endpoint endpoint = cCtx.endpoint();
if (endpoint.isGroup()) {
authority = endpoint.authority();
} else {
final int defaultPort = cCtx.sessionProtocol().defaultPort();
代码示例来源:origin: com.linecorp.armeria/armeria-logback
final Endpoint endpoint = cCtx.endpoint();
if (endpoint.isGroup()) {
authority = endpoint.authority();
} else {
final int defaultPort = cCtx.sessionProtocol().defaultPort();
代码示例来源:origin: com.linecorp.armeria/armeria-logback-shaded
final Endpoint endpoint = cCtx.endpoint();
if (endpoint.isGroup()) {
authority = endpoint.authority();
} else {
final int defaultPort = cCtx.sessionProtocol().defaultPort();
代码示例来源:origin: line/centraldogma
/**
* Returns a newly-created {@link CentralDogma} instance.
*
* @throws UnknownHostException if failed to resolve the host names from the DNS servers
*/
public CentralDogma build() throws UnknownHostException {
final Endpoint endpoint = endpoint();
final String scheme = "tbinary+" + (isUseTls() ? "https" : "http") + "://";
final String uri = scheme + endpoint.authority() + "/cd/thrift/v1";
final ClientBuilder builder = new ClientBuilder(uri)
.factory(clientFactory())
.rpcDecorator(CentralDogmaClientTimeoutScheduler::new);
clientConfigurator().configure(builder);
builder.decorator((delegate, ctx, req) -> {
if (!req.headers().contains(HttpHeaderNames.AUTHORIZATION)) {
// To prevent CSRF attack, we add 'Authorization' header to every request.
req.headers().set(HttpHeaderNames.AUTHORIZATION, "bearer " + CsrfToken.ANONYMOUS);
}
return delegate.execute(ctx, req);
});
return new LegacyCentralDogma(clientFactory(), builder.build(CentralDogmaService.AsyncIface.class));
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-client-armeria-legacy-shaded
/**
* Returns a newly-created {@link CentralDogma} instance.
*
* @throws UnknownHostException if failed to resolve the host names from the DNS servers
*/
public CentralDogma build() throws UnknownHostException {
final Endpoint endpoint = endpoint();
final String scheme = "tbinary+" + (isUseTls() ? "https" : "http") + "://";
final String uri = scheme + endpoint.authority() + "/cd/thrift/v1";
final ClientBuilder builder = new ClientBuilder(uri)
.factory(clientFactory())
.decorator(RpcRequest.class, RpcResponse.class,
CentralDogmaClientTimeoutScheduler::new);
clientConfigurator().configure(builder);
builder.decorator(HttpRequest.class, HttpResponse.class,
(delegate, ctx, req) -> {
if (!req.headers().contains(HttpHeaderNames.AUTHORIZATION)) {
// To prevent CSRF attack, we add 'Authorization' header to every request.
req.headers().set(HttpHeaderNames.AUTHORIZATION,
"bearer " + CsrfToken.ANONYMOUS);
}
return delegate.execute(ctx, req);
});
return new LegacyCentralDogma(clientFactory(), builder.build(CentralDogmaService.AsyncIface.class));
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-client-armeria-legacy
/**
* Returns a newly-created {@link CentralDogma} instance.
*
* @throws UnknownHostException if failed to resolve the host names from the DNS servers
*/
public CentralDogma build() throws UnknownHostException {
final Endpoint endpoint = endpoint();
final String scheme = "tbinary+" + (isUseTls() ? "https" : "http") + "://";
final String uri = scheme + endpoint.authority() + "/cd/thrift/v1";
final ClientBuilder builder = new ClientBuilder(uri)
.factory(clientFactory())
.rpcDecorator(CentralDogmaClientTimeoutScheduler::new);
clientConfigurator().configure(builder);
builder.decorator((delegate, ctx, req) -> {
if (!req.headers().contains(HttpHeaderNames.AUTHORIZATION)) {
// To prevent CSRF attack, we add 'Authorization' header to every request.
req.headers().set(HttpHeaderNames.AUTHORIZATION, "bearer " + CsrfToken.ANONYMOUS);
}
return delegate.execute(ctx, req);
});
return new LegacyCentralDogma(clientFactory(), builder.build(CentralDogmaService.AsyncIface.class));
}
}
内容来源于网络,如有侵权,请联系作者删除!