Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply ktlint with max_line_length as 112 #5456

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.{kt,kts}]
max_line_length = 112
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ open class AnnotatedServiceFlowBenchmark {

@Get("/publisher")
@ProducesJsonSequences
fun publisherBm(): Publisher<String> = Flux.fromStream(IntStream.range(0, 1000).mapToObj { it.toString() })
fun publisherBm(): Publisher<String> =
Flux.fromStream(IntStream.range(0, 1000).mapToObj { it.toString() })
},
)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class GraphqlArmeriaClient(
private val serializer: GraphQLClientSerializer = defaultGraphQLSerializer(),
// TODO(ikhoon): support Automatic Persisted Queries
// See: https://github.com/ExpediaGroup/graphql-kotlin/issues/1640
override val automaticPersistedQueriesSettings: AutomaticPersistedQueriesSettings = AutomaticPersistedQueriesSettings(),
override val automaticPersistedQueriesSettings: AutomaticPersistedQueriesSettings =
AutomaticPersistedQueriesSettings(),
) : GraphQLClient<HttpRequestBuilder> {
override suspend fun <T : Any> execute(
request: GraphQLClientRequest<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ class HelloServiceImpl : HelloServiceGrpcKt.HelloServiceCoroutineImplBase() {
suspend fun <T> withArmeriaBlockingContext(block: suspend CoroutineScope.() -> T): T =
withContext(ServiceRequestContext.current().blockingTaskExecutor().asCoroutineDispatcher(), block)

private fun buildReply(message: String): HelloReply = HelloReply.newBuilder().setMessage(message).build()
private fun buildReply(message: String): HelloReply =
HelloReply.newBuilder().setMessage(
message,
).build()

private fun toMessage(message: String): String = "Hello, $message!"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ interface CoroutineServerInterceptor : AsyncServerInterceptor {
CoroutineContextServerInterceptor::class.let { kclass ->
val companionObject = checkNotNull(kclass.companionObject)
val property = companionObject.memberProperties.single { it.name == "COROUTINE_CONTEXT_KEY" }
checkNotNull(property.getter.call(kclass.companionObjectInstance)) as Context.Key<CoroutineContext>
checkNotNull(
property.getter.call(kclass.companionObjectInstance),
) as Context.Key<CoroutineContext>
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ internal class CoroutineServerInterceptorTest {
return SimpleResponse.getDefaultInstance()
}

override fun streamingOutputCall(request: StreamingOutputCallRequest): Flow<StreamingOutputCallResponse> {
override fun streamingOutputCall(
request: StreamingOutputCallRequest,
): Flow<StreamingOutputCallResponse> {
return flow {
for (i in 1..5) {
delay(500)
Expand All @@ -404,15 +406,19 @@ internal class CoroutineServerInterceptorTest {
}
}

override suspend fun streamingInputCall(requests: Flow<StreamingInputCallRequest>): StreamingInputCallResponse {
override suspend fun streamingInputCall(
requests: Flow<StreamingInputCallRequest>,
): StreamingInputCallResponse {
val names = requests.map { it.payload.body.toString() }.toList()

assertContextPropagation()

return buildReply(names)
}

override fun fullDuplexCall(requests: Flow<StreamingOutputCallRequest>): Flow<StreamingOutputCallResponse> {
override fun fullDuplexCall(
requests: Flow<StreamingOutputCallRequest>,
): Flow<StreamingOutputCallResponse> {
return flow {
requests.collect {
delay(500)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,16 @@ class TestServiceImpl : TestServiceGrpcKt.TestServiceCoroutineImplBase() {
ServiceRequestContext.current().blockingTaskExecutor().asCoroutineDispatcher()

// A blocking dispatcher that does not propagate a request context
fun blockingDispatcher(): CoroutineDispatcher = CommonPools.blockingTaskExecutor().asCoroutineDispatcher()
fun blockingDispatcher(): CoroutineDispatcher =
CommonPools.blockingTaskExecutor().asCoroutineDispatcher()

suspend fun <T> withArmeriaBlockingContext(block: suspend CoroutineScope.() -> T): T =
withContext(ServiceRequestContext.current().blockingTaskExecutor().asCoroutineDispatcher(), block)

private fun buildReply(message: String): HelloReply = HelloReply.newBuilder().setMessage(message).build()
private fun buildReply(message: String): HelloReply =
HelloReply.newBuilder().setMessage(
message,
).build()

private fun toMessage(message: String): String = "Hello, $message!"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class AnnotatedServiceErrorMessageTest {

assertThatThrownBy { serverBuilder.build() }
.hasMessageContaining(
"Kotlin suspending functions are supported only when you added 'armeria-kotlin' as a dependency.",
"Kotlin suspending functions are supported" +
" only when you added 'armeria-kotlin' as a dependency.",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import kotlin.coroutines.CoroutineContext
/**
* Propagates [ServiceRequestContext] over coroutines.
*/
@Deprecated("Use RequestContext.asCoroutineContext() instead.", ReplaceWith("RequestContext.asCoroutineContext()"))
@Deprecated(
"Use RequestContext.asCoroutineContext() instead.",
ReplaceWith("RequestContext.asCoroutineContext()"),
)
class ArmeriaRequestCoroutineContext(
private val requestContext: ServiceRequestContext,
) : ThreadContextElement<SafeCloseable>, AbstractCoroutineContextElement(Key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ internal class FlowAnnotatedServiceTest {
fun runsWithinEventLoop() =
flow {
ServiceRequestContext.current()
assertThat(Thread.currentThread().name).contains("armeria-common-worker")
assertThat(
Thread.currentThread().name,
).contains("armeria-common-worker")
emit("OK")
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ class SuspendingAnnotatedServiceTest {
@Get("/baz")
suspend fun baz(): String {
ServiceRequestContext.current()
assertThat(Thread.currentThread().name).contains("armeria-common-blocking-tasks")
assertThat(
Thread.currentThread().name,
).contains("armeria-common-blocking-tasks")
return "OK"
}
},
Expand Down
Loading