-
Notifications
You must be signed in to change notification settings - Fork 323
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
Register services in package.yaml
instead via ServiceLoader
#11868
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@radeusgd, @jdunkerley & others, can you please review this concept for service registration? If it is found sound, I provide proper implementation of the lookup_services
builtin.
@@ -924,3 +919,16 @@ local_file_move (source : File) (destination : File) (replace_existing : Boolean | |||
File_Error.handle_java_exceptions source <| | |||
copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING.to_text] else [] | |||
source.move_builtin destination copy_options | |||
|
|||
# PRIVATE | |||
type File_System_SPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First step, @radeusgd, is to define an SPI type. It can contain any information needed to process the registered instances. In this case it is protocol
name. For purposes of simplicity the other argument is typ
- to keep the implementation compatible, but one could do better, probably.
if vec . not_empty then vec.first else Nothing | ||
|
||
private get_types _:Boolean = | ||
Meta.lookup_services File_System_SPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To look the implementations up one will be allowed to use lookup_services
method and specify the SPI type one is interested in. The behavior of the lookup_services
method will be similar to the operations shown in the MetaServicesTest
.
@@ -29,3 +29,7 @@ component-groups: | |||
- Logical: { color: oklch(0.464 0.14 300) } | |||
- Operators: { color: oklch(0.464 0.14 275) } | |||
- Errors: { color: oklch(0.464 0.14 15) } | |||
|
|||
services: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To register an implementation one adds services
section that specifies pair of SPI type and implementation type.
@jdunkerley: If you want the IDE to show a drop box with all available providers sooner than the library is loaded, then we might need (localized) display name explaining why such a library should be import
ed. Engine+ls would deliver list of all possible implementations to the IDE via suggestion db or etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
James would like Meta.lookup_services
to be able to return even the not enabled services. Then one can create a drop down with a selection of all possible implementation. Question: what happens when a not enabled service is selected? How does one turn that library on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall Meta provide something like Meta.is_library_imported
? Then if not, we could give some feedback to the language server and ask it to insert a missing import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feedback to the language server
- CCing @4e6.
- how exactly? widgets don't have a way to talk to the language server
- there is Allow modification of source code from inside of Enso #8011
- with such a feature widgets would have a way to modify the code
- but it is a way bigger task than what Register services in
package.yaml
instead viaServiceLoader
#11868 originally tend to achieve
E.g. if we continue to insist on solving the problem with not enabled services we effectively put this PR on hold.
import project.System.File.File_System_SPI | ||
import project.Enso_Cloud.Enso_File | ||
|
||
type Enso_File_System_Impl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration of implementation can be done in a private
module by defining a singleton type (which is its own type) and a conversion from such type to the SPI interface. In this case the conversion is using File_System_SPI.new
factory method.
package.yaml
instead via ServiceLoader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to keep org.enso.base.file_system.FileSystemSPI? Why not migrate other service implementations in this PR as well?
* @param provides name of SPI type | ||
* @param with name of implementation type | ||
*/ | ||
case class ProvidesWith(val provides: String, val `with`: String) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change String
to org.enso.pkg.QualifiedName
?
|
||
type Enso_File_System_Impl | ||
|
||
File_System_SPI.from (_:Enso_File_System_Impl) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure this works, you should remove EnsoPathFileSystemImpl.java?
Co-authored-by: Hubert Plociniczak <[email protected]>
Co-authored-by: Hubert Plociniczak <[email protected]>
Pull Request Description
Designs a fix for #11724.
package.yaml
is extended withand a new method
lookup_services
will read all such info and load the implementations just like demonstrated inMetaServicesTest
.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.