-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add Java and Kotlin code snippets to all use case pages #437
Conversation
Deploying documentation with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looked at the code, looks good except some minor things here and there
@Handler | ||
suspend fun run(ctx: Context, task: Task): Result { | ||
val subTasks: Array<SubTask> = | ||
ctx.runBlock (KtSerdes.json<Array<SubTask>>()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to remove the explicit type either here or on the val declaration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, you can simply remove the serde here, it's implicit
split(task) | ||
} | ||
|
||
val resultFutures: MutableList<Awaitable<SubTaskResult>> = ArrayList() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val resultFutures: MutableList<Awaitable<SubTaskResult>> = ArrayList() | |
val resultFutures: MutableList<Awaitable<SubTaskResult>> = mutableListOf() |
val result: String = rs | ||
.invocationHandle( | ||
handle.invocationId, | ||
KtSerdes.json<String>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about type inference as above
|
||
suspend fun downloadData(userId: String, email: Email) { | ||
// <mark_1> | ||
val client: IngressClient = DataPreparationServiceClient.fromClient(rs, userId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove the type annotation IngressClient
here?
CompletableFuture.anyOf(client.workflowHandle().attachAsync()) | ||
.orTimeout(30, TimeUnit.SECONDS) | ||
.join() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use kotlin stuff for this, not CompletableFuture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the client methods have a variant suspend
, e.g. attachSuspend
, which you import from dev.restate.sdk.kotlin
. For timeouts: https://kotlinlang.org/docs/cancellation-and-timeouts.html#timeout
ctx.sleep(5000.milliseconds) | ||
// </mark_2> | ||
// <mark_3> | ||
userId = ctx.runBlock(KtSerdes.json<String>()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to provide serde, it's implicit
|
||
// <mark_3> | ||
val previousRole: UserRole = ctx.runBlock( | ||
KtSerdes.json<UserRole>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove serde
try { | ||
// <mark_3> | ||
val previous: Permission = ctx.runBlock ( | ||
KtSerdes.json<Permission>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove serde
ctx.runBlock { tryApplyUserRole(update.userId, update.role) } | ||
// </mark_3> | ||
|
||
val previousPermissions = ArrayList<Permission>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val previousPermissions = ArrayList<Permission>() | |
val previousPermissions = mutableListOf<Permission>() |
// <mark_1> | ||
ProductServiceClient.fromClient(rs, productId) | ||
.send() | ||
.reserve(DEFAULT.withIdempotency(reservationId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use qualified name, it helps understanding this without reading the import:
.reserve(DEFAULT.withIdempotency(reservationId)); | |
.reserve(CallRequestOptions.DEFAULT.withIdempotency(reservationId)); |
@slinkydeveloper reviewing the code snippets is enough. Especially Kotlin.