Repository navigation
env 6.1.1 — data helpers on RedisSystem, public ResettableRedisRemote - #13
Merged
Merged
Conversation
…emote keys/type/del/exists/getMap/setMap/getList/setList/get/set move from RedisContainerSystem to RedisSystem as default methods built on exec(), so specs use env<RedisSystem>() the same way against a container and a remote Redis. ResettableRedisRemote.exec() selects env.redis.database on every call; its keys() hides the __ns_owner__ marker. resettableRedis() now returns RedisSystem (no cast); the 5.6.2 JVM signature returning ExternalSystem is kept as a hidden bridge. ResettableRedisRemoteTest runs against Testcontainers, or against a running Redis with ENV_REMOTE=true (TEST_REDIS_HOST/PORT/DB). Co-Authored-By: Claude Code <noreply@anthropic.com>
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.
Forward-port of #12 (released as 5.6.3 from
release/5.6.x) to the 6.x line, bumped to 6.1.1. Cherry-picked cleanly onto 6.1.0;:env-redis:compileTestKotlinpasses locally on Testcontainers 2.What
RedisSystemgainsexec(f: (KredsClient) -> T)and default data helpers built on it:keys(pattern, vararg types),type,del,exists(vararg),exists(key),getMap,setMap(key, field, value),setMap(key, map),getList(key, start, stop),setList,get,set.Signatures and behaviour are the ones
RedisContainerSystemhad; it now only overridesexecandclean.ResettableRedisRemoteis public. Itsexecopens a client and runsSELECT env.redis.databasebefore every call, so every helper stays inside its own logical database.
keys()hides the__ns_owner__marker thatstart()writes, so a spec sees the same key set as against a container.start()andclean()go through the sameexec.resettableRedis(props)now returnsRedisSystem— noas RedisSystemcast needed.Why
In the shared test stack, specs run against a Redis sidecar via
resettableRedis(props). Up to 5.6.2 itcould only do
clean(), while MD specs callkeys(),getMap(),setMap()that existed only onRedisContainerSystem. As a result every repo wrote its ownRoomRediswrapper(quotes/dataflow, securities-api, md-cbonds-quotes). With 5.6.3 specs use
env<RedisSystem>()and thesame calls work in CI (container) and in the room (remote).
Compatibility
RedisContainerSystemhelpers compile unchanged (same names, defaults,return types;
del/exists(vararg)/getList/setListnow declare the types they already returned).ResettableRedisRemoteKt.resettableRedis(Map): ExternalSystemis kept as ahidden bridge; the new Kotlin-visible function is compiled as
resettableRedisSystem(checked withjavap).Callers compiled against 5.6.2 keep linking; on recompile they get the
RedisSystemreturn type.RedisContainerSystem.keys$default/getList$defaultmoved to
RedisSystem$DefaultImpls. A jar compiled against 5.6.2 that callskeys()/getList(key)without arguments would get
NoSuchMethodErroruntil recompiled. Specs are always recompiled; noprecompiled consumer was found in the platform jars.
How it was tested
ResettableRedisRemoteTest— one test per helper plus "writes/reads its own db, db 0 untouched",resettableRedis()returnsRedisSystem,execruns in its own db; the 3 existing start/clean tests kept.Testcontainers Redis by default; with
ENV_REMOTE=trueit uses a running Redis(
TEST_REDIS_HOST/TEST_REDIS_PORT, defaultredis:6379, dbTEST_REDIS_DB), touching db 0 only with auniquely named guard key that it removes afterwards.
./gradlew :env-redis:test --tests redis.ResettableRedisRemoteTestwithENV_REMOTE=trueagainstthe shared-stack Redis — 12/12 passed, 0 skipped (twice).
:env-redis:detekt :env-redis:ktlint :env-redis:compileTestKotlin :example:compileTestKotlin— green.RedisContainerSystemTestand the Testcontainers branch ofResettableRedisRemoteTest—there was no Docker on the machine (
/var/run/docker.sockmissing). GitHub Actions CI (./gradlew build) covers them.🤖 Generated with Claude Code
🤖 Generated with Claude Code