Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nested attributes, bug fixes and refactoring #3

Merged
merged 16 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [0.0.1-RC3]
- Simplified NamespaceDataSource to use a supplier instead of hierarchy for static and dynamic source
- LeiaBundle: Fixed duplicate instantiation of schema repository
- TimeBasedDataProvider: Fixed the initial delay of executor to prevent multiple invocation of update on startup
- Schema Validator: Removed instance creation of schema class. It's not required for static validations.
- SchemaValidationUtils - Fixed strict type validation

## [0.0.1-RC2]
- Added tests to the core functionality to schemaValidator, refresher, client, core and models
- Fixed the validation bug in SchemaValidationUtils. field.getType().isInstanceOf is a miss, Class.isAssignable is the correct way to check for class assignments.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ And
<dependency>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-bom</artifactId>
<versio>0.0.1-RC2</version>
<versio>0.0.1-RC3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion leia-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
</parent>

<artifactId>leia-bom</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion leia-client-dropwizard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
package com.grookage.leia.dw.client;

import com.google.common.base.Preconditions;
import com.google.inject.Injector;
import com.grookage.leia.client.LeiaMessageProduceClient;
import com.grookage.leia.client.datasource.NamespaceDataSource;
import com.grookage.leia.client.refresher.LeiaClientRefresher;
import com.grookage.leia.client.refresher.LeiaClientSupplier;
import com.grookage.leia.provider.config.LeiaHttpConfiguration;
import com.grookage.leia.validator.InjectableSchemaValidator;
import com.grookage.leia.validator.StaticSchemaValidator;
import com.grookage.leia.validator.LeiaSchemaValidator;
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
Expand All @@ -47,15 +46,11 @@ public abstract class LeiaClientBundle<T extends Configuration> implements Confi

protected abstract Set<String> getPackageRoots(T configuration);

protected abstract Injector getInjector(Environment environment);

protected LeiaSchemaValidator getSchemaValidator(T configuration,
Environment environment,
LeiaClientRefresher clientRefresher) {
return InjectableSchemaValidator.builder()
return StaticSchemaValidator.builder()
.supplier(clientRefresher::getConfiguration)
.packageRoots(getPackageRoots(configuration))
.injector(getInjector(environment))
.build();
}

Expand All @@ -76,7 +71,7 @@ public void run(T configuration, Environment environment) {
.build())
.configRefreshTimeSeconds(configRefreshSeconds)
.build();
final var validator = getSchemaValidator(configuration, environment, clientRefresher);
final var validator = getSchemaValidator(configuration, clientRefresher);
validator.start();
if (withProducerClient) {
producerClient = LeiaMessageProduceClient.builder()
Expand Down
2 changes: 1 addition & 1 deletion leia-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@

package com.grookage.leia.client.datasource;

import lombok.AllArgsConstructor;

import java.util.Set;
import java.util.function.Supplier;

public interface NamespaceDataSource {
@AllArgsConstructor
public class NamespaceDataSource {

Set<String> getNamespaces();
private final Supplier<Set<String>> namespaceSupplier;

public Set<String> getNamespaces() {
return namespaceSupplier.get();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,26 @@ class NamespaceDataSourceTest {

@Test
void testNamespaceDataSource() {
final var staticSource = new StaticNamespaceDataSource(Set.of("testNamespace"));
Assertions.assertNotNull(staticSource);
Assertions.assertNotNull(staticSource.getNamespaces());
Assertions.assertFalse(staticSource.getNamespaces().isEmpty());
final var supplier = new Supplier<Set<String>>() {

private static final AtomicReference<Boolean> supplierMarker = new AtomicReference<>(false);

@Override
public Set<String> get() {
return supplierMarker.get() ?
Set.of("testNamespace") : Set.of();
Set.of("testNamespace") : Set.of();
}

public void mark() {
supplierMarker.set(true);
}
};
final var suppliedSource = new DynamicNamespaceDataSource(supplier);
final var suppliedSource = new NamespaceDataSource(supplier);
Assertions.assertNotNull(suppliedSource.getNamespaces());
Assertions.assertTrue(suppliedSource.getNamespaces().isEmpty());

supplier.mark();
Assertions.assertNotNull(suppliedSource.getNamespaces());
Assertions.assertFalse(suppliedSource.getNamespaces().isEmpty());


}
}
2 changes: 1 addition & 1 deletion leia-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-dropwizard-es/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-dropwizard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ protected List<Lifecycle> withLifecycleManagers(T configuration) {
public void run(T configuration, Environment environment) {
final var userResolver = userResolver(configuration);
Preconditions.checkNotNull(userResolver, "User Resolver can't be null");
this.schemaRepository = getSchemaRepository(configuration);
final var schemaProcessorHub = SchemaProcessorHub.of()
.withSchemaRepository(getSchemaRepository(configuration))
.withSchemaRepository(schemaRepository)
.withVersionIDGenerator(getVersionIDGenerator())
.build();
this.schemaIngestor = new SchemaIngestor<U>()
.withProcessorHub(schemaProcessorHub)
.build();
this.schemaRepository = getSchemaRepository(configuration);
final var cacheConfig = getCacheConfig(configuration);
this.schemaRetriever = new SchemaRetriever(schemaRepository, cacheConfig);
withLifecycleManagers(configuration)
Expand Down
2 changes: 1 addition & 1 deletion leia-elastic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Set;

@EqualsAndHashCode(callSuper = true)
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
2 changes: 1 addition & 1 deletion leia-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-bom</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-bom</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-refresher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public TimeBasedDataProvider(Supplier<T> configSupplier, T initialDefaultValue,
}

public void start() {
this.executorService.scheduleWithFixedDelay(this.updater, 0L, this.delay, this.timeUnit);
this.executorService.scheduleWithFixedDelay(this.updater, this.delay, this.delay, this.timeUnit);
this.update();
}

Expand Down
2 changes: 1 addition & 1 deletion leia-repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
9 changes: 1 addition & 8 deletions leia-schema-validator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand All @@ -47,13 +47,6 @@
<version>${reflections.version}</version>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${guice.inject.version}</version>
</dependency>


<dependency>
<artifactId>leia-models</artifactId>
<type>test-jar</type>
Expand Down
Loading
Loading