-
Notifications
You must be signed in to change notification settings - Fork 2
Add CheckpointingFileDataSupplier - can lock DSL values #31
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
base: master
Are you sure you want to change the base?
Add CheckpointingFileDataSupplier - can lock DSL values #31
Conversation
| import net.devslash.err.RetryOnTransitiveError | ||
| import java.time.Duration | ||
| import java.util.* | ||
| import kotlin.reflect.KMutableProperty0 |
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.
snip
|
|
||
| dependencies { | ||
| implementation(kotlin("stdlib", kotlinVersion)) | ||
| implementation(kotlin("reflect", kotlinVersion)) |
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.
snip?
| ) | ||
| } | ||
|
|
||
| fun <T> lock(field: KMutableProperty0<RequestDataSupplier<T>?>) { |
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.
document
| /** | ||
| * 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 |
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.
data class -> value class
| } | ||
| } | ||
|
|
||
| class AlreadySetException2 : |
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.
snip
| @DSLLockedValue | ||
| class ProtectedDS<T>(val ds: RequestDataSupplier<T>) : RequestDataSupplier<T> { | ||
| override suspend fun getDataForRequest(): RequestData? = ds.getDataForRequest() | ||
| } No newline at end of file |
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.
line
| } | ||
| call<Int>(address) { | ||
| data = ListDataSupplier(listOf(1, 2, 3)) | ||
| lock(this::data) |
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.
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.
|
|
|
||
| internal class LockableValueTest { | ||
|
|
||
| // What i can do is have `lock` as a |
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.
snip
| x = null | ||
| assertThat(x, `is`(nullValue())) | ||
| } | ||
| } No newline at end of file |
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.
fix
| val rd = supplier.getDataForRequest()!! | ||
| val rd2 = supplier.getDataForRequest()!! | ||
|
|
||
| runHttp { |
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.
fix
Fixes #17