-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Extension mechanism for FileSystem #1466
Comments
It’d also be nice to use this to simplify testing for libraries like SQLite that go direct to the filesystem by default.
|
I think we need more stuff to support the Perhaps something like this? interface FileSystemExtension {
fun interface Factory<E : FileSystemExtension> {
fun create(host: FileSystemExtension.Host): E
}
interface Host {
fun onPathParameter(path: Path, functionName: String, parameterName: String): Path
fun onPathResult(path: Path, functionName: String): Path
}
} fun <E : FileSystemExtension> FileSystem.extend(
factory: FileSystemExtension.Factory<E>,
): FileSystem This makes it a bit more annoying to create extensions, but it gives them the stuff they need to do 1:1 path mapping. Also getting the implementation right is tricky, cause we need to potentially apply multiple layers of mappings. |
Yep, implementation is beyond tricky; it’s impossible. I can’t create a single instance of an extension because it could need different path transforms depending on which wrapped FileSystem returned it. |
Some updates on extensions after a discussion with @dellisd ...
In this listing we target multiple underlying |
There’s a bunch of FileSystem features that we don’t implement:
We should make it possible to get at extended features like these, without necessarily having all of these features in the core API.
Users could add an interface like this:
You’d use it like this:
Finally you’d attach extensions in a way similar to
CoroutineContext
:The text was updated successfully, but these errors were encountered: