Skip to content
Snippets Groups Projects
Commit 2dc38542 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4606 fix configuration

parent 532ca30c
No related branches found
No related tags found
No related merge requests found
package de.ozgcloud.client.autoconfigure;
import lombok.Builder;
import lombok.Getter;
import net.devh.boot.grpc.client.config.GrpcChannelProperties;
import net.devh.boot.grpc.client.config.GrpcChannelsProperties;
import net.devh.boot.grpc.client.config.NegotiationType;
@Builder
@Getter
public class GrpcChannelConfigurator {
private String clientName;
private String address;
private NegotiationType negotiationType;
public void addToProperties(GrpcChannelsProperties properties) {
var clientMap = properties.getClient();
var channelProps = new GrpcChannelProperties();
channelProps.setAddress(address);
channelProps.setNegotiationType(negotiationType);
clientMap.put(clientName, channelProps);
}
}
package de.ozgcloud.client.autoconfigure; package de.ozgcloud.client.autoconfigure;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
...@@ -48,6 +49,7 @@ public class OzgCloudClientAutoConfiguration { ...@@ -48,6 +49,7 @@ public class OzgCloudClientAutoConfiguration {
private static final String CLIENT_NAME_VORGANG_MANAGER = "vorgang-manager"; private static final String CLIENT_NAME_VORGANG_MANAGER = "vorgang-manager";
private static final String CLIENT_NAME_FILE_MANAGER = "file-manager"; private static final String CLIENT_NAME_FILE_MANAGER = "file-manager";
private static final String CLIENT_NAME_COMMAND_MANAGER = "command-manager"; private static final String CLIENT_NAME_COMMAND_MANAGER = "command-manager";
private static final String CLIENT_NAME_USER_MANAGER = "user-manager";
@Autowired @Autowired
private OzgCloudVorgangManagerProperties vorgangManagerProperties; private OzgCloudVorgangManagerProperties vorgangManagerProperties;
...@@ -55,6 +57,8 @@ public class OzgCloudClientAutoConfiguration { ...@@ -55,6 +57,8 @@ public class OzgCloudClientAutoConfiguration {
private OzgCloudFileManagerProperties fileManagerProperties; private OzgCloudFileManagerProperties fileManagerProperties;
@Autowired @Autowired
private OzgCloudCommandManagerProperties commandManagerProperties; private OzgCloudCommandManagerProperties commandManagerProperties;
@Autowired
private OzgCloudUserManagerProperties userManagerProperties;
// @Bean // @Bean
// @ConditionalOnProperty("ozgcloud.vorgang-manager.address") // @ConditionalOnProperty("ozgcloud.vorgang-manager.address")
...@@ -71,10 +75,27 @@ public class OzgCloudClientAutoConfiguration { ...@@ -71,10 +75,27 @@ public class OzgCloudClientAutoConfiguration {
@Bean @Bean
@ConditionalOnProperty("ozgcloud.command-manager.address") @ConditionalOnProperty("ozgcloud.command-manager.address")
GrpcChannelsProperties commandProperties() { GrpcChannelConfigurator commandProperties() {
return GrpcChannelConfigurator.builder()
.clientName(CLIENT_NAME_COMMAND_MANAGER)
.address(commandManagerProperties.getAddress())
.negotiationType(commandManagerProperties.getNegotiationType())
.build();
}
GrpcChannelConfigurator userManagerProperties() {
return GrpcChannelConfigurator.builder()
.clientName(CLIENT_NAME_USER_MANAGER)
.address(userManagerProperties.getAddress())
.negotiationType(userManagerProperties.getNegotiationType())
.build();
}
@Bean
GrpcChannelsProperties clientProperties(Collection<GrpcChannelConfigurator> configurators) {
var properties = new GrpcChannelsProperties(); var properties = new GrpcChannelsProperties();
var clientMap = properties.getClient(); configurators.stream().forEach(configurator -> configurator.addToProperties(properties));
addCommandManager(clientMap);
return properties; return properties;
} }
...@@ -163,4 +184,11 @@ public class OzgCloudClientAutoConfiguration { ...@@ -163,4 +184,11 @@ public class OzgCloudClientAutoConfiguration {
AlfaService alfaService() { AlfaService alfaService() {
return new DummyAlfaService(); return new DummyAlfaService();
} }
@Bean
@ConditionalOnProperty("ozgcloud.user-manager.address")
OzgCloudUserProfileService grpcOzgCloudUserProfileService(@GrpcClient("user-manager") UserProfileServiceBlockingStub grpcStub,
UserProfileMapper mapper) {
return new GrpcOzgCloudUserProfileService(grpcStub, mapper);
}
} }
package de.ozgcloud.client.autoconfigure;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import lombok.Getter;
import lombok.Setter;
import net.devh.boot.grpc.client.config.NegotiationType;
@Getter
@Setter
@Configuration
@ConfigurationProperties("ozgcloud.user-manager")
public class OzgCloudUserManagerProperties {
/**
* Network-Address of the User-Manager instance, starting with resolving
* protocoll.
*/
private String address;
/**
* Negotiation Type for the gRPC connection - possible Values: PLAINTEXT, TLS
*/
private NegotiationType negotiationType = NegotiationType.valueOf("TLS");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment