Skip to content

Commit 0fc757c

Browse files
authored
Merge branch 'main' into 241027-proxy-config
2 parents 1240a24 + 2419274 commit 0fc757c

File tree

325 files changed

+24669
-5662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+24669
-5662
lines changed

.github/workflows/actions_build.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
on: [ ubicloud-standard-8, macos-12, windows-latest ]
35+
on: [ ubicloud-standard-16, macos-latest, windows-latest ]
3636
java: [ 21 ]
3737
include:
3838
- java: 8
39-
on: ubicloud-standard-8
39+
on: ubicloud-standard-16
4040
- java: 11
41-
on: ubicloud-standard-8
41+
on: ubicloud-standard-16
4242
- java: 17
43-
on: ubicloud-standard-8
43+
on: ubicloud-standard-16
4444
leak: true
4545
- java: 17
46-
on: ubicloud-standard-8
46+
on: ubicloud-standard-16
4747
min-java: 11
4848
- java: 17
49-
on: ubicloud-standard-8
49+
on: ubicloud-standard-16
5050
min-java: 17
5151
coverage: true
5252
- java: 21
53-
on: ubicloud-standard-8
53+
on: ubicloud-standard-16
5454
snapshot: true
5555
# blockhound makes the build run about 10 minutes slower
5656
blockhound: true
@@ -236,7 +236,7 @@ jobs:
236236

237237
- name: Run the linters
238238
run: |
239-
./gradlew --no-daemon --stacktrace --max-workers=8 --parallel lint
239+
./gradlew --no-daemon --stacktrace --max-workers=4 --parallel lint
240240
241241
site:
242242
if: github.repository == 'line/armeria'

.github/workflows/publish-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
publish:
1414
name: Publish final artifacts
1515
if: github.repository == 'line/armeria'
16-
runs-on: ubicloud-standard-8
16+
runs-on: ubicloud-standard-16
1717
steps:
1818
- uses: actions/checkout@v4
1919

@@ -29,7 +29,7 @@ jobs:
2929

3030
- name: Build with Gradle
3131
run: |
32-
./gradlew --no-daemon --stacktrace --max-workers=8 --parallel -PflakyTests=false \
32+
./gradlew --no-daemon --stacktrace --max-workers=12 --parallel -PflakyTests=false \
3333
-Pretry=true -PfailOnPassedAfterRetry=false \
3434
build
3535
shell: bash

.github/workflows/publish-site.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Publish Armeria site
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release Version'
8+
required: true
9+
type: string
410
push:
511
tags:
612
- armeria-*
@@ -32,7 +38,11 @@ jobs:
3238

3339
- name: Build the site
3440
run: |
35-
./gradlew --no-daemon --stacktrace --max-workers=2 --parallel -PgithubToken=${{ secrets.GITHUB_TOKEN }} site
41+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
42+
./gradlew --no-daemon --stacktrace --max-workers=2 --parallel -PgithubToken=${{ secrets.GITHUB_TOKEN }} -Pversion=${{ inputs.version }} site
43+
else
44+
./gradlew --no-daemon --stacktrace --max-workers=2 --parallel -PgithubToken=${{ secrets.GITHUB_TOKEN }} site
45+
fi
3646
3747
- name: Deploy the site
3848
uses: peaceiris/actions-gh-pages@v4

.scalafmt.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "3.3.2"
1+
version = "3.8.3"
22

33
style = default
44

benchmarks/jmh/src/jmh/java/com/linecorp/armeria/server/RoutersBenchmark.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class RoutersBenchmark {
6161
FALLBACK_SERVICE = newServiceConfig(Route.ofCatchAll());
6262
HOST = new VirtualHost(
6363
"localhost", "localhost", 0, null,
64-
null, SERVICES, FALLBACK_SERVICE, RejectedRouteHandler.DISABLED,
64+
null, null, SERVICES, FALLBACK_SERVICE, RejectedRouteHandler.DISABLED,
6565
unused -> NOPLogger.NOP_LOGGER, FALLBACK_SERVICE.defaultServiceNaming(),
6666
FALLBACK_SERVICE.defaultLogName(), 0, 0, false,
6767
AccessLogWriter.disabled(), CommonPools.blockingTaskExecutor(), 0, SuccessFunction.ofDefault(),

build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ allprojects {
117117
doFirst {
118118
addTestOutputListener({ descriptor, event ->
119119
if (event.message.contains('LEAK: ')) {
120+
if (isCi) {
121+
logger.warn("Leak is detected in ${descriptor.className}.${descriptor.displayName}\n" +
122+
"${event.message}")
123+
}
120124
hasLeak.set(true)
121125
}
122126
})
@@ -485,3 +489,7 @@ allprojects {
485489
}
486490
}
487491
}
492+
493+
configure(projectsWithFlags('java', 'publish')) {
494+
failOnVersionConflict(libs.protobuf.java)
495+
}

consul/src/main/java/com/linecorp/armeria/internal/consul/ConsulClient.java

+32-7
Original file line numberDiff line numberDiff line change
@@ -75,53 +75,78 @@ ObjectMapper getObjectMapper() {
7575
}
7676

7777
/**
78-
* Registers a service to Consul Agent with service ID.
78+
* Registers a service to Consul Agent.
7979
*
8080
* @param serviceId a service ID that identifying a service
8181
* @param serviceName a service name to register
8282
* @param endpoint an endpoint of service to register
8383
* @param check a check for the service
8484
* @param tags tags for the service
85-
* @return a {@link CompletableFuture} that will be completed with the registered service ID
85+
*
86+
* @return an HttpResponse representing the HTTP response from Consul
8687
*/
8788
public HttpResponse register(String serviceId, String serviceName, Endpoint endpoint,
8889
@Nullable Check check, List<String> tags) {
8990
return agentClient.register(serviceId, serviceName, endpoint.host(), endpoint.port(), check, tags);
9091
}
9192

9293
/**
93-
* De-registers a service to Consul Agent.
94+
* De-registers a service from Consul Agent.
9495
*
9596
* @param serviceId a service ID that identifying a service
97+
*
98+
* @return an HttpResponse representing the HTTP response from Consul
9699
*/
97100
public HttpResponse deregister(String serviceId) {
98101
return agentClient.deregister(serviceId);
99102
}
100103

101104
/**
102-
* Get registered endpoints with service name from Consul agent.
105+
* Retrieves the list of registered endpoints for the specified service name from the Consul agent.
106+
*
107+
* @param serviceName the name of the service whose endpoints are to be retrieved
108+
*
109+
* @return a {@link CompletableFuture} which provides a list of {@link Endpoint}s
103110
*/
104111
public CompletableFuture<List<Endpoint>> endpoints(String serviceName) {
105112
return endpoints(serviceName, null, null);
106113
}
107114

108115
/**
109-
* Get registered endpoints with service name in datacenter from Consul agent.
116+
* Retrieves the list of registered endpoints for the specified service name and datacenter
117+
* from the Consul agent, optionally applying a filter.
118+
*
119+
* @param serviceName the name of the service whose endpoints are to be retrieved
120+
* @param datacenter the datacenter to query; if {@code null}, the default datacenter is used
121+
* @param filter a filter expression to apply; if {@code null}, no filtering is performed
122+
*
123+
* @return a {@link CompletableFuture} which provides a list of {@link Endpoint}s
110124
*/
111125
public CompletableFuture<List<Endpoint>> endpoints(String serviceName, @Nullable String datacenter,
112126
@Nullable String filter) {
113127
return catalogClient.endpoints(serviceName, datacenter, filter);
114128
}
115129

116130
/**
117-
* Returns the registered endpoints with the specified service name from Consul agent.
131+
* Retrieves the list of healthy endpoints for the specified service name from the Consul agent.
132+
*
133+
* @param serviceName the name of the service whose healthy endpoints are to be retrieved
134+
*
135+
* @return a {@link CompletableFuture} which provides a list of healthy {@link Endpoint}s
118136
*/
119137
public CompletableFuture<List<Endpoint>> healthyEndpoints(String serviceName) {
120138
return healthyEndpoints(serviceName, null, null);
121139
}
122140

123141
/**
124-
* Returns the registered endpoints with the specified service name in datacenter from Consul agent.
142+
* Retrieves the list of healthy endpoints for the specified service name and datacenter
143+
* from the Consul agent, optionally applying a filter.
144+
*
145+
* @param serviceName the name of the service whose healthy endpoints are to be retrieved
146+
* @param datacenter the datacenter to query; if {@code null}, the default datacenter is used
147+
* @param filter a filter expression to apply; if {@code null}, no filtering is performed
148+
*
149+
* @return a {@link CompletableFuture} which provides a list of healthy {@link Endpoint}s
125150
*/
126151
public CompletableFuture<List<Endpoint>> healthyEndpoints(String serviceName, @Nullable String datacenter,
127152
@Nullable String filter) {

core/build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ dependencies {
139139
// JUnit Pioneer
140140
testImplementation libs.junit.pioneer
141141

142+
// Reactor for registering EventLoop as a non blocking thread.
143+
optionalImplementation libs.reactor.core
144+
142145
// Reactive Streams
143146
api libs.reactivestreams
144147
testImplementation libs.reactivestreams.tck
@@ -217,8 +220,6 @@ if (tasks.findByName('trimShadedJar')) {
217220
tasks.trimShadedJar.configure {
218221
// Keep all classes under com.linecorp.armeria, except the internal ones.
219222
keep "class !com.linecorp.armeria.internal.shaded.**,com.linecorp.armeria.** { *; }"
220-
// Keep the 'NonBlocking' tag interface.
221-
keep "class reactor.core.scheduler.NonBlocking { *; }"
222223
// Do not optimize the dependencies that access some fields via sun.misc.Unsafe or reflection only.
223224
keep "class com.linecorp.armeria.internal.shaded.caffeine.** { *; }"
224225
keep "class com.linecorp.armeria.internal.shaded.jctools.** { *; }"

core/src/main/java/com/linecorp/armeria/client/AbstractClientOptionsBuilder.java

+37-9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import java.util.function.Function;
3030
import java.util.function.Supplier;
3131

32+
import com.google.common.collect.ImmutableList;
33+
3234
import com.linecorp.armeria.client.endpoint.EndpointGroup;
3335
import com.linecorp.armeria.client.redirect.RedirectConfig;
3436
import com.linecorp.armeria.common.HttpHeaderNames;
@@ -55,6 +57,7 @@ public class AbstractClientOptionsBuilder {
5557

5658
private final Map<ClientOption<?>, ClientOptionValue<?>> options = new LinkedHashMap<>();
5759
private final ClientDecorationBuilder decoration = ClientDecoration.builder();
60+
private final ClientPreprocessorsBuilder clientPreprocessorsBuilder = new ClientPreprocessorsBuilder();
5861
private final HttpHeadersBuilder headers = HttpHeaders.builder();
5962

6063
@Nullable
@@ -125,6 +128,8 @@ public <T> AbstractClientOptionsBuilder option(ClientOptionValue<T> optionValue)
125128
} else if (opt == ClientOptions.HEADERS) {
126129
final HttpHeaders h = (HttpHeaders) optionValue.value();
127130
setHeaders(h);
131+
} else if (opt == ClientOptions.PREPROCESSORS) {
132+
clientPreprocessorsBuilder.add((ClientPreprocessors) optionValue.value());
128133
} else {
129134
options.put(opt, optionValue);
130135
}
@@ -518,6 +523,28 @@ public AbstractClientOptionsBuilder responseTimeoutMode(ResponseTimeoutMode resp
518523
requireNonNull(responseTimeoutMode, "responseTimeoutMode"));
519524
}
520525

526+
/**
527+
* Adds the specified HTTP-level {@code preprocessor}.
528+
*
529+
* @param preprocessor the {@link HttpPreprocessor} that preprocesses an invocation
530+
*/
531+
@UnstableApi
532+
public AbstractClientOptionsBuilder preprocessor(HttpPreprocessor preprocessor) {
533+
clientPreprocessorsBuilder.add(preprocessor);
534+
return this;
535+
}
536+
537+
/**
538+
* Adds the specified RPC-level {@code rpcPreprocessor}.
539+
*
540+
* @param rpcPreprocessor the {@link RpcPreprocessor} that preprocesses an invocation
541+
*/
542+
@UnstableApi
543+
public AbstractClientOptionsBuilder rpcPreprocessor(RpcPreprocessor rpcPreprocessor) {
544+
clientPreprocessorsBuilder.addRpc(rpcPreprocessor);
545+
return this;
546+
}
547+
521548
/**
522549
* Builds {@link ClientOptions} with the given options and the
523550
* {@linkplain ClientOptions#of() default options}.
@@ -532,20 +559,21 @@ protected final ClientOptions buildOptions() {
532559
*/
533560
protected final ClientOptions buildOptions(@Nullable ClientOptions baseOptions) {
534561
final Collection<ClientOptionValue<?>> optVals = options.values();
535-
final int numOpts = optVals.size();
536-
final int extra = contextCustomizer == null ? 3 : 4;
537-
final ClientOptionValue<?>[] optValArray = optVals.toArray(new ClientOptionValue[numOpts + extra]);
538-
optValArray[numOpts] = ClientOptions.DECORATION.newValue(decoration.build());
539-
optValArray[numOpts + 1] = ClientOptions.HEADERS.newValue(headers.build());
540-
optValArray[numOpts + 2] = ClientOptions.CONTEXT_HOOK.newValue(contextHook);
562+
final ImmutableList.Builder<ClientOptionValue<?>> additionalValues =
563+
ImmutableList.builder();
564+
additionalValues.addAll(optVals);
565+
additionalValues.add(ClientOptions.DECORATION.newValue(decoration.build()));
566+
additionalValues.add(ClientOptions.PREPROCESSORS.newValue(clientPreprocessorsBuilder.build()));
567+
additionalValues.add(ClientOptions.HEADERS.newValue(headers.build()));
568+
additionalValues.add(ClientOptions.CONTEXT_HOOK.newValue(contextHook));
541569
if (contextCustomizer != null) {
542-
optValArray[numOpts + 3] = ClientOptions.CONTEXT_CUSTOMIZER.newValue(contextCustomizer);
570+
additionalValues.add(ClientOptions.CONTEXT_CUSTOMIZER.newValue(contextCustomizer));
543571
}
544572

545573
if (baseOptions != null) {
546-
return ClientOptions.of(baseOptions, optValArray);
574+
return ClientOptions.of(baseOptions, additionalValues.build());
547575
} else {
548-
return ClientOptions.of(optValArray);
576+
return ClientOptions.of(additionalValues.build());
549577
}
550578
}
551579
}

core/src/main/java/com/linecorp/armeria/client/AbstractHttpResponseDecoder.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public HttpResponseWrapper addResponse(@Nullable AbstractHttpRequestHandler requ
6262
int id, DecodedHttpResponse res,
6363
ClientRequestContext ctx, EventLoop eventLoop) {
6464
final HttpResponseWrapper newRes =
65-
new HttpResponseWrapper(requestHandler, res, eventLoop, ctx,
66-
ctx.responseTimeoutMillis(), ctx.maxResponseLength());
65+
new HttpResponseWrapper(requestHandler, res, eventLoop, ctx, ctx.maxResponseLength());
6766
final HttpResponseWrapper oldRes = responses.put(id, newRes);
6867
keepAliveHandler().increaseNumRequests();
6968

core/src/main/java/com/linecorp/armeria/client/AbstractWebClientBuilder.java

+12
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,16 @@ public AbstractWebClientBuilder rpcDecorator(Function<? super RpcClient, ? exten
184184
public AbstractWebClientBuilder rpcDecorator(DecoratingRpcClientFunction decorator) {
185185
throw new UnsupportedOperationException("RPC decorator cannot be added to the web client builder.");
186186
}
187+
188+
/**
189+
* Raises an {@link UnsupportedOperationException} because this builder doesn't support RPC-level but only
190+
* HTTP-level preprocessors.
191+
*
192+
* @deprecated RPC preprocessor cannot be added to the web client builder.
193+
*/
194+
@Deprecated
195+
@Override
196+
public AbstractClientOptionsBuilder rpcPreprocessor(RpcPreprocessor rpcPreprocessor) {
197+
throw new UnsupportedOperationException("RPC preprocessor cannot be added to the web client builder.");
198+
}
187199
}

0 commit comments

Comments
 (0)