Skip to content

Commit 79190af

Browse files
Spotless goes wild
1 parent 64de0b0 commit 79190af

44 files changed

Lines changed: 632 additions & 407 deletions

File tree

Some content is hidden

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

build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ allprojects {
6565
filters =
6666
arrayOf(
6767
com.github.jk1.license.filter.LicenseBundleNormalizer(
68-
"$rootDir/config/license-normalizer-bundle.json", true))
68+
"$rootDir/config/license-normalizer-bundle.json",
69+
true,
70+
)
71+
)
6972
}
7073
}
7174

client-kotlin/src/main/kotlin/dev/restate/client/kotlin/ingress.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ suspend fun <Req, Res> Client.callSuspend(request: Request<Req, Res>): Response<
5656
*/
5757
suspend fun <Req, Res> Request<Req, Res>.send(
5858
client: Client,
59-
delay: Duration? = null
59+
delay: Duration? = null,
6060
): SendResponse<Res> {
6161
return client.sendSuspend(this, delay)
6262
}
@@ -67,7 +67,7 @@ suspend fun <Req, Res> Request<Req, Res>.send(
6767
*/
6868
suspend fun <Req, Res> Client.sendSuspend(
6969
request: Request<Req, Res>,
70-
delay: Duration? = null
70+
delay: Duration? = null,
7171
): SendResponse<Res> {
7272
return this.sendAsync(request, delay?.toJavaDuration()).await()
7373
}
@@ -81,15 +81,15 @@ suspend fun <Req, Res> Client.sendSuspend(
8181
*/
8282
suspend fun <Req, Res> WorkflowRequest<Req, Res>.submit(
8383
client: Client,
84-
delay: Duration? = null
84+
delay: Duration? = null,
8585
): SendResponse<Res> {
8686
return client.submitSuspend(this, delay)
8787
}
8888

8989
/** Submit a workflow, optionally providing an execution delay to wait for. */
9090
suspend fun <Req, Res> Client.submitSuspend(
9191
request: WorkflowRequest<Req, Res>,
92-
delay: Duration? = null
92+
delay: Duration? = null,
9393
): SendResponse<Res> {
9494
return this.submitAsync(request, delay?.toJavaDuration()).await()
9595
}
@@ -104,7 +104,7 @@ suspend fun <Req, Res> Client.submitSuspend(
104104
suspend fun <T : Any> Client.AwakeableHandle.resolveSuspend(
105105
typeTag: TypeTag<T>,
106106
payload: T,
107-
options: RequestOptions = RequestOptions.DEFAULT
107+
options: RequestOptions = RequestOptions.DEFAULT,
108108
): Response<Void> {
109109
return this.resolveAsync(typeTag, payload, options).await()
110110
}
@@ -117,7 +117,7 @@ suspend fun <T : Any> Client.AwakeableHandle.resolveSuspend(
117117
*/
118118
suspend inline fun <reified T : Any> Client.AwakeableHandle.resolveSuspend(
119119
payload: T,
120-
options: RequestOptions = RequestOptions.DEFAULT
120+
options: RequestOptions = RequestOptions.DEFAULT,
121121
): Response<Void> {
122122
return this.resolveSuspend(typeTag<T>(), payload, options)
123123
}
@@ -130,7 +130,7 @@ suspend inline fun <reified T : Any> Client.AwakeableHandle.resolveSuspend(
130130
*/
131131
suspend fun Client.AwakeableHandle.rejectSuspend(
132132
reason: String,
133-
options: RequestOptions = RequestOptions.DEFAULT
133+
options: RequestOptions = RequestOptions.DEFAULT,
134134
): Response<Void> {
135135
return this.rejectAsync(reason, options).await()
136136
}
@@ -180,7 +180,7 @@ suspend fun <T : Any?> Client.InvocationHandle<T>.getOutputSuspend(
180180
*/
181181
inline fun <reified Res> Client.idempotentInvocationHandle(
182182
target: Target,
183-
idempotencyKey: String
183+
idempotencyKey: String,
184184
): Client.IdempotentInvocationHandle<Res> {
185185
return this.idempotentInvocationHandle(target, idempotencyKey, typeTag<Res>())
186186
}
@@ -218,7 +218,7 @@ suspend fun <T> Client.IdempotentInvocationHandle<T>.getOutputSuspend(
218218
*/
219219
inline fun <reified Res> Client.workflowHandle(
220220
workflowName: String,
221-
workflowId: String
221+
workflowId: String,
222222
): Client.WorkflowHandle<Res> {
223223
return this.workflowHandle(workflowName, workflowId, typeTag<Res>())
224224
}

sdk-api-kotlin-gen/src/main/kotlin/dev/restate/sdk/kotlin/gen/KElementConverter.kt

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ import kotlin.reflect.KClass
2727
class KElementConverter(
2828
private val logger: KSPLogger,
2929
private val builtIns: KSBuiltIns,
30-
private val byteArrayType: KSType
30+
private val byteArrayType: KSType,
3131
) : KSDefaultVisitor<Service.Builder, Unit>() {
3232
companion object {
3333
private val SUPPORTED_CLASS_KIND: Set<ClassKind> = setOf(ClassKind.CLASS, ClassKind.INTERFACE)
3434
private val EMPTY_PAYLOAD: PayloadType =
3535
PayloadType(
36-
true, "", "Unit", "dev.restate.serde.kotlinx.KotlinSerializationSerdeFactory.UNIT")
36+
true,
37+
"",
38+
"Unit",
39+
"dev.restate.serde.kotlinx.KotlinSerializationSerdeFactory.UNIT",
40+
)
3741
private const val RAW_SERDE: String = "dev.restate.serde.Serde.RAW"
3842
}
3943

@@ -42,7 +46,8 @@ class KElementConverter(
4246
override fun visitAnnotated(annotated: KSAnnotated, data: Service.Builder) {
4347
if (annotated !is KSClassDeclaration) {
4448
logger.error(
45-
"Only classes or interfaces can be annotated with @Service or @VirtualObject or @Workflow")
49+
"Only classes or interfaces can be annotated with @Service or @VirtualObject or @Workflow"
50+
)
4651
}
4752
visitClassDeclaration(annotated as KSClassDeclaration, data)
4853
}
@@ -56,7 +61,8 @@ class KElementConverter(
5661
if (!SUPPORTED_CLASS_KIND.contains(classDeclaration.classKind)) {
5762
logger.error(
5863
"The ServiceProcessor supports only class declarations of kind $SUPPORTED_CLASS_KIND",
59-
classDeclaration)
64+
classDeclaration,
65+
)
6066
}
6167
if (classDeclaration.getVisibility() == Visibility.PRIVATE) {
6268
logger.error("The annotated class is private", classDeclaration)
@@ -94,7 +100,8 @@ class KElementConverter(
94100
if (data.handlers.isEmpty()) {
95101
logger.warn(
96102
"The class declaration $targetFqcn has no methods annotated as handlers",
97-
classDeclaration)
103+
classDeclaration,
104+
)
98105
}
99106

100107
var serdeFactoryDecl = "dev.restate.serde.kotlinx.KotlinSerializationSerdeFactory()"
@@ -134,7 +141,8 @@ class KElementConverter(
134141
if (!(!hasAnyAnnotation || hasExactlyOneAnnotation)) {
135142
logger.error(
136143
"You can have only one annotation between @Shared and @Exclusive and @Workflow to a method",
137-
function)
144+
function,
145+
)
138146
}
139147

140148
val handlerBuilder = Handler.builder()
@@ -158,7 +166,8 @@ class KElementConverter(
158166
.withInputAccept(inputAcceptFromParameterList(function.parameters))
159167
.withInputType(inputPayloadFromParameterList(function.parameters))
160168
.withOutputType(outputPayloadFromExecutableElement(function))
161-
.validateAndBuild())
169+
.validateAndBuild()
170+
)
162171
} catch (e: Exception) {
163172
logger.error("Error when building handler: $e", function)
164173
}
@@ -184,7 +193,8 @@ class KElementConverter(
184193
parameterElement.type.resolve(),
185194
parameterElement.getAnnotationsByType(Json::class).firstOrNull(),
186195
parameterElement.getAnnotationsByType(Raw::class).firstOrNull(),
187-
parameterElement)
196+
parameterElement,
197+
)
188198
}
189199

190200
@OptIn(KspExperimental::class)
@@ -193,14 +203,15 @@ class KElementConverter(
193203
fn.returnType?.resolve() ?: builtIns.unitType,
194204
fn.getAnnotationsByType(Json::class).firstOrNull(),
195205
fn.getAnnotationsByType(Raw::class).firstOrNull(),
196-
fn)
206+
fn,
207+
)
197208
}
198209

199210
private fun payloadFromTypeMirrorAndAnnotations(
200211
ty: KSType,
201212
jsonAnnotation: Json?,
202213
rawAnnotation: Raw?,
203-
relatedNode: KSNode
214+
relatedNode: KSNode,
204215
): PayloadType {
205216
if (ty == builtIns.unitType) {
206217
if (rawAnnotation != null || jsonAnnotation != null) {
@@ -222,12 +233,16 @@ class KElementConverter(
222233
val qualifiedTypeName = qualifiedTypeName(ty)
223234
var serdeDecl: String =
224235
if (rawAnnotation != null) RAW_SERDE else jsonSerdeDecl(ty, qualifiedTypeName)
225-
if (rawAnnotation != null &&
226-
rawAnnotation.contentType != getAnnotationDefaultValue(Raw::class.java, "contentType")) {
236+
if (
237+
rawAnnotation != null &&
238+
rawAnnotation.contentType != getAnnotationDefaultValue(Raw::class.java, "contentType")
239+
) {
227240
serdeDecl = contentTypeDecoratedSerdeDecl(serdeDecl, rawAnnotation.contentType)
228241
}
229-
if (jsonAnnotation != null &&
230-
jsonAnnotation.contentType != getAnnotationDefaultValue(Json::class.java, "contentType")) {
242+
if (
243+
jsonAnnotation != null &&
244+
jsonAnnotation.contentType != getAnnotationDefaultValue(Json::class.java, "contentType")
245+
) {
231246
serdeDecl = contentTypeDecoratedSerdeDecl(serdeDecl, jsonAnnotation.contentType)
232247
}
233248

@@ -249,12 +264,13 @@ class KElementConverter(
249264
private fun validateMethodSignature(
250265
serviceType: ServiceType,
251266
handlerType: HandlerType,
252-
function: KSFunctionDeclaration
267+
function: KSFunctionDeclaration,
253268
) {
254269
if (function.parameters.isEmpty()) {
255270
logger.error(
256271
"The annotated method has no parameters. There must be at least the context parameter as first parameter",
257-
function)
272+
function,
273+
)
258274
}
259275
when (handlerType) {
260276
HandlerType.SHARED ->
@@ -265,15 +281,17 @@ class KElementConverter(
265281
} else {
266282
logger.error(
267283
"The annotation @Shared is not supported by the service type $serviceType",
268-
function)
284+
function,
285+
)
269286
}
270287
HandlerType.EXCLUSIVE ->
271288
if (serviceType == ServiceType.VIRTUAL_OBJECT) {
272289
validateFirstParameterType(ObjectContext::class, function)
273290
} else {
274291
logger.error(
275292
"The annotation @Exclusive is not supported by the service type $serviceType",
276-
function)
293+
function,
294+
)
277295
}
278296
HandlerType.STATELESS -> validateFirstParameterType(Context::class, function)
279297
HandlerType.WORKFLOW ->
@@ -282,17 +300,21 @@ class KElementConverter(
282300
} else {
283301
logger.error(
284302
"The annotation @Workflow is not supported by the service type $serviceType",
285-
function)
303+
function,
304+
)
286305
}
287306
}
288307
}
289308

290309
private fun validateFirstParameterType(clazz: KClass<*>, function: KSFunctionDeclaration) {
291-
if (function.parameters[0].type.resolve().declaration.qualifiedName!!.asString() !=
292-
clazz.qualifiedName) {
310+
if (
311+
function.parameters[0].type.resolve().declaration.qualifiedName!!.asString() !=
312+
clazz.qualifiedName
313+
) {
293314
logger.error(
294315
"The method signature must have ${clazz.qualifiedName} as first parameter, was ${function.parameters[0].type.resolve().declaration.qualifiedName!!.asString()}",
295-
function)
316+
function,
317+
)
296318
}
297319
}
298320

sdk-api-kotlin-gen/src/main/kotlin/dev/restate/sdk/kotlin/gen/MetaRestateAnnotation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import dev.restate.sdk.endpoint.definition.ServiceType
1414

1515
internal data class MetaRestateAnnotation(
1616
val annotationName: KSName,
17-
val serviceType: ServiceType
17+
val serviceType: ServiceType,
1818
) {
1919
fun resolveName(annotated: KSAnnotated): String? =
2020
annotated.annotations

0 commit comments

Comments
 (0)