Skip to content

Commit

Permalink
feat(sql): Support ENTITY_TAGS writes to primary and previous storage…
Browse files Browse the repository at this point in the history
… services

feat(sql): Support ENTITY_TAGS reads against primary

This removes the last bit of special casing of ENTITY_TAGS and how we
read/write them.
  • Loading branch information
ajordens committed Jul 8, 2019
1 parent d880dbb commit afdc6f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ class CompositeStorageService(
}

override fun <T : Timestamped?> loadObject(objectType: ObjectType?, objectKey: String?): T {
if (objectType == ObjectType.ENTITY_TAGS) {
// entity tags are currently unsupported in SQL
return previous.loadObject<T>(objectType, objectKey)
}

var exception: Exception? = null

if (isPrimaryReadEnabled()) {
Expand All @@ -105,11 +100,6 @@ class CompositeStorageService(
}

override fun <T : Timestamped?> loadObjects(objectType: ObjectType, objectKeys: List<String>): List<T> {
if (objectType == ObjectType.ENTITY_TAGS) {
// entity tags are currently unsupported in SQL
return previous.loadObjects<T>(objectType, objectKeys)
}

var exception: Exception? = null

if (isPrimaryReadEnabled()) {
Expand Down Expand Up @@ -156,10 +146,7 @@ class CompositeStorageService(
}

try {
if (objectType != ObjectType.ENTITY_TAGS) {
// entity tags are currently unsupported in SQL
primary.storeObject(objectType, objectKey, item)
}
primary.storeObject(objectType, objectKey, item)
} catch (e: Exception) {
log.error(
"{}.storeObject({}, {}) failed",
Expand All @@ -174,10 +161,6 @@ class CompositeStorageService(
}

override fun listObjectKeys(objectType: ObjectType?): Map<String, Long> {
if (objectType == ObjectType.ENTITY_TAGS) {
return previous.listObjectKeys(objectType)
}

val objectKeys = mutableMapOf<String, Long>()

if (isPreviousReadEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,22 @@ internal object CompositeStorageServiceTests : JUnit5Minutests {
}

context("loadObject()") {
test("should always load EntityTags from 'previous'") {
test("should always load EntityTags from 'primary'") {
every {
previous.loadObject<EntityTags>(ObjectType.ENTITY_TAGS, "id-entitytags001")
primary.loadObject<EntityTags>(ObjectType.ENTITY_TAGS, "id-entitytags001")
} returns EntityTags().apply { id = "id-entitytags001" }

every {
dynamicConfigService.getConfig(Boolean::class.java, any(), any())
} returns true

expectThat(
subject.loadObject<EntityTags>(ObjectType.ENTITY_TAGS, "id-entitytags001").id
).isEqualTo("id-entitytags001")

verifyAll {
primary wasNot Called
previous.loadObject<Timestamped>(ObjectType.ENTITY_TAGS, "id-entitytags001")
primary.loadObject<Timestamped>(ObjectType.ENTITY_TAGS, "id-entitytags001")
previous wasNot Called
}
}

Expand Down

0 comments on commit afdc6f7

Please sign in to comment.