Skip to content

Commit

Permalink
Align RootActorStarter with new configurable extension approach
Browse files Browse the repository at this point in the history
Signed-off-by: Yannic Klem <yannic.klem@bosch.io>
  • Loading branch information
Yannic92 committed Jul 8, 2022
1 parent a0a343a commit a10f6c5
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 14 deletions.
Expand Up @@ -402,7 +402,8 @@ protected void startServiceRootActors(final ActorSystem actorSystem, final C ser
injectSystemPropertiesLimits(serviceSpecificConfig);

startMainRootActor(actorSystem, getMainRootActorProps(serviceSpecificConfig, pubSubMediator));
RootActorStarter.get(actorSystem).execute();
RootActorStarter.get(actorSystem, ScopedConfig.getOrEmpty(actorSystem.settings().config(), "ditto"))
.execute();
});
}

Expand Down
Expand Up @@ -14,6 +14,9 @@

import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

import akka.actor.ActorSystem;

/**
Expand All @@ -33,21 +36,33 @@ public interface RootActorStarter extends DittoExtensionPoint {
* {@code ActorSystem}.
*
* @param actorSystem the actorSystem in which the {@code RootActorStarter} should be loaded.
* @param config the configuration of this extension.
* @return the {@code RootActorStarter} implementation.
* @throws NullPointerException if {@code actorSystem} is {@code null}.
*/
static RootActorStarter get(final ActorSystem actorSystem) {
static RootActorStarter get(final ActorSystem actorSystem, final Config config) {
checkNotNull(actorSystem, "actorSystem");
return ExtensionId.INSTANCE.get(actorSystem);
checkNotNull(config, "config");
final var extensionIdConfig = ExtensionId.computeConfig(config);
return DittoExtensionIds.get(actorSystem)
.computeIfAbsent(extensionIdConfig, ExtensionId::new)
.get(actorSystem);
}

final class ExtensionId extends DittoExtensionPoint.ExtensionId<RootActorStarter> {

private static final String CONFIG_PATH = "ditto.root-actor-starter";
private static final ExtensionId INSTANCE = new ExtensionId(RootActorStarter.class);
private static final String CONFIG_KEY = "root-actor-starter";
private static final String CONFIG_PATH = "ditto.extensions." + CONFIG_KEY;

private ExtensionId(final ExtensionIdConfig<RootActorStarter> extensionIdConfig) {
super(extensionIdConfig);
}

private ExtensionId(final Class<RootActorStarter> parentClass) {
super(parentClass);
static ExtensionIdConfig<RootActorStarter> computeConfig(final Config config) {
return ExtensionIdConfig.of(
RootActorStarter.class,
config.hasPath(CONFIG_KEY) ? config.getConfig(CONFIG_KEY) : ConfigFactory.empty()
);
}

@Override
Expand Down
9 changes: 7 additions & 2 deletions base/service/src/main/resources/reference.conf
@@ -1,3 +1,8 @@
ditto.extensions.root-child-actor-starter = {
extension-class = org.eclipse.ditto.base.service.NoOpRootChildActorStarter
ditto.extensions {
root-actor-starter = {
extension-class = org.eclipse.ditto.base.service.NoOpRootActorStarter
}
root-child-actor-starter = {
extension-class = org.eclipse.ditto.base.service.NoOpRootChildActorStarter
}
}
1 change: 0 additions & 1 deletion connectivity/service/src/main/resources/connectivity.conf
@@ -1,6 +1,5 @@
ditto {
service-name = "connectivity"
root-actor-starter = "org.eclipse.ditto.base.service.NoOpRootActorStarter"

pre-enforcers = [
"org.eclipse.ditto.policies.enforcement.pre.CommandWithOptionalEntityPreEnforcer",
Expand Down
1 change: 0 additions & 1 deletion gateway/service/src/main/resources/gateway.conf
Expand Up @@ -16,7 +16,6 @@ ditto {
}

service-name = "gateway"
root-actor-starter = "org.eclipse.ditto.base.service.NoOpRootActorStarter"
mapping-strategy.implementation = "org.eclipse.ditto.gateway.service.util.GatewayMappingStrategies"

signal-enrichment {
Expand Down
1 change: 0 additions & 1 deletion policies/service/src/main/resources/policies.conf
@@ -1,7 +1,6 @@
ditto {
service-name = "policies"
mapping-strategy.implementation = "org.eclipse.ditto.policies.api.PoliciesMappingStrategies"
root-actor-starter = "org.eclipse.ditto.base.service.NoOpRootActorStarter"
existence-checker = "org.eclipse.ditto.policies.enforcement.pre.PolicyExistenceChecker"

pre-enforcers = [
Expand Down
1 change: 0 additions & 1 deletion things/service/src/main/resources/things.conf
@@ -1,7 +1,6 @@
ditto {
service-name = "things"
mapping-strategy.implementation = "org.eclipse.ditto.things.api.ThingsMappingStrategies"
root-actor-starter = "org.eclipse.ditto.base.service.NoOpRootActorStarter"
existence-checker = "org.eclipse.ditto.things.service.enforcement.ThingExistenceChecker"

pre-enforcers = [
Expand Down
1 change: 0 additions & 1 deletion thingsearch/service/src/main/resources/search.conf
@@ -1,7 +1,6 @@
ditto {
service-name = "search"
mapping-strategy.implementation = "org.eclipse.ditto.thingsearch.api.ThingSearchMappingStrategies"
root-actor-starter = "org.eclipse.ditto.base.service.NoOpRootActorStarter"

pre-enforcers = []

Expand Down

0 comments on commit a10f6c5

Please sign in to comment.