Skip to content

Commit 0230775

Browse files
committed
simplify usages of model catalog.
we know what model catalog we need for a given edition, and we know what point in the plugin lifecycle we need it. so we just get what we need, when we need it. nothing clever. concretely, the invariant is that all extension entry points run and finish before any lifecycles initialise. so while we have several extensions needing model catalog, we can illustrate in code the guarantees we know about. specifically, when an extension needs model catalog in it's lifecycle only, then we can just get the already created one; whereas when you need it in extension init itself, you are competing and must do a synchronised singleton get-or-create type thing. this will be much clearer when we merge the extensions.
1 parent 16890a0 commit 0230775

File tree

3 files changed

+15
-131
lines changed

3 files changed

+15
-131
lines changed

edition-api/src/main/java/org/neo4j/gds/EditionFactory.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

edition-api/src/test/java/org/neo4j/gds/EditionFactoryTest.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

proc/sysinfo/src/test/java/org/neo4j/gds/SysInfoProcLicensesTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
import org.junit.jupiter.api.BeforeEach;
2424
import org.junit.jupiter.api.Nested;
2525
import org.junit.jupiter.api.Test;
26+
import org.neo4j.kernel.extension.ExtensionFactory;
27+
import org.neo4j.kernel.extension.context.ExtensionContext;
28+
import org.neo4j.kernel.lifecycle.Lifecycle;
29+
import org.neo4j.kernel.lifecycle.LifecycleAdapter;
2630
import org.neo4j.test.TestDatabaseManagementServiceBuilder;
2731
import org.neo4j.test.extension.ExtensionCallback;
2832

@@ -217,9 +221,17 @@ public String toString() {
217221
@ExtensionCallback
218222
protected void configuration(TestDatabaseManagementServiceBuilder builder) {
219223
super.configuration(builder);
220-
builder
221-
.removeExtensions(e -> e instanceof EditionFactory)
222-
.addExtension(new EditionFactory(testLicenseState));
224+
builder.addExtension(new ExtensionFactory<Dependencies>("justsomethingforthistest") {
225+
@Override
226+
public Lifecycle newInstance(ExtensionContext context, Dependencies dependencies) {
227+
dependencies.globalProcedures().registerComponent(
228+
LicenseState.class,
229+
ctx -> testLicenseState,
230+
false
231+
);
232+
return new LifecycleAdapter();
233+
}
234+
});
223235
}
224236

225237
@BeforeEach

0 commit comments

Comments
 (0)