Skip to content

Commit

Permalink
Improving test and including missing java docs
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Aug 24, 2024
1 parent 31eddb9 commit e945fb1
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ public class BlockNodeApp {
private final WebServerConfig.Builder webServerBuilder;

/**
* Has all needed dependencies to start the server and initialize the context.
* Constructs a new BlockNodeApp with the specified dependencies.
*
* @param serviceStatus the status of the service
* @param healthService the health service
* @param serviceStatus has the status of the service
* @param healthService handles the health API requests
* @param blockStreamService handles the GRPC API requests
* @param webServerBuilder used to build the web server and start it
*/
@Inject
public BlockNodeApp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ static BlockNodeContext provideBlockNodeContext() {
}
}

/**
* Provides a block stream service singleton using DI.
*
* @param streamMediator should come from DI
* @param blockReader should come from DI
* @param serviceStatus should come from DI
* @param blockNodeContext should come from DI
* @return a block stream service singleton
*/
@Singleton
@Provides
static BlockStreamService provideBlockStreamService(
Expand All @@ -76,6 +85,11 @@ static BlockStreamService provideBlockStreamService(
return new BlockStreamService(streamMediator, blockReader, serviceStatus, blockNodeContext);
}

/**
* Provides a web server config builder singleton using DI.
*
* @return a web server config builder singleton
*/
@Singleton
@Provides
static WebServerConfig.Builder provideWebServerConfigBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@
import java.nio.file.Path;
import javax.inject.Singleton;

/**
* A Dagger module for providing configuration dependencies, any specific configuration should be
* part of this module.
*/
@Module
public interface ConfigInjectionModule {

static final String APPLICATION_PROPERTIES = "app.properties";
/** The application properties file name within the resources package. */
String APPLICATION_PROPERTIES = "app.properties";

/**
* Provides a configuration singleton using the configuration builder. Injected by the DI
* Framework.
*
* @return a configuration singleton
*/
@Singleton
@Provides
static Configuration provideConfiguration() {
Expand All @@ -53,31 +64,61 @@ static Configuration provideConfiguration() {
}
}

/**
* Provides a persistence storage configuration singleton using the configuration.
*
* @param configuration is the configuration singleton
* @return a persistence storage configuration singleton
*/
@Singleton
@Provides
static PersistenceStorageConfig providePersistenceStorageConfig(
@NonNull Configuration configuration) {
return configuration.getConfigData(PersistenceStorageConfig.class);
}

/**
* Provides a metrics configuration singleton using the configuration.
*
* @param configuration is the configuration singleton
* @return a metrics configuration singleton
*/
@Singleton
@Provides
static MetricsConfig provideMetricsConfig(@NonNull Configuration configuration) {
return configuration.getConfigData(MetricsConfig.class);
}

/**
* Provides a Prometheus configuration singleton using the configuration.
*
* @param configuration is the configuration singleton
* @return a Prometheus configuration singleton
*/
@Singleton
@Provides
static PrometheusConfig providePrometheusConfig(@NonNull Configuration configuration) {
return configuration.getConfigData(PrometheusConfig.class);
}

/**
* Provides a consumer configuration singleton using the configuration.
*
* @param configuration is the configuration singleton
* @return a consumer configuration singleton
*/
@Singleton
@Provides
static ConsumerConfig provideConsumerConfig(@NonNull Configuration configuration) {
return configuration.getConfigData(ConsumerConfig.class);
}

/**
* Provides a basic common configuration singleton using the configuration.
*
* @param configuration is the configuration singleton
* @return a basic common configuration singleton
*/
@Singleton
@Provides
static BasicCommonConfig provideBasicCommonConfig(@NonNull Configuration configuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ static BlockWriter<BlockItem> providesBlockWriter(@NonNull BlockNodeContext bloc
}
}

/**
* Provides a block reader singleton using the persistence storage config.
*
* @param config the persistence storage configuration needed to build the block reader
* @return a block reader singleton
*/
@Provides
@Singleton
static BlockReader<Block> providesBlockReader(@NonNull PersistenceStorageConfig config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class BlockNodeAppTest {

@Mock private HealthService healthService;

@Mock private BlockStreamService blockStreamService;

@Mock private WebServerConfig.Builder webServerBuilder;

@Mock private WebServer webServer;
Expand Down

0 comments on commit e945fb1

Please sign in to comment.