-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP invoke * Improvements * Add fn * Update function slug --------- Co-authored-by: Tony Holdstock-Brown <[email protected]>
- Loading branch information
1 parent
cee9c49
commit 8df627e
Showing
6 changed files
with
184 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
inngest-test-server/src/main/kotlin/com/inngest/testserver/ProcessAlbum.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.inngest.testserver | ||
|
||
import com.inngest.* | ||
import java.time.Duration | ||
|
||
@FunctionConfig(id = "ProcessAlbum", name = "ProcessAlbum") | ||
@FunctionEventTrigger(event = "delivery/process.requested") | ||
class ProcessAlbum : InngestFunction() { | ||
override fun execute( | ||
ctx: FunctionContext, | ||
step: Step, | ||
): LinkedHashMap<String, Any> { | ||
|
||
// NOTE - App ID is set on the serve level | ||
val res = step.invoke<Map<String, Any>>( | ||
"restore-album", | ||
"ktor-dev", | ||
"RestoreFromGlacier", | ||
mapOf("some-arg" to "awesome"), | ||
null, | ||
|
||
) | ||
|
||
// throw NonRetriableError("Could not restore") | ||
return linkedMapOf("hello" to true) | ||
} | ||
|
||
fun isRestoredFromGlacier(temp: Int): Boolean { | ||
if (temp > 2) { | ||
return true | ||
} | ||
return false; | ||
} | ||
|
||
fun restoreFromGlacier(): String { | ||
return "FILES_RESTORED" | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
inngest-test-server/src/main/kotlin/com/inngest/testserver/RestoreFromGlacier.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.inngest.testserver | ||
|
||
import com.inngest.* | ||
import java.time.Duration | ||
|
||
@FunctionConfig(id = "RestoreFromGlacier", name = "RestoreFromGlacier") | ||
@FunctionEventTrigger(event = "delivery/restore.requested") | ||
class RestoreFromGlacier : InngestFunction() { | ||
override fun execute( | ||
ctx: FunctionContext, | ||
step: Step, | ||
): LinkedHashMap<String, Any> { | ||
|
||
step.run("restore") { | ||
if (!isRestoredFromGlacier(0)) { | ||
restoreFromGlacier() | ||
} | ||
} | ||
var i = 0 | ||
while (i < 6) { | ||
val isRestored = step.run(String.format("check-status-%d", i)) { | ||
isRestoredFromGlacier(i) | ||
} | ||
if (isRestored) { | ||
return linkedMapOf("restored" to true) | ||
} | ||
step.sleep(String.format("wait-for-restore-%d", i), Duration.ofSeconds(5)) | ||
i++ | ||
} | ||
|
||
// throw NonRetriableError("Could not restore") | ||
return linkedMapOf("restored" to false) | ||
} | ||
|
||
fun isRestoredFromGlacier(temp: Int): Boolean { | ||
if (temp > 2) { | ||
return true | ||
} | ||
return false; | ||
} | ||
|
||
fun restoreFromGlacier(): String { | ||
return "FILES_RESTORED" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters