mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Polish external reader API/implementation (#759)
- keep implementation classes internal to their packages - make classes final if possible - make namespace classes non-instantiable - throw IllegalStateException instead of ExternalReaderProcessException for use after close - common convention already used by HttpClient etc. - programming errors should be signaled with unchecked exceptions - use private instead of public lock object - polish Javadoc - delete commented out code - don't use star import for a single class
This commit is contained in:
@@ -21,7 +21,7 @@ import java.util.regex.Pattern
|
||||
import kotlin.io.path.isRegularFile
|
||||
import org.pkl.core.*
|
||||
import org.pkl.core.evaluatorSettings.PklEvaluatorSettings
|
||||
import org.pkl.core.externalreader.ExternalReaderProcessImpl
|
||||
import org.pkl.core.externalreader.ExternalReaderProcess
|
||||
import org.pkl.core.http.HttpClient
|
||||
import org.pkl.core.module.ModuleKeyFactories
|
||||
import org.pkl.core.module.ModuleKeyFactory
|
||||
@@ -185,12 +185,11 @@ abstract class CliCommand(protected val cliOptions: CliBaseOptions) {
|
||||
}
|
||||
|
||||
private val externalProcesses by lazy {
|
||||
// share ExternalProcessImpl instances between configured external resource/module readers with
|
||||
// the same spec
|
||||
// this avoids spawning multiple subprocesses if the same reader implements both reader types
|
||||
// and/or multiple schemes
|
||||
// Share ExternalReaderProcess instances between configured external resource/module readers
|
||||
// with the same spec. This avoids spawning multiple subprocesses if the same reader implements
|
||||
// both reader types and/or multiple schemes.
|
||||
(externalModuleReaders + externalResourceReaders).values.toSet().associateWith {
|
||||
ExternalReaderProcessImpl(it)
|
||||
ExternalReaderProcess.of(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user