-
Notifications
You must be signed in to change notification settings - Fork 280
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
Untangle external reader code #776
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.pkl.core.externalreader; | ||
|
||
public record ModuleReaderSpec( | ||
String scheme, boolean hasHierarchicalUris, boolean isLocal, boolean isGlobbable) {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,24 +13,19 @@ | |
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.pkl.core.module; | ||
package org.pkl.core.externalreader; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.List; | ||
import org.pkl.core.SecurityManager; | ||
import org.pkl.core.SecurityManagerException; | ||
import org.pkl.core.messaging.MessageTransport; | ||
import org.pkl.core.module.PathElement; | ||
|
||
public interface ExternalModuleResolver { | ||
|
||
interface Spec { | ||
boolean hasHierarchicalUris(); | ||
|
||
boolean isGlobbable(); | ||
|
||
boolean isLocal(); | ||
|
||
String scheme(); | ||
public interface ModuleResolver { | ||
static ModuleResolver of(MessageTransport transport, long evaluatorId) { | ||
return new ModuleResolverImpl(transport, evaluatorId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There aren't any layering violations here, are there? Since we've now shipped this in 0.27, I think let's keep this as-is, and have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This PR already makes breaking API changes. If it's important to make this particular change less breaking, record I prefer the name
|
||
} | ||
|
||
String resolveModule(SecurityManager securityManager, URI uri) | ||
|
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.
Either undo this change, or re-add and deprecate.
But, I think it's fine to just keep this method around; we don't gain much by inlining this.
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.
The motivation is to remove a method from the public API that doesn't belong there. I can add it back as deprecated.
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.
Sorry, I don't fully understand; what makes
Proxy.create()
not belong here?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.
Sorry, my impression was that
Proxy.create()
is an internal method used byProxy.parse()
that accidentally became a public API.I feel that regular Java code should just use
new Proxy(new URI(...))
ornew Proxy(URI.create(...))
. These will also throw more appropriate exceptions thanPklException
, which is mainly thrown by the evaluator and doesn't seem ideal for regular Java APIs that don't evaluate Pkl code.One more thing I noticed is that similar classes such as
Release
andPklInfo
usejava.lang.String
forpkl.base.Uri
. (They also don't have their own package.) A potential problem with usingjava.net.URI
forpkl.base.Uri
is that valid Pkl objects can't be represented in Java.