Skip to content

Commit

Permalink
Merge pull request #261 from art-community/feature/many-fixes
Browse files Browse the repository at this point in the history
Bugfixes & Refactoring
  • Loading branch information
mizantrop2397 authored Mar 25, 2020
2 parents 0f77067 + 25a781e commit 6dbdad7
Show file tree
Hide file tree
Showing 88 changed files with 932 additions and 662 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import lombok.experimental.*;
import ru.art.config.*;
import ru.art.config.exception.*;
import ru.art.core.annotation.*;
import static java.util.Collections.*;
import static java.util.Objects.isNull;
import static java.util.function.Function.*;
Expand All @@ -36,7 +35,6 @@
import java.util.*;
import java.util.function.*;

@PublicApi
@UtilityClass
public class ConfigExtensions {
public static String configString(String sectionId, String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,39 @@
package ru.art.config.extensions.activator;

import lombok.experimental.*;
import org.apache.logging.log4j.*;
import ru.art.config.extensions.provider.*;
import ru.art.config.remote.provider.*;
import ru.art.core.annotation.*;
import ru.art.core.configuration.ContextInitialConfiguration.*;
import ru.art.core.context.*;
import static java.text.MessageFormat.*;
import static ru.art.config.ConfigProvider.*;
import static ru.art.config.module.ConfigModule.*;
import static ru.art.config.remote.constants.RemoteConfigLoaderConstants.*;
import static ru.art.config.remote.provider.RemoteConfigProvider.*;
import static ru.art.core.checker.CheckerForEmptiness.*;
import static ru.art.core.constants.ContextConstants.*;
import static ru.art.core.context.Context.*;
import static ru.art.core.wrapper.ExceptionWrapper.*;
import static ru.art.logging.LoggingModule.*;

@PublicApi
@UtilityClass
public class AgileConfigurationsActivator {
public static Context useAgileConfigurations(String mainModuleId) {
ApplicationContextConfiguration configuration = new ApplicationContextConfiguration(mainModuleId, new AgileConfigurationProvider());
Context context = initContext(configuration);
ignoreException(RemoteConfigProvider::useRemoteConfigurations);
loggingModule()
.getLogger(AgileConfigurationsActivator.class)
.info(format(CONFIGURATION_MODE, configModuleState().configurationMode()));
useRemoteConfigurations();
Logger logger = loggingModule().getLogger(AgileConfigurationsActivator.class);
logger.info(format(CONFIGURATION_MODE, configModuleState().configurationMode()));
switch (configModuleState().configurationMode()) {
case FILE:
String configUrl = configUrl();
if (isEmpty(configUrl)) {
loggingModule()
.getLogger(AgileConfigurationsActivator.class)
.warn(CONFIGURATION_FILE_NOT_EXISTS);
logger.warn(CONFIGURATION_FILE_NOT_EXISTS);
return context;
}
loggingModule()
.getLogger(AgileConfigurationsActivator.class)
.info(format(CONFIGURATION_FILE_URL, configUrl));
logger.info(format(CONFIGURATION_FILE_URL, configUrl));
return context;
case REMOTE:
loggingModule()
.getLogger(AgileConfigurationsActivator.class)
.info(format(REMOTE_CONFIGURATION_PROPERTIES, configModuleState().remoteConfigProperties()));
logger.info(format(REMOTE_CONFIGURATION_PROPERTIES, configModuleState().remoteConfigProperties()));
return context;
}
return context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
package ru.art.config.extensions.grpc;

import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.grpc.GrpcConfigKeys.*;

@PublicApi
public class GrpcConfigProvider {
public static Config grpcServerConfig() {
return configInner(GRPC_SERVER_CONFIG_SECTION_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.http.HttpConfigKeys.*;

@PublicApi
@UtilityClass
public class HttpConfigProvider {
public static Config httpServerConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@Getter
public class HttpServerAgileConfiguration extends HttpServerModuleDefaultConfiguration {
private final Map<MimeType, HttpContentMapper> contentMappers = configureHttpContentMappers(super.getContentMappers());
private final Logbook logbook = logbookWithoutResourceLogs(logbookWithoutMetricsLogs()).build();
private final Logbook logbook = logbookWithoutResourceLogs(logbookWithoutMetricsLogs(this::isEnableValueTracing), this::isEnableValueTracing).build();
private int port;
private String path;
private int maxThreadsCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.kafka.KafkaConfigKeys.*;

@PublicApi
@UtilityClass
public class KafkaConfigProvider {
public static Config kafkaBrokerConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.logging.LoggingConfigKeys.*;

@PublicApi
@UtilityClass
public class LoggingConfigProvider {
public static Config loggingConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.metrics.MetricsConfigKeys.*;

@PublicApi
@UtilityClass
public class MetricsConfigProvider {
public static Config metricsConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.network.NetworkManagerConfigKeys.*;

@PublicApi
@UtilityClass
public class NetworkManagerConfigProvider {
public static Config networkManagerConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.rocks.RocksDbConfigKeys.*;

@PublicApi
@UtilityClass
public class RocksDbConfigProvider {
public static Config rocksDbConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.rsocket.RsocketConfigKeys.*;

@PublicApi
@UtilityClass
public class RsocketConfigProvider {
public static Config rsocketConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.github.resilience4j.retry.*;
import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import ru.art.service.model.*;
import static io.github.resilience4j.bulkhead.BulkheadConfig.*;
import static io.github.resilience4j.circuitbreaker.CircuitBreakerConfig.*;
Expand All @@ -37,7 +36,6 @@
import static ru.art.core.extension.ExceptionExtensions.*;
import java.util.*;

@PublicApi
@UtilityClass
public class ServiceConfigProvider {
public static CircuitBreakerServiceConfig getCircuitBreakerServiceConfig(String sectionId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.sql.SqlConfigKeys.*;

@PublicApi
@UtilityClass
public class SqlConfigProvider {
public static Config sqlDbConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void refresh() {
.username(ifExceptionOrEmpty(() -> config.getString(CONNECTION_SECTION_ID + DOT + USERNAME), DEFAULT_TARANTOOL_USERNAME))
.password(ifExceptionOrEmpty(() -> config.getString(CONNECTION_SECTION_ID + DOT + PASSWORD), EMPTY_STRING))
.operationTimeoutMillis(ifExceptionOrEmpty(() -> config.getInt(CONNECTION_SECTION_ID + DOT + OPERATION_TIMEOUT_MILLIS), DEFAULT_TARANTOOL_OPERATION_TIMEOUT))
.maxRetryCount(ifExceptionOrEmpty(() -> config.getInt(CONNECTION_SECTION_ID + DOT + MAX_RETRY_COUNT), DEFAULT_TARANTOOL_RETRIES))
.build())
.initialConfiguration(TarantoolInitialConfiguration.builder()
.background(nullIfException(() -> config.getBool(INITIAL_SECTION_ID + DOT + BACKGROUND)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public interface TarantoolConfigKeys {
String USERNAME = "username";
String PASSWORD = "password";
String OPERATION_TIMEOUT_MILLIS = "operationTimeoutMillis";
String MAX_RETRY_COUNT = "maxRetryCount";
String BACKGROUND = "background";
String CUSTOM_PROC_TITLE = "customProcTitle";
String MEMTX_DIR = "memtxDir";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import lombok.experimental.*;
import ru.art.config.*;
import ru.art.core.annotation.*;
import static ru.art.config.extensions.ConfigExtensions.*;
import static ru.art.config.extensions.sql.SqlConfigKeys.*;

@PublicApi
@UtilityClass
public class TarantoolConfigProvider {
public static Config tarantoolConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import ru.art.grpc.client.communicator.GrpcCommunicator.*;
import ru.art.grpc.client.specification.*;
import ru.art.service.exception.*;
import static lombok.AccessLevel.PRIVATE;
import static ru.art.config.remote.api.constants.RemoteConfigApiConstants.Methods.*;
import static ru.art.config.remote.api.constants.RemoteConfigApiConstants.*;
import static ru.art.grpc.client.communicator.GrpcCommunicator.*;
Expand All @@ -39,7 +40,7 @@ public RemoteConfigCommunicationSpecification(String host, Integer port, String
this.path = path;
}

@Getter(lazy = true)
@Getter(lazy = true, value = PRIVATE)
private final GrpcAsynchronousCommunicator applyConfiguration = grpcCommunicator(host, port, path)
.serviceId(REMOTE_CONFIG_SERVICE_ID)
.methodId(APPLY_CONFIGURATION_METHOD_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
import ru.art.config.cache.*;
import ru.art.config.constants.*;
import ru.art.config.exception.*;
import ru.art.core.annotation.*;
import static java.util.Objects.*;
import static ru.art.config.ConfigLoader.*;
import static ru.art.config.constants.ConfigExceptionMessages.*;
import static ru.art.config.constants.ConfigModuleConstants.*;
import static ru.art.config.module.ConfigModule.*;

@PublicApi
@UtilityClass
public class ConfigProvider {
private static final ConfigCacheContainer CONFIG_CACHE_CONTAINER = new ConfigCacheContainer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
import ru.art.config.configuration.*;
import ru.art.config.state.*;
import ru.art.core.module.Module;
import static lombok.AccessLevel.PRIVATE;
import static ru.art.config.configuration.ConfigModuleConfiguration.*;
import static ru.art.config.constants.ConfigModuleConstants.*;
import static ru.art.core.context.Context.*;

@Getter
public class ConfigModule implements Module<ConfigModuleConfiguration, ConfigModuleState> {
@Getter(lazy = true)
@Getter(lazy = true, value = PRIVATE)
private static final ConfigModuleConfiguration configModule = context().getModule(CONFIG_MODULE_ID, ConfigModule::new);
@Getter(lazy = true)
@Getter(lazy = true, value = PRIVATE)
private static final ConfigModuleState configModuleState = context().getModuleState(CONFIG_MODULE_ID, ConfigModule::new);
private final ConfigModuleConfiguration defaultConfiguration = DEFAULT_CONFIGURATION;
private final String id = CONFIG_MODULE_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

import lombok.*;
import ru.art.configurator.api.model.*;
import ru.art.core.context.*;
import ru.art.grpc.client.communicator.*;
import ru.art.grpc.client.specification.*;
import ru.art.service.exception.*;
import static java.lang.System.*;
import static lombok.AccessLevel.PRIVATE;
import static ru.art.configurator.api.constants.ConfiguratorCommunicationConstants.*;
import static ru.art.configurator.api.constants.ConfiguratorServiceConstants.*;
import static ru.art.configurator.api.constants.ConfiguratorServiceConstants.Methods.*;
Expand All @@ -42,13 +44,13 @@
@AllArgsConstructor
public class ConfiguratorCommunicationSpecification implements GrpcCommunicationSpecification {
private final String host;
private final Integer port;
private final int port;
private final String path;
private final String serviceId = CONFIGURATOR_COMMUNICATION_SERVICE_ID;
private final String profileId = getProperty(PROFILE_PROPERTY);
private final ModuleKey moduleKey = new ModuleKey(isEmpty(profileId) ? LOCAL_PROFILE : profileId, contextConfiguration().getMainModuleId());

@Getter(lazy = true)
@Getter(lazy = true, value = PRIVATE)
private final GrpcCommunicator getProtobufConfig = getProtobufConfig();

private GrpcCommunicator getProtobufConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import ru.art.http.mapper.*;
import ru.art.http.server.HttpServerModuleConfiguration.*;
import ru.art.http.server.interceptor.*;
import ru.art.http.server.module.*;
import static ru.art.config.ConfigProvider.*;
import static ru.art.configurator.api.constants.ConfiguratorServiceConstants.*;
import static ru.art.configurator.constants.ConfiguratorModuleConstants.*;
Expand All @@ -39,6 +40,7 @@
import static ru.art.http.server.constants.HttpServerModuleConstants.HttpResourceServiceConstants.HttpResourceType.*;
import static ru.art.http.server.interceptor.CookieInterceptor.Error.*;
import static ru.art.http.server.interceptor.HttpServerInterceptor.*;
import static ru.art.http.server.module.HttpServerModule.*;
import static ru.art.http.server.service.HttpResourceService.*;
import static ru.art.metrics.http.filter.MetricsHttpLogFilter.*;
import java.util.*;
Expand All @@ -47,7 +49,7 @@
public class ConfiguratorHttpServerConfiguration extends HttpServerModuleDefaultConfiguration {
private final Map<MimeType, HttpContentMapper> contentMappers = configureContentMappers(super.getContentMappers());
private final int port = ifExceptionOrEmpty(() -> config(CONFIGURATOR_SECTION_ID).getInt(CONFIGURATOR_HTTP_PORT_PROPERTY), super.getPort());
private final Logbook logbook = logbookWithoutMetricsLogs(logbookWithoutResourceLogs()).build();
private final Logbook logbook = logbookWithoutMetricsLogs(logbookWithoutResourceLogs(this::isEnableValueTracing), this::isEnableRawDataTracing).build();
private final String path = ifExceptionOrEmpty(() ->
config(CONFIGURATOR_SECTION_ID).getString(CONFIGURATOR_HTTP_PATH_PROPERTY), CONFIGURATOR_PATH);
private final List<HttpServerInterceptor> requestInterceptors = initializeRequestInterceptors(super.getRequestInterceptors());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import ru.art.grpc.server.state.*;
import ru.art.http.client.configuration.*;
import ru.art.http.client.module.*;
import ru.art.http.client.state.HttpClientModuleState;
import ru.art.http.client.state.*;
import ru.art.http.server.*;
import ru.art.http.server.module.*;
import ru.art.http.server.specification.*;
Expand All @@ -45,6 +45,7 @@
import ru.art.rocks.db.state.*;
import ru.art.service.*;
import static java.util.UUID.*;
import static lombok.AccessLevel.*;
import static ru.art.config.ConfigProvider.*;
import static ru.art.configurator.api.constants.ConfiguratorServiceConstants.*;
import static ru.art.configurator.constants.ConfiguratorModuleConstants.*;
Expand All @@ -61,7 +62,7 @@

@Getter
public class ConfiguratorModule implements Module<ConfiguratorModuleConfiguration, ModuleState> {
@Getter(lazy = true)
@Getter(lazy = true, value = PRIVATE)
private static final ConfiguratorModuleConfiguration configuratorModule = context().getModule(CONFIGURATOR_MODULE_ID, ConfiguratorModule::new);
private final String id = CONFIGURATOR_MODULE_ID;
private final ConfiguratorModuleConfiguration defaultConfiguration = new ConfiguratorModuleConfiguration();
Expand Down

This file was deleted.

Loading

0 comments on commit 6dbdad7

Please sign in to comment.