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

Enable dependency injection with auto-generated components #74

Merged

Conversation

rubensworks
Copy link
Contributor

While this PR may seem fairly simple, most of the work for this was spent in this new tool: https://github.com/LinkedSoftwareDependencies/Components-Generator.js

Every time you now run the build scripts, the components folder will automatically be filled with .jsonld files based on all the exported TypeScript files (using Components-Generator.js). These components are used within our declarative dependency injection configuration (see config/).

I already split up the config file over different presets, which will make it easier to modularize in the future. Suggestions for structuring the config differently are definitely welcome.

It's very important we get this part right, so please review in detail :-)

I will also write some based dev documentation, so people know how to work with this.

@rubensworks
Copy link
Contributor Author

@rubensworks
Copy link
Contributor Author

Fix for Windows is pushed.

Copy link
Member

@joachimvh joachimvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This automated config generation thing is great. Really would have liked this when we were making Comunica :D .

Regarding the structure: I think we probably want to structure it in such way that the things that are most likely to be replaced by something are in separete files. Not 100% sure what those would be, but my guess would be all the separate inputs of the AuthenticatedLdpHandler (so would put each of those big blocks in a separate file, and for example add the acl authorization to the acl.json). The stores are probably another place more likely to have changes but that one's a bit more difficult since we have a stack of stores. Perhaps put the actual store handling the data in a separate config? But then again the sparql store is not going to need some of the patching handlers, so not sure there.

})
.help();

new Promise<RuntimeConfig>(async(resolve): Promise<void> => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might have something to do with this being CLI stuff and async is a problem, but why is a new Promise made here? Because it seems like everything in there could also just be in a try/catch block with 1 await in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need runCustom to be non-async, because we want to call it from bin/ without having to add a then/catch there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's fake safety because it's completing non-synchronously anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safe though, since we handle then and catch directly here.

But in any case, I can remove the explicit Promise constructor as you've mentioned, and just call the async function directly.

Copy link
Member

@RubenVerborgh RubenVerborgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 🔥 !

Only thing I wonder is whether we want to s/:my:/:default:/g, which I find less confusing.

@rubensworks
Copy link
Contributor Author

Only thing I wonder is whether we want to s/:my:/:default:/g, which I find less confusing.

Sure, that might be better indeed! Will change.

@rubensworks
Copy link
Contributor Author

Rebased on master, so this one should be good to go.

@joachimvh joachimvh merged commit 3f20f79 into CommunitySolidServer:master Sep 1, 2020
const loader = new Loader(properties);
await loader.registerAvailableModuleResources();
const setup: Setup = await loader
.instantiateFromUrl('urn:solid-server:my', configPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rubensworks Still a my here, is that a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks I didn't test things properly.
We probably want some automated tests around this bin...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a class now, so we don't even need bin tests. But a system test that boots up the bin would be needed indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants