-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: decouple env plugin from language runtimes #452
Conversation
* @see EnvConfig | ||
*/ | ||
@DelicateElideApi public class Environment private constructor (public val config: EnvConfig) { | ||
private val effectiveEnvironment: AtomicReference<MutableMap<String, String?>> = AtomicReference(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.
environment is now mapped from the config
, we no longer need to manually synchronize or even assign this map (lazy is technically still synchronized).
override val key: Key<Environment> = Key("Environment") | ||
|
||
override fun install(scope: InstallationScope, configuration: EnvConfig.() -> Unit): Environment { | ||
// apply the configuration and create the plugin instance | ||
val config = EnvConfig().apply(configuration) | ||
val instance = Environment(config) | ||
|
||
// @TODO: graceful language detection |
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.
fixed, now there's no need for language detection
@@ -60,80 +56,40 @@ import elide.vm.annotations.Polyglot | |||
|
|||
/** Apply an environment [config] to a context [builder] during the [ContextCreated] event. */ | |||
internal fun onContextCreate(builder: PolyglotContextBuilder) { | |||
if (config.app.enabled) { |
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.
Environment map initialization logic has been moved to a lazy property
private val mutableEnvironmentVariables: MutableMap<String, EnvVar> = ConcurrentSkipListMap() | ||
|
||
/** Register an [EnvVar] with the given [key]. */ | ||
public fun setEnv(key: String, value: EnvVar) { |
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.
Following a similar pattern to language bindings in AbstractLanguagePlugin
, expose only an immutable map and very restricted mutating operations using methods.
a8b92d3
to
a084931
Compare
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
Signed-off-by: Dario Valdespino <dvaldespino00@gmail.com>
a084931
to
06dd1ec
Compare
Summary
This PR updates the
Environment
plugin to remove dependencies on language plugins.The env variables proxy is injected through polyglot bindings by default. Languages without support for polyglot bindings may install the env proxy manually to language-scoped bindings using
Environment.install(PolyglotContext, GuestLanguage)
.