Skip to content

Commit

Permalink
OAP-105 Remove direct disabling OAP dependecies
Browse files Browse the repository at this point in the history
  • Loading branch information
nofateg authored Mar 26, 2024
1 parent 0091912 commit e315678
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ services {
}
fake-param1 {
implementation = ...
enabled = false
profile = disabled
link {
consructorParameter = <modules.this.some-service>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void mapWithEntries() {
public void mapEnvToConfig() {
var modules = List.of( url( "env/env.conf" ) );

Env.set( "CONFIG.services.env.s1.enabled", "false" );
Env.set( "CONFIG.services.env.s1.profile", "disabled" );
Env.set( "CONFIG.services.env.s2.parameters.val", "\"test$value\"" );

try( var kernel = new Kernel( modules ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
link {
tis = <modules.this.m>
}
enabled = false
profile = disabled
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ti2 {
implementation = oap.application.KernelLinkImplementationsTest.TestInterfaceImpl2
link.tis = <modules.field-references.m>
enabled = false
profile = disabled
supervision.supervise = true
}
ti3 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
s2 {
implementation = oap.application.ServiceOne
enabled = false
profile = disabled
parameters {
i = 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
s3 {
implementation = oap.application.ServiceOne
enabled = false
profile = disabled
parameters {
i = 3
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ private static void initServices( ModuleItemTree map, LinkedHashSet<String> prof
enabled = ServiceEnabledStatus.DISABLED_BY_PROFILE;
}

if( !service.enabled ) {
log.debug( "skipping service {}:{}, reason: enabled = false", moduleInfo.module.name, serviceName );
enabled = ServiceEnabledStatus.DISABLED_BY_FLAG;
}

moduleInfo.services.put( serviceName, new ModuleItem.ServiceItem( serviceName, moduleInfo, service, enabled ) );
}
}
Expand Down Expand Up @@ -309,8 +304,8 @@ private static void validateModuleDeps( ModuleItemTree map ) throws ApplicationE
for( var dModuleInfo : moduleInfo.getDependsOn().values() ) {
if( !dModuleInfo.moduleItem.isEnabled() ) {
throw new ApplicationException( "[" + moduleInfo.module.name + ":*] dependencies are not enabled."
+ " [" + dModuleInfo.moduleItem.module.name + "] is disabled by "
+ dModuleInfo.moduleItem.getEnabled().toString() + "." );
+ " [" + dModuleInfo.moduleItem.module.name + "] is disabled by "
+ dModuleInfo.moduleItem.getEnabled().toString() + "." );
}
}
}
Expand Down Expand Up @@ -339,7 +334,7 @@ private static void validateServiceDeps( ModuleItemTree map ) throws Application
for( var dServiceReference : serviceInfo.dependsOn ) {
if( !dServiceReference.serviceItem.isEnabled() && dServiceReference.required ) {
throw new ApplicationException( "[" + moduleInfo.module.name + ":" + serviceInfo.service.name + "] dependencies are not enabled. Required service [" + dServiceReference.serviceItem.serviceName + "] is disabled by "
+ dServiceReference.serviceItem.enabled.toString() + "." );
+ dServiceReference.serviceItem.enabled.toString() + "." );
}
}
}
Expand Down Expand Up @@ -459,11 +454,11 @@ private static void initDeps( ModuleItemTree map, LinkedHashSet<String> profiles
private static void initModuleDeps( ModuleItemTree map, LinkedHashSet<String> profiles ) {
for( var moduleItem : map.values() ) {
for( var d : moduleItem.module.dependsOn ) {
if ( !KernelHelper.profileEnabled( d.profiles, profiles ) ) {
if( !KernelHelper.profileEnabled( d.profiles, profiles ) ) {
log.trace( "[module#{}]: skip dependsOn {}, module profiles are not enabled", moduleItem.module.name, new LinkedHashSet<ModuleItem>() );
continue;
}
ModuleItem dModule = map.findModule( moduleItem, d.name );
ModuleItem dModule = map.findModule( moduleItem, d.name );
if( !dModule.isEnabled() ) {
log.trace( "[module#{}]: skip dependsOn {}, module is not enabled", moduleItem.module.name, new LinkedHashSet<ModuleItem>() );
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

public enum ServiceEnabledStatus {
ENABLED( "enabled" ),
DISABLED_BY_PROFILE( "profile" ),
DISABLED_BY_FLAG( "'enabled' flag" );
DISABLED_BY_PROFILE( "profile" );

final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class Service {
public String implementation;
public String name;
public RemoteLocation remote;
public boolean enabled = true;
@JsonIgnore
public LinkedHashMap<String, Object> ext = new LinkedHashMap<>();

Expand Down
44 changes: 44 additions & 0 deletions oap-http/oap-remote/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>oap</groupId>
<artifactId>oap-http-parent</artifactId>
<version>${oap.project.version}</version>
</parent>

<artifactId>oap-remote</artifactId>

<dependencies>
<dependency>
<groupId>oap</groupId>
<artifactId>oap-stdlib</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>oap</groupId>
<artifactId>oap-http</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>oap</groupId>
<artifactId>oap-stdlib-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>oap</groupId>
<artifactId>oap-application-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>
11 changes: 11 additions & 0 deletions oap-http/oap-remote/src/main/java/oap/remote/RemoteServices.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package oap.remote;

import java.util.List;

public interface RemoteServices {
Object get( String name );

int count();

List<String> keySet();
}
1 change: 1 addition & 0 deletions oap-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
<module>oap-http-prometheus</module>
<module>oap-pnio</module>
<module>oap-http-test</module>
<module>oap-remote</module>
</modules>
</project>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</distributionManagement>

<properties>
<oap.project.version>21.17.4</oap.project.version>
<oap.project.version>21.18.0</oap.project.version>

<oap.deps.config.version>21.0.0</oap.deps.config.version>
<oap.deps.oap-teamcity.version>21.0.1</oap.deps.oap-teamcity.version>
Expand Down

0 comments on commit e315678

Please sign in to comment.