Add CheckpointingFileDataSupplier - can lock DSL values#31
Open
devslash-paul wants to merge 1 commit intomasterfrom
Open
Add CheckpointingFileDataSupplier - can lock DSL values#31devslash-paul wants to merge 1 commit intomasterfrom
devslash-paul wants to merge 1 commit intomasterfrom
Conversation
devslash-paul
commented
Jun 28, 2021
| import net.devslash.err.RetryOnTransitiveError | ||
| import java.time.Duration | ||
| import java.util.* | ||
| import kotlin.reflect.KMutableProperty0 |
devslash-paul
commented
Jun 28, 2021
|
|
||
| dependencies { | ||
| implementation(kotlin("stdlib", kotlinVersion)) | ||
| implementation(kotlin("reflect", kotlinVersion)) |
devslash-paul
commented
Jun 28, 2021
| ) | ||
| } | ||
|
|
||
| fun <T> lock(field: KMutableProperty0<RequestDataSupplier<T>?>) { |
devslash-paul
commented
Jun 28, 2021
| /** | ||
| * Lockable value is a delegate pattern that allows for a marker annotation to be used to lock. | ||
| * | ||
| * Doesn't work on primitives. If you want it to work on a primitive, then wrap it in a data class for now |
Owner
Author
There was a problem hiding this comment.
data class -> value class
devslash-paul
commented
Jun 28, 2021
| } | ||
| } | ||
|
|
||
| class AlreadySetException2 : |
devslash-paul
commented
Jun 28, 2021
| @DSLLockedValue | ||
| class ProtectedDS<T>(val ds: RequestDataSupplier<T>) : RequestDataSupplier<T> { | ||
| override suspend fun getDataForRequest(): RequestData? = ds.getDataForRequest() | ||
| } No newline at end of file |
devslash-paul
commented
Jun 28, 2021
| } | ||
| call<Int>(address) { | ||
| data = ListDataSupplier(listOf(1, 2, 3)) | ||
| lock(this::data) |
Owner
Author
There was a problem hiding this comment.
change to specific example
Codecov Report
@@ Coverage Diff @@
## master #31 +/- ##
============================================
+ Coverage 69.64% 71.57% +1.93%
- Complexity 93 95 +2
============================================
Files 30 30
Lines 481 482 +1
Branches 70 70
============================================
+ Hits 335 345 +10
+ Misses 103 94 -9
Partials 43 43
Continue to review full report at Codecov.
|
devslash-paul
commented
Jun 28, 2021
|
|
||
| internal class LockableValueTest { | ||
|
|
||
| // What i can do is have `lock` as a |
devslash-paul
commented
Jun 28, 2021
| x = null | ||
| assertThat(x, `is`(nullValue())) | ||
| } | ||
| } No newline at end of file |
devslash-paul
commented
Jun 28, 2021
| val rd = supplier.getDataForRequest()!! | ||
| val rd2 = supplier.getDataForRequest()!! | ||
|
|
||
| runHttp { |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17