-
Notifications
You must be signed in to change notification settings - Fork 328
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
Refactor common SPI logic, handle SPI registrations with missing Enso library #11722
Conversation
Cloud tests:
|
…s and handles the issue of SPIs that are registered but not loaded
ea7bd86
to
3f41674
Compare
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.
Now, when the whole EnsoServiceLoader
infrastructure is being revamped, can we also rename the implementation classes, please?
I'd suggest to more closely mimic the API of ServiceLoader
just tailor it to Enso needs. E.g. create EnsoServiceLoader
and its nested class Provider
.
Few comments and one (hopefully) helpful suggestion left inline.
return getTypeObject() != null; | ||
} | ||
|
||
protected static class Loader<T extends AbstractEnsoTypeSPI> { |
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.
Missing documentation. I would make this class the entry point for this "SPI infrastructure" - e.g. a top level class.
import org.graalvm.polyglot.PolyglotException; | ||
import org.graalvm.polyglot.Value; | ||
|
||
public abstract class AbstractEnsoTypeSPI { |
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.
I belive the proper name of this machinery is EnsoServiceLoader
. The top most class should be the "loader". The inner class should represent the item (any reason why not call it Provider
just like java.util..ServiceLoader
does?).
cachedTypeObject = EnsoMeta.getType(getModuleName(), getTypeName()); | ||
} catch (PolyglotException e) { | ||
// Currently I have not found a way to get the type/class of the exception, so we rely on | ||
// the message. |
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.
e.getGuestValue().getMetaObject()
should give you access to the exception Enso type.
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.
I was trying it and IIRC getGuestValue
was null.
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.
At least that was the case in Native Image build, the only place where this error is relevant (it does not happen in JVM mode)
std-bits/base/src/main/java/org/enso/base/spi/AbstractEnsoTypeSPI.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/spi/AbstractEnsoTypeSPI.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/enso_cloud/DataLinkSPI.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/file_format/FileFormatSPI.java
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/file_format/FileFormatSPI.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/file_format/FileFormatSPI.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/spi/AbstractEnsoTypeSPI.java
Outdated
Show resolved
Hide resolved
std-bits/aws/src/main/java/org/enso/aws/database/RedshiftConnectionDetailsImpl.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/spi/EnsoServiceLoader.java
Outdated
Show resolved
Hide resolved
std-bits/base/src/main/java/org/enso/base/spi/EnsoServiceLoader.java
Outdated
Show resolved
Hide resolved
import org.graalvm.polyglot.Value; | ||
|
||
/** A base class for an Enso service backed by an Enso type. */ | ||
public abstract class EnsoService { |
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.
I would prefer to make this EnsoServiceLoader.Provider
inner class, but I can live with outer class as well.
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.
I don't think this is a provider.
Our Loader scheme omits the provider abstraction as it seems unnecessary in this setup. Note that all the ServiceLoader.Provider
does is have a get
method that allows to extract the underlying type T
(from ServiceLoader<T>
). In our case, EnsoService
is the base type for "that T
" - i.e. it is the bound in EnsoServiceLoader<? extends EnsoService>
. So they server a bit different purposes and I don't think the name Provider
would be fitting.
Pull Request Description
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.