Skip to content
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

feat: component exclusion config #128

Merged
merged 10 commits into from
Jan 9, 2025
Merged

Conversation

aludwiko
Copy link
Contributor

@aludwiko aludwiko commented Jan 9, 2025

No description provided.

@@ -354,6 +355,16 @@ private final class Sdk(
}
}

private def isNotExcluded(clz: Class[_]): Boolean = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we avoid double negation here?
isExcluded and then

componentClasses
    .filter(hasComponentId)
    .filterNot(isExcluded)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, filterNot(i => !i.isNotExcluded) 😄

@@ -546,6 +558,7 @@ private final class Sdk(
private val viewDescriptors: Seq[SpiViewDescriptor] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't viewDescriptors covered by above foreach in the same way as other components?
as it is now, views will be logged as "Unknown component"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -546,6 +558,7 @@ private final class Sdk(
private val viewDescriptors: Seq[SpiViewDescriptor] =
componentClasses
.filter(hasComponentId)
.filter(isNotExcluded)
.collect {
case clz if classOf[View].isAssignableFrom(clz) => ViewDescriptorFactory(clz, serializer, sdkExecutionContext)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about HttpEndpoints? shouldn't those also be possible to exclude?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, added filtering there

@aludwiko aludwiko requested a review from patriknw January 9, 2025 10:54
# Conflicts:
#	akka-javasdk/src/main/scala/akka/javasdk/impl/SdkRunner.scala
Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

@@ -1,2 +1,4 @@
# Using a different port to not conflict with parallel tests
akka.javasdk.testkit.http-port = 39391
akka.javasdk.profiles.active = test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profile leftover

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@@ -36,4 +38,5 @@ private[impl] object Settings {
private[impl] final case class Settings(
cleanupDeletedEventSourcedEntityAfter: Duration,
cleanupDeletedKeyValueEntityAfter: Duration,
devModeSettings: Option[DevModeSettings])
devModeSettings: Option[DevModeSettings],
excludedComponents: Seq[String])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set instead of Seq

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

httpPort = sdkConfig.getInt("dev-mode.http-port"))))
httpPort = sdkConfig.getInt("dev-mode.http-port"))),
excludedComponents =
Option(sdkConfig.getString("components.exclude")).fold(Seq.empty[String])(_.split(",").toSeq))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this Option fold needed? shouldn't be null as far as I can see

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be good to .map(_.trim) the values in case they use space in the config

exclude = "akkajavasdk.components.keyvalueentities.user.ProdCounterEntity, akkajavasdk.components.keyvalueentities.user.StageCounterEntity"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, initially, I wanted to add protection against a null case, good hint with trim, added

@@ -92,4 +92,6 @@ akka.javasdk {
collector-endpoint = ${?COLLECTOR_ENDPOINT}
}
}
# The comma separated list of FQCNs of components to exclude from running
components.exclude = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be exclude or disable?
Both are good of course. I'm just trying to imagine if one is easier to understand then the other.

If we say exclude will people ask: exclude from what?
I don't know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disable or disabled ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disable as in imperative tense. Like in exclude.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Copy link
Member

@octonato octonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I left a comment earlier. No strong opinion. I just wanted to iterate once more on the names. Fine for merge with 'exclude' as well.

@@ -354,6 +355,16 @@ private final class Sdk(
}
}

private def isExcluded(clz: Class[_]): Boolean = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDisabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -1,2 +1,3 @@
# Using a different port to not conflict with parallel tests
akka.javasdk.testkit.http-port = 39391
akka.javasdk.components.disabled = "akkajavasdk.components.keyvalueentities.user.ProdCounterEntity,akkajavasdk.components.keyvalueentities.user.StageCounterEntity"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used by any test? it is wrong.
disabled vs disable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed :) fixed

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@patriknw patriknw merged commit b5a4c30 into java-spi Jan 9, 2025
22 checks passed
@patriknw patriknw deleted the component-exclusion-config branch January 9, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants