Update ZIO library (#6072)

close #6069

Changelog:
- update: ZIO major version bump
This commit is contained in:
Dmitry Bushev 2023-03-28 10:58:59 +03:00 committed by GitHub
parent 6b9cbeacb2
commit aa97787603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
83 changed files with 330 additions and 824 deletions

View File

@ -444,8 +444,8 @@ val icuVersion = "71.1"
// === ZIO ==================================================================== // === ZIO ====================================================================
val zioVersion = "1.0.12" val zioVersion = "2.0.10"
val zioInteropCatsVersion = "3.2.9.0" val zioInteropCatsVersion = "23.0.0.2"
val zio = Seq( val zio = Seq(
"dev.zio" %% "zio" % zioVersion, "dev.zio" %% "zio" % zioVersion,
"dev.zio" %% "zio-interop-cats" % zioInteropCatsVersion "dev.zio" %% "zio-interop-cats" % zioInteropCatsVersion
@ -856,8 +856,13 @@ lazy val `project-manager` = (project in file("lib/scala/project-manager"))
rebuildNativeImage := NativeImage rebuildNativeImage := NativeImage
.buildNativeImage( .buildNativeImage(
"project-manager", "project-manager",
staticOnLinux = true, staticOnLinux = true,
initializeAtRuntime = Seq("scala.util.Random") initializeAtRuntime = Seq(
"scala.util.Random",
"zio.internal.ZScheduler$$anon$4",
"zio.Runtime$",
"zio.FiberRef$"
)
) )
.dependsOn(VerifyReflectionSetup.run) .dependsOn(VerifyReflectionSetup.run)
.dependsOn(installNativeImage) .dependsOn(installNativeImage)
@ -1582,7 +1587,8 @@ lazy val `engine-runner` = project
// Note [WSLoggerManager Shutdown Hook] // Note [WSLoggerManager Shutdown Hook]
"org.enso.loggingservice.WSLoggerManager$", "org.enso.loggingservice.WSLoggerManager$",
"io.methvin.watchservice.jna.CarbonAPI", "io.methvin.watchservice.jna.CarbonAPI",
"org.enso.syntax2.Parser" "org.enso.syntax2.Parser",
"zio.internal.ZScheduler$$anon$4"
) )
) )
.dependsOn(installNativeImage) .dependsOn(installNativeImage)

View File

@ -202,23 +202,28 @@ Copyright notices related to this dependency can be found in the directory `comm
'izumi-reflect-thirdparty-boopickle-shaded_2.13', licensed under the Apache-2.0, is distributed with the engine. 'izumi-reflect-thirdparty-boopickle-shaded_2.13', licensed under the Apache-2.0, is distributed with the engine.
The license information can be found along with the copyright notices. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.izumi-reflect-thirdparty-boopickle-shaded_2.13-1.1.3`. Copyright notices related to this dependency can be found in the directory `dev.zio.izumi-reflect-thirdparty-boopickle-shaded_2.13-2.2.5`.
'izumi-reflect_2.13', licensed under the Apache-2.0, is distributed with the engine. 'izumi-reflect_2.13', licensed under the Apache-2.0, is distributed with the engine.
The license information can be found along with the copyright notices. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.izumi-reflect_2.13-1.1.3`. Copyright notices related to this dependency can be found in the directory `dev.zio.izumi-reflect_2.13-2.2.5`.
'zio-internal-macros_2.13', licensed under the Apache-2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.zio-internal-macros_2.13-2.0.10`.
'zio-stacktracer_2.13', licensed under the Apache-2.0, is distributed with the engine. 'zio-stacktracer_2.13', licensed under the Apache-2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.zio-stacktracer_2.13-1.0.12`. Copyright notices related to this dependency can be found in the directory `dev.zio.zio-stacktracer_2.13-2.0.10`.
'zio_2.13', licensed under the Apache-2.0, is distributed with the engine. 'zio_2.13', licensed under the Apache-2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.zio_2.13-1.0.12`. Copyright notices related to this dependency can be found in the directory `dev.zio.zio_2.13-2.0.10`.
'circe-core_2.13', licensed under the Apache 2.0, is distributed with the engine. 'circe-core_2.13', licensed under the Apache 2.0, is distributed with the engine.

View File

@ -1,61 +0,0 @@
/*
* Copyright 2019-2020 Septimal Mind Ltd
* Copyright 2020 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*
*/
/*
* Copyright 2017-2020 John A. De Goes and the ZIO Contributors
* Copyright 2013-2020 Miles Sabin
*
* 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
*
* http://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.
*/
Copyright 2017-2020 John A. De Goes and the ZIO Contributors
/*
* Copyright 2017-2020 John A. De Goes and the ZIO Contributors
* Copyright 2017-2018 Łukasz Biały, Paul Chiusano, Michael Pilquist,
* Oleg Pyzhcov, Fabio Labella, Alexandru Nedelcu, Pavel Chlupacek.
*
* 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
*
* http://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.
*/
-----------------------
See dev.zio.izumi-reflect_2.13-1.0.0-M5 for more information.

View File

@ -1,11 +0,0 @@
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
http://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.

View File

@ -1,20 +0,0 @@
/*
* Copyright 2019-2020 Septimal Mind Ltd
* Copyright 2020 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*
*/
The Apache 2.0 license file can be located in the licenses directory.

View File

@ -0,0 +1,2 @@
Copyright 2017-2020 John A. De Goes and the ZIO Contributors

View File

@ -1,31 +0,0 @@
/*
* Copyright (C) 2014-2021 Lightbend Inc. <https://www.lightbend.com>
*
* 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
*
* http://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.
*/
/*
* Copyright 2019-2021 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*/

View File

@ -0,0 +1 @@
Copyright 2021-2023 John A. De Goes and the ZIO Contributors

View File

@ -1,60 +0,0 @@
/*
* Copyright 2017-2021 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*/
/*
* Copyright 2018-2021 John A. De Goes and the ZIO Contributors
* Copyright 2017-2021 Łukasz Biały, Paul Chiusano, Michael Pilquist,
* Oleg Pyzhcov, Fabio Labella, Alexandru Nedelcu, Pavel Chlupacek.
*
* 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
*
* http://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.
*/
/*
* Copyright 2019-2021 John A. De Goes and the ZIO Contributors
* Copyright 2013-2021 Miles Sabin
*
* 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
*
* http://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.
*/
Copyright 2018-2021 John A. De Goes and the ZIO Contributors
Copyright 2019-2021 John A. De Goes and the ZIO Contributors
Copyright 2020-2021 John A. De Goes and the ZIO Contributors
Copyright 2021 John A. De Goes and the ZIO Contributors

View File

@ -0,0 +1,3 @@
Copyright 2013-2021 Miles Sabin
Copyright 2017-2020 John A. De Goes and the ZIO Contributors

View File

@ -162,28 +162,33 @@ Copyright notices related to this dependency can be found in the directory `comm
'izumi-reflect-thirdparty-boopickle-shaded_2.13', licensed under the Apache-2.0, is distributed with the project-manager. 'izumi-reflect-thirdparty-boopickle-shaded_2.13', licensed under the Apache-2.0, is distributed with the project-manager.
The license information can be found along with the copyright notices. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.izumi-reflect-thirdparty-boopickle-shaded_2.13-1.1.3`. Copyright notices related to this dependency can be found in the directory `dev.zio.izumi-reflect-thirdparty-boopickle-shaded_2.13-2.2.5`.
'izumi-reflect_2.13', licensed under the Apache-2.0, is distributed with the project-manager. 'izumi-reflect_2.13', licensed under the Apache-2.0, is distributed with the project-manager.
The license information can be found along with the copyright notices. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.izumi-reflect_2.13-1.1.3`. Copyright notices related to this dependency can be found in the directory `dev.zio.izumi-reflect_2.13-2.2.5`.
'zio-internal-macros_2.13', licensed under the Apache-2.0, is distributed with the project-manager.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.zio-internal-macros_2.13-2.0.10`.
'zio-interop-cats_2.13', licensed under the Apache-2.0, is distributed with the project-manager. 'zio-interop-cats_2.13', licensed under the Apache-2.0, is distributed with the project-manager.
The license file can be found at `licenses/APACHE2.0`. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.zio-interop-cats_2.13-3.2.9.0`. Copyright notices related to this dependency can be found in the directory `dev.zio.zio-interop-cats_2.13-23.0.0.2`.
'zio-stacktracer_2.13', licensed under the Apache-2.0, is distributed with the project-manager. 'zio-stacktracer_2.13', licensed under the Apache-2.0, is distributed with the project-manager.
The license file can be found at `licenses/APACHE2.0`. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.zio-stacktracer_2.13-1.0.12`. Copyright notices related to this dependency can be found in the directory `dev.zio.zio-stacktracer_2.13-2.0.10`.
'zio_2.13', licensed under the Apache-2.0, is distributed with the project-manager. 'zio_2.13', licensed under the Apache-2.0, is distributed with the project-manager.
The license file can be found at `licenses/APACHE2.0`. The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `dev.zio.zio_2.13-1.0.12`. Copyright notices related to this dependency can be found in the directory `dev.zio.zio_2.13-2.0.10`.
'circe-core_2.13', licensed under the Apache 2.0, is distributed with the project-manager. 'circe-core_2.13', licensed under the Apache 2.0, is distributed with the project-manager.

View File

@ -1,61 +0,0 @@
/*
* Copyright 2019-2020 Septimal Mind Ltd
* Copyright 2020 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*
*/
/*
* Copyright 2017-2020 John A. De Goes and the ZIO Contributors
* Copyright 2013-2020 Miles Sabin
*
* 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
*
* http://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.
*/
Copyright 2017-2020 John A. De Goes and the ZIO Contributors
/*
* Copyright 2017-2020 John A. De Goes and the ZIO Contributors
* Copyright 2017-2018 Łukasz Biały, Paul Chiusano, Michael Pilquist,
* Oleg Pyzhcov, Fabio Labella, Alexandru Nedelcu, Pavel Chlupacek.
*
* 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
*
* http://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.
*/
-----------------------
See dev.zio.izumi-reflect_2.13-1.0.0-M5 for more information.

View File

@ -1,11 +0,0 @@
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
http://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.

View File

@ -1,20 +0,0 @@
/*
* Copyright 2019-2020 Septimal Mind Ltd
* Copyright 2020 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*
*/
The Apache 2.0 license file can be located in the licenses directory.

View File

@ -0,0 +1,2 @@
Copyright 2017-2020 John A. De Goes and the ZIO Contributors

View File

@ -1 +1,3 @@
Copyright (C) 2014-2021 Lightbend Inc. <https://www.lightbend.com> Copyright (C) 2014-2021 Lightbend Inc. <https://www.lightbend.com>
Copyright 2017-2019 John A. De Goes and the ZIO Contributors

View File

@ -1,31 +0,0 @@
/*
* Copyright 2017-2019 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*/
/*
* Copyright 2021 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*/

View File

@ -1,17 +0,0 @@
/*
* Copyright (C) 2014-2021 Lightbend Inc. <https://www.lightbend.com>
*
* 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
*
* http://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.
*/
Copyright 2019-2021 John A. De Goes and the ZIO Contributors

View File

@ -0,0 +1 @@
Copyright 2021-2023 John A. De Goes and the ZIO Contributors

View File

@ -1,60 +0,0 @@
/*
* Copyright 2017-2021 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*/
/*
* Copyright 2018-2021 John A. De Goes and the ZIO Contributors
* Copyright 2017-2021 Łukasz Biały, Paul Chiusano, Michael Pilquist,
* Oleg Pyzhcov, Fabio Labella, Alexandru Nedelcu, Pavel Chlupacek.
*
* 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
*
* http://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.
*/
/*
* Copyright 2019-2021 John A. De Goes and the ZIO Contributors
* Copyright 2013-2021 Miles Sabin
*
* 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
*
* http://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.
*/
Copyright 2018-2021 John A. De Goes and the ZIO Contributors
Copyright 2019-2021 John A. De Goes and the ZIO Contributors
Copyright 2020-2021 John A. De Goes and the ZIO Contributors
Copyright 2021 John A. De Goes and the ZIO Contributors

View File

@ -0,0 +1,3 @@
Copyright 2013-2021 Miles Sabin
Copyright 2017-2020 John A. De Goes and the ZIO Contributors

View File

@ -105,11 +105,8 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) {
) )
log.trace("Created ActorSystem [{}].", system) log.trace("Created ActorSystem [{}].", system)
private val zioRuntime = { private val zioRuntime =
val r = new effect.ExecutionContextRuntime(system.dispatcher) new effect.ExecutionContextRuntime(system.dispatcher)
r.init()
r
}
private val zioExec = effect.ZioExec(zioRuntime) private val zioExec = effect.ZioExec(zioRuntime)
log.trace("Created ZIO executor [{}].", zioExec) log.trace("Created ZIO executor [{}].", zioExec)

View File

@ -2,7 +2,6 @@ package org.enso.languageserver.effect
import org.enso.languageserver.effect import org.enso.languageserver.effect
import zio._ import zio._
import zio.blocking.blocking
import java.util.concurrent.{ExecutionException, TimeoutException} import java.util.concurrent.{ExecutionException, TimeoutException}
@ -18,7 +17,7 @@ trait Exec[-F[_, _]] {
* @param op effect to execute * @param op effect to execute
* @return a future containing either a failure or a result * @return a future containing either a failure or a result
*/ */
def exec[E, A](op: F[E, A]): Future[Either[E, A]] def exec[E, A](op: F[E, A])(implicit trace: Trace): Future[Either[E, A]]
/** Execute Zio effect with timeout. /** Execute Zio effect with timeout.
* *
@ -29,13 +28,13 @@ trait Exec[-F[_, _]] {
def execTimed[E, A]( def execTimed[E, A](
timeout: FiniteDuration, timeout: FiniteDuration,
op: F[E, A] op: F[E, A]
): Future[Either[E, A]] )(implicit trace: Trace): Future[Either[E, A]]
/** Execute long running task in background. /** Execute long running task in background.
* *
* @param op effect to execute * @param op effect to execute
*/ */
def exec_[E, A](op: F[E, A]): Unit def exec_[E <: Throwable, A](op: F[E, A])(implicit trace: Trace): Unit
} }
/** Executor of Zio effects. /** Executor of Zio effects.
@ -47,55 +46,66 @@ case class ZioExec(runtime: effect.Runtime) extends Exec[ZioExec.IO] {
/** Execute Zio effect. /** Execute Zio effect.
* *
* @param op effect to execute * @param op effect to execute
* @param trace object prevents the library from messing up the user's execution trace
* @return a future containing either a failure or a result * @return a future containing either a failure or a result
*/ */
override def exec[E, A](op: ZIO[ZEnv, E, A]): Future[Either[E, A]] = { override def exec[E, A](
val promise = Promise[Either[E, A]]() op: ZIO[ZAny, E, A]
runtime.instance.unsafeRunAsync(op) { )(implicit trace: Trace): Future[Either[E, A]] =
_.fold( zio.Unsafe.unsafe { implicit unsafe =>
ZioExec.completeFailure(promise, _), val promise = Promise[Either[E, A]]()
ZioExec.completeSuccess(promise, _) runtime.instance.unsafe.fork(
op.foldCause(
ZioExec.completeFailure(promise, _),
ZioExec.completeSuccess(promise, _)
)
) )
promise.future
} }
promise.future
}
/** Execute Zio effect with timeout. /** Execute Zio effect with timeout.
* *
* @param timeout execution timeout * @param timeout execution timeout
* @param op effect to execute * @param op effect to execute
* @param trace object prevents the library from messing up the user's execution trace
* @return a future. On timeout future is failed with `TimeoutException`. * @return a future. On timeout future is failed with `TimeoutException`.
* Otherwise future contains either a failure or a result. * Otherwise future contains either a failure or a result.
*/ */
override def execTimed[E, A]( override def execTimed[E, A](
timeout: FiniteDuration, timeout: FiniteDuration,
op: ZIO[ZEnv, E, A] op: ZIO[ZAny, E, A]
): Future[Either[E, A]] = { )(implicit trace: Trace): Future[Either[E, A]] =
val promise = Promise[Either[E, A]]() zio.Unsafe.unsafe { implicit unsafe =>
runtime.instance.unsafeRunAsync( val promise = Promise[Either[E, A]]()
op.disconnect.timeout(zio.duration.Duration.fromScala(timeout)) runtime.instance.unsafe.fork(
) { op.disconnect
_.fold( .timeout(zio.Duration.fromScala(timeout))
ZioExec.completeFailure(promise, _), .foldCause[Unit](
_.fold(promise.failure(ZioExec.timeoutFailure))(a => ZioExec.completeFailure(promise, _),
promise.success(Right(a)) _.fold(promise.failure(ZioExec.timeoutFailure))(a =>
) promise.success(Right(a))
)
)
) )
promise.future
} }
promise.future
}
/** Execute long running task in background. /** Execute long running task in background.
* *
* @param op effect to execute * @param op effect to execute
* @param trace object prevents the library from messing up the user's execution trace
*/ */
override def exec_[E, A](op: ZIO[ZEnv, E, A]): Unit = override def exec_[E <: Throwable, A](
runtime.instance.unsafeRunAsync_(blocking(op)) op: ZIO[ZAny, E, A]
)(implicit trace: Trace): Unit =
zio.Unsafe.unsafe { implicit unsafe =>
runtime.instance.unsafe.fork(ZIO.blocking(op))
}
} }
object ZioExec { object ZioExec {
type IO[+E, +A] = ZIO[ZEnv, E, A] type IO[+E, +A] = ZIO[ZAny, E, A]
object ZioExecutionException extends ExecutionException object ZioExecutionException extends ExecutionException

View File

@ -6,7 +6,7 @@ import scala.concurrent.ExecutionContext
trait Runtime { trait Runtime {
/** @return the runtime instance */ /** @return the runtime instance */
def instance: zio.Runtime[zio.ZEnv] def instance: zio.Runtime[zio.ZAny]
/** Initialize the runtime. */ /** Initialize the runtime. */
def init(): Unit def init(): Unit
@ -21,11 +21,12 @@ object Runtime {
*/ */
def fromExecutionContext( def fromExecutionContext(
ec: ExecutionContext ec: ExecutionContext
): zio.Runtime[zio.ZEnv] = ): zio.Runtime[zio.ZAny] =
zio.Runtime.unsafeFromLayer( zio.Unsafe.unsafe { implicit unsafe =>
zio.ZEnv.live, zio.Runtime.unsafe.fromLayer(
zio.internal.Platform.fromExecutionContext(ec) zio.Runtime.setExecutor(zio.Executor.fromExecutionContext(ec))
) )
}
} }
/** Runtime that executes effects in the provided execution context. /** Runtime that executes effects in the provided execution context.
@ -34,12 +35,13 @@ object Runtime {
*/ */
final class ExecutionContextRuntime(ec: ExecutionContext) extends Runtime { final class ExecutionContextRuntime(ec: ExecutionContext) extends Runtime {
var instance: zio.Runtime[zio.ZEnv] = _ var instance: zio.Runtime[zio.ZAny] = _
/** Initialize the runtime. */ /** Initialize the runtime. */
override def init(): Unit = { override def init(): Unit =
if (instance eq null) { synchronized {
instance = Runtime.fromExecutionContext(ec) if (instance eq null) {
instance = Runtime.fromExecutionContext(ec)
}
} }
}
} }

View File

@ -1,9 +1,8 @@
package org.enso.languageserver package org.enso.languageserver
import zio._ import zio._
import zio.blocking.Blocking
package object effect { package object effect {
type BlockingIO[+E, +A] = ZIO[Blocking, E, A] type BlockingIO[+E, +A] = ZIO[ZAny, E, A]
} }

View File

@ -37,7 +37,8 @@ class FileManager(
private def findContentRoot( private def findContentRoot(
id: UUID id: UUID
): IO[FileSystemFailure, ContentRootWithFile] = ): IO[FileSystemFailure, ContentRootWithFile] =
IO.fromFuture { ec => contentRootManager.findContentRoot(id)(ec) } ZIO
.fromFuture { ec => contentRootManager.findContentRoot(id)(ec) }
.mapError { _ => ContentRootNotFound } .mapError { _ => ContentRootNotFound }
.absolve .absolve

View File

@ -3,7 +3,6 @@ package org.enso.languageserver.filemanager
import org.apache.commons.io.{FileExistsException, FileUtils} import org.apache.commons.io.{FileExistsException, FileUtils}
import org.enso.languageserver.effect.BlockingIO import org.enso.languageserver.effect.BlockingIO
import zio._ import zio._
import zio.blocking.effectBlocking
import java.io.{File, FileNotFoundException, RandomAccessFile} import java.io.{File, FileNotFoundException, RandomAccessFile}
import java.nio.ByteBuffer import java.nio.ByteBuffer
@ -12,6 +11,7 @@ import java.nio.file.attribute.BasicFileAttributes
import java.security.MessageDigest import java.security.MessageDigest
import scala.collection.mutable import scala.collection.mutable
import scala.util.Using import scala.util.Using
import zio.ZIO.attemptBlocking
/** File manipulation facility. /** File manipulation facility.
*/ */
@ -34,7 +34,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
file: File, file: File,
content: String content: String
): BlockingIO[FileSystemFailure, Unit] = ): BlockingIO[FileSystemFailure, Unit] =
effectBlocking(FileUtils.write(file, content, "UTF-8")) attemptBlocking(FileUtils.write(file, content, "UTF-8"))
.mapError(errorHandling) .mapError(errorHandling)
/** @inheritdoc */ /** @inheritdoc */
@ -42,7 +42,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
file: File, file: File,
contents: Array[Byte] contents: Array[Byte]
): BlockingIO[FileSystemFailure, Unit] = ): BlockingIO[FileSystemFailure, Unit] =
effectBlocking(FileUtils.writeByteArrayToFile(file, contents)) attemptBlocking(FileUtils.writeByteArrayToFile(file, contents))
.mapError(errorHandling) .mapError(errorHandling)
/** Reads the contents of a textual file. /** Reads the contents of a textual file.
@ -51,14 +51,14 @@ class FileSystem extends FileSystemApi[BlockingIO] {
* @return either [[FileSystemFailure]] or the content of a file as a String * @return either [[FileSystemFailure]] or the content of a file as a String
*/ */
override def read(file: File): BlockingIO[FileSystemFailure, String] = override def read(file: File): BlockingIO[FileSystemFailure, String] =
effectBlocking(FileUtils.readFileToString(file, "UTF-8")) attemptBlocking(FileUtils.readFileToString(file, "UTF-8"))
.mapError(errorHandling) .mapError(errorHandling)
/** @inheritdoc */ /** @inheritdoc */
override def readBinary( override def readBinary(
file: File file: File
): BlockingIO[FileSystemFailure, Array[Byte]] = ): BlockingIO[FileSystemFailure, Array[Byte]] =
effectBlocking(FileUtils.readFileToByteArray(file)) attemptBlocking(FileUtils.readFileToByteArray(file))
.mapError(errorHandling) .mapError(errorHandling)
/** Deletes the specified file or directory recursively. /** Deletes the specified file or directory recursively.
@ -67,7 +67,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
* @return either [[FileSystemFailure]] or Unit * @return either [[FileSystemFailure]] or Unit
*/ */
def delete(file: File): BlockingIO[FileSystemFailure, Unit] = def delete(file: File): BlockingIO[FileSystemFailure, Unit] =
effectBlocking { attemptBlocking {
if (file.isDirectory) { if (file.isDirectory) {
FileUtils.deleteDirectory(file) FileUtils.deleteDirectory(file)
} else { } else {
@ -87,7 +87,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
} yield () } yield ()
private def createEmptyFile(file: File): BlockingIO[FileSystemFailure, Unit] = private def createEmptyFile(file: File): BlockingIO[FileSystemFailure, Unit] =
effectBlocking(file.createNewFile(): Unit) attemptBlocking(file.createNewFile(): Unit)
.mapError(errorHandling) .mapError(errorHandling)
/** Creates a directory, including any necessary but nonexistent parent /** Creates a directory, including any necessary but nonexistent parent
@ -99,7 +99,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
override def createDirectory( override def createDirectory(
file: File file: File
): BlockingIO[FileSystemFailure, Unit] = ): BlockingIO[FileSystemFailure, Unit] =
effectBlocking(FileUtils.forceMkdir(file)) attemptBlocking(FileUtils.forceMkdir(file))
.mapError(errorHandling) .mapError(errorHandling)
/** Copy a file or directory recursively. /** Copy a file or directory recursively.
@ -112,9 +112,9 @@ class FileSystem extends FileSystemApi[BlockingIO] {
*/ */
override def copy(from: File, to: File): BlockingIO[FileSystemFailure, Unit] = override def copy(from: File, to: File): BlockingIO[FileSystemFailure, Unit] =
if (from.isDirectory && to.isFile) { if (from.isDirectory && to.isFile) {
IO.fail(FileExists) ZIO.fail(FileExists)
} else { } else {
effectBlocking { attemptBlocking {
if (from.isFile && to.isDirectory) { if (from.isFile && to.isDirectory) {
FileUtils.copyFileToDirectory(from, to) FileUtils.copyFileToDirectory(from, to)
} else if (from.isDirectory) { } else if (from.isDirectory) {
@ -132,7 +132,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
* @return either [[FileSystemFailure]] or Unit * @return either [[FileSystemFailure]] or Unit
*/ */
override def move(from: File, to: File): BlockingIO[FileSystemFailure, Unit] = override def move(from: File, to: File): BlockingIO[FileSystemFailure, Unit] =
effectBlocking { attemptBlocking {
if (to.isDirectory) { if (to.isDirectory) {
val createDestDir = false val createDestDir = false
FileUtils.moveToDirectory(from, to, createDestDir) FileUtils.moveToDirectory(from, to, createDestDir)
@ -149,7 +149,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
* @return either [[FileSystemFailure]] or file existence flag * @return either [[FileSystemFailure]] or file existence flag
*/ */
override def exists(file: File): BlockingIO[FileSystemFailure, Boolean] = override def exists(file: File): BlockingIO[FileSystemFailure, Boolean] =
effectBlocking(Files.exists(file.toPath)) attemptBlocking(Files.exists(file.toPath))
.mapError(errorHandling) .mapError(errorHandling)
/** List contents of a given path. /** List contents of a given path.
@ -160,7 +160,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
override def list(path: File): BlockingIO[FileSystemFailure, Vector[Entry]] = override def list(path: File): BlockingIO[FileSystemFailure, Vector[Entry]] =
if (path.exists) { if (path.exists) {
if (path.isDirectory) { if (path.isDirectory) {
effectBlocking { attemptBlocking {
FileSystem FileSystem
.list(path.toPath) .list(path.toPath)
.map { .map {
@ -170,10 +170,10 @@ class FileSystem extends FileSystemApi[BlockingIO] {
} }
}.mapError(errorHandling) }.mapError(errorHandling)
} else { } else {
IO.fail(NotDirectory) ZIO.fail(NotDirectory)
} }
} else { } else {
IO.fail(FileNotFound) ZIO.fail(FileNotFound)
} }
/** Returns tree of a given path. /** Returns tree of a given path.
@ -189,7 +189,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
val limit = FileSystem.Depth(depth) val limit = FileSystem.Depth(depth)
if (path.exists && limit.canGoDeeper) { if (path.exists && limit.canGoDeeper) {
if (path.isDirectory) { if (path.isDirectory) {
effectBlocking { attemptBlocking {
val directory = DirectoryEntry.empty(path.toPath) val directory = DirectoryEntry.empty(path.toPath)
FileSystem.readDirectoryEntry( FileSystem.readDirectoryEntry(
directory, directory,
@ -201,10 +201,10 @@ class FileSystem extends FileSystemApi[BlockingIO] {
directory directory
}.mapError(errorHandling) }.mapError(errorHandling)
} else { } else {
IO.fail(NotDirectory) ZIO.fail(NotDirectory)
} }
} else { } else {
IO.fail(FileNotFound) ZIO.fail(FileNotFound)
} }
} }
@ -217,13 +217,13 @@ class FileSystem extends FileSystemApi[BlockingIO] {
path: File path: File
): BlockingIO[FileSystemFailure, Attributes] = ): BlockingIO[FileSystemFailure, Attributes] =
if (path.exists) { if (path.exists) {
effectBlocking { attemptBlocking {
val attrs = val attrs =
Files.readAttributes(path.toPath, classOf[BasicFileAttributes]) Files.readAttributes(path.toPath, classOf[BasicFileAttributes])
Attributes.fromBasicAttributes(path.toPath, attrs) Attributes.fromBasicAttributes(path.toPath, attrs)
}.mapError(errorHandling) }.mapError(errorHandling)
} else { } else {
IO.fail(FileNotFound) ZIO.fail(FileNotFound)
} }
/** Returns the digest of the file at the provided `path` /** Returns the digest of the file at the provided `path`
@ -233,7 +233,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
*/ */
override def digest(path: File): BlockingIO[FileSystemFailure, SHA3_224] = { override def digest(path: File): BlockingIO[FileSystemFailure, SHA3_224] = {
if (path.isFile) { if (path.isFile) {
effectBlocking { attemptBlocking {
val messageDigest = MessageDigest.getInstance("SHA3-224") val messageDigest = MessageDigest.getInstance("SHA3-224")
Using.resource( Using.resource(
Files.newInputStream(path.toPath, StandardOpenOption.READ) Files.newInputStream(path.toPath, StandardOpenOption.READ)
@ -250,9 +250,9 @@ class FileSystem extends FileSystemApi[BlockingIO] {
}.mapError(errorHandling) }.mapError(errorHandling)
} else { } else {
if (path.exists()) { if (path.exists()) {
IO.fail(NotFile) ZIO.fail(NotFile)
} else { } else {
IO.fail(FileNotFound) ZIO.fail(FileNotFound)
} }
} }
} }
@ -267,7 +267,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
): BlockingIO[FileSystemFailure, SHA3_224] = { ): BlockingIO[FileSystemFailure, SHA3_224] = {
val path = segment.path val path = segment.path
if (path.isFile) { if (path.isFile) {
effectBlocking { attemptBlocking {
val messageDigest = MessageDigest.getInstance("SHA3-224") val messageDigest = MessageDigest.getInstance("SHA3-224")
Using.resource( Using.resource(
Files.newInputStream(path.toPath, StandardOpenOption.READ) Files.newInputStream(path.toPath, StandardOpenOption.READ)
@ -300,9 +300,9 @@ class FileSystem extends FileSystemApi[BlockingIO] {
}.mapError(errorHandling) }.mapError(errorHandling)
} else { } else {
if (path.exists()) { if (path.exists()) {
IO.fail(NotFile) ZIO.fail(NotFile)
} else { } else {
IO.fail(FileNotFound) ZIO.fail(FileNotFound)
} }
} }
} }
@ -314,9 +314,9 @@ class FileSystem extends FileSystemApi[BlockingIO] {
bytes: Array[Byte] bytes: Array[Byte]
): BlockingIO[FileSystemFailure, SHA3_224] = { ): BlockingIO[FileSystemFailure, SHA3_224] = {
if (path.isDirectory) { if (path.isDirectory) {
IO.fail(NotFile) ZIO.fail(NotFile)
} else { } else {
effectBlocking { attemptBlocking {
Using.resource(new RandomAccessFile(path, "rw")) { file => Using.resource(new RandomAccessFile(path, "rw")) { file =>
Using.resource(file.getChannel) { chan => Using.resource(file.getChannel) { chan =>
val lock = chan.lock() val lock = chan.lock()
@ -366,7 +366,7 @@ class FileSystem extends FileSystemApi[BlockingIO] {
): BlockingIO[FileSystemFailure, ReadBytesResult] = { ): BlockingIO[FileSystemFailure, ReadBytesResult] = {
val path = segment.path val path = segment.path
if (path.isFile) { if (path.isFile) {
effectBlocking { attemptBlocking {
Using.resource( Using.resource(
Files.newInputStream(path.toPath, StandardOpenOption.READ) Files.newInputStream(path.toPath, StandardOpenOption.READ)
) { stream => ) { stream =>
@ -388,9 +388,9 @@ class FileSystem extends FileSystemApi[BlockingIO] {
}.mapError(errorHandling) }.mapError(errorHandling)
} else { } else {
if (path.exists()) { if (path.exists()) {
IO.fail(NotFile) ZIO.fail(NotFile)
} else { } else {
IO.fail(FileNotFound) ZIO.fail(FileNotFound)
} }
} }
} }

View File

@ -65,13 +65,13 @@ final class PathWatcher(
val result: BlockingIO[FileSystemFailure, Unit] = val result: BlockingIO[FileSystemFailure, Unit] =
for { for {
pathToWatch <- IO pathToWatch <- ZIO
.fromFuture { _ => pathToWatchResult } .fromFuture { _ => pathToWatchResult }
.mapError { _ => ContentRootNotFound } .mapError { _ => ContentRootNotFound }
.absolve .absolve
_ <- validatePath(pathToWatch) _ <- validatePath(pathToWatch)
watcher <- IO.fromEither(buildWatcher(pathToWatch)) watcher <- ZIO.fromEither(buildWatcher(pathToWatch))
_ <- IO.fromEither(startWatcher(watcher)) _ <- ZIO.fromEither(startWatcher(watcher))
} yield () } yield ()
exec exec
@ -148,7 +148,7 @@ final class PathWatcher(
private def validatePath(path: File): BlockingIO[FileSystemFailure, Unit] = private def validatePath(path: File): BlockingIO[FileSystemFailure, Unit] =
for { for {
pathExists <- fs.exists(path) pathExists <- fs.exists(path)
_ <- ZIO.when(!pathExists)(IO.fail(FileNotFound)) _ <- ZIO.when(!pathExists)(ZIO.fail(FileNotFound))
} yield () } yield ()
private def buildWatcher( private def buildWatcher(

View File

@ -26,12 +26,13 @@ final class WatcherAdapter(
.build() .build()
/** Start watcher. */ /** Start watcher. */
def start(): IO[Throwable, Unit] = def start(): IO[Throwable, Unit] = {
IO(watcher.watch()) ZIO.attempt(watcher.watch())
}
/** Stop watcher. */ /** Stop watcher. */
def stop(): IO[Throwable, Unit] = def stop(): IO[Throwable, Unit] =
IO(watcher.close()) ZIO.attempt(watcher.close())
/** A callback executed by `DirectoryWatcher` on file system event. */ /** A callback executed by `DirectoryWatcher` on file system event. */
override def onEvent(event: DirectoryChangeEvent): Unit = { override def onEvent(event: DirectoryChangeEvent): Unit = {

View File

@ -27,9 +27,9 @@ import org.enso.languageserver.vcsmanager.Git.{
} }
import scala.jdk.CollectionConverters._ import scala.jdk.CollectionConverters._
import zio.blocking.effectBlocking
import java.time.Instant import java.time.Instant
import zio.ZIO.attemptBlocking
private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean) private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
extends VcsApi[BlockingIO] { extends VcsApi[BlockingIO] {
@ -54,7 +54,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
} }
override def init(root: Path): BlockingIO[VcsFailure, Unit] = { override def init(root: Path): BlockingIO[VcsFailure, Unit] = {
effectBlocking { attemptBlocking {
FileStoreAttributes.setBackground(asyncInit) FileStoreAttributes.setBackground(asyncInit)
val rootFile = root.toFile val rootFile = root.toFile
if (!rootFile.exists()) { if (!rootFile.exists()) {
@ -130,7 +130,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
root: Path, root: Path,
named: Option[String] named: Option[String]
): BlockingIO[VcsFailure, RepoCommit] = { ): BlockingIO[VcsFailure, RepoCommit] = {
effectBlocking { attemptBlocking {
val repo = repository(root) val repo = repository(root)
val commitName = named.getOrElse(Instant.now().toString) val commitName = named.getOrElse(Instant.now().toString)
@ -175,7 +175,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
root: Path, root: Path,
commitId: Option[String] commitId: Option[String]
): BlockingIO[VcsFailure, List[Path]] = { ): BlockingIO[VcsFailure, List[Path]] = {
effectBlocking { attemptBlocking {
val repo = repository(root) val repo = repository(root)
val jgit = new JGit(repo) val jgit = new JGit(repo)
@ -250,7 +250,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
} }
override def status(root: Path): BlockingIO[VcsFailure, RepoStatus] = { override def status(root: Path): BlockingIO[VcsFailure, RepoStatus] = {
effectBlocking { attemptBlocking {
val repo = repository(root) val repo = repository(root)
val jgit = new JGit(repo) val jgit = new JGit(repo)
val statusCmd = jgit.status() val statusCmd = jgit.status()
@ -283,7 +283,7 @@ private class Git(ensoDataDirectory: Option[Path], asyncInit: Boolean)
root: Path, root: Path,
limit: Option[Int] limit: Option[Int]
): BlockingIO[VcsFailure, List[RepoCommit]] = { ): BlockingIO[VcsFailure, List[RepoCommit]] = {
effectBlocking { attemptBlocking {
val jgit = new JGit(repository(root)) val jgit = new JGit(repository(root))
val logCmd = jgit.log() val logCmd = jgit.log()
limit limit

View File

@ -13,7 +13,7 @@ import org.enso.languageserver.filemanager.{
Path Path
} }
import org.enso.languageserver.util.UnhandledLogging import org.enso.languageserver.util.UnhandledLogging
import zio.IO import zio.{IO, ZIO}
import java.io.File import java.io.File
import java.util.UUID import java.util.UUID
@ -32,7 +32,8 @@ class VcsManager(
private def findContentRoot( private def findContentRoot(
id: UUID id: UUID
): IO[FileSystemFailure, ContentRootWithFile] = ): IO[FileSystemFailure, ContentRootWithFile] =
IO.fromFuture { ec => contentRootManager.findContentRoot(id)(ec) } ZIO
.fromFuture { ec => contentRootManager.findContentRoot(id)(ec) }
.mapError { _ => ContentRootNotFound } .mapError { _ => ContentRootNotFound }
.absolve .absolve

View File

@ -9,7 +9,7 @@ trait Effects {
protected def opTimeout: FiniteDuration = 3.seconds protected def opTimeout: FiniteDuration = 3.seconds
implicit final class UnsafeRunZio[E, A](io: zio.ZIO[zio.ZEnv, E, A]) { implicit final class UnsafeRunZio[E, A](io: zio.ZIO[zio.ZAny, E, A]) {
def unsafeRunSync(): Either[E, A] = def unsafeRunSync(): Either[E, A] =
Await.result(ZioExec(new TestRuntime).exec(io), opTimeout) Await.result(ZioExec(new TestRuntime).exec(io), opTimeout)
} }

View File

@ -4,7 +4,7 @@ package org.enso.languageserver.effect
final class TestRuntime extends Runtime { final class TestRuntime extends Runtime {
/** @inheritdoc */ /** @inheritdoc */
override def instance: zio.Runtime[zio.ZEnv] = override def instance: zio.Runtime[zio.ZAny] =
zio.Runtime.default zio.Runtime.default
/** @inheritdoc */ /** @inheritdoc */

View File

@ -17,10 +17,9 @@ import org.enso.projectmanager.boot.configuration.{
import org.enso.version.VersionDescription import org.enso.version.VersionDescription
import pureconfig.ConfigSource import pureconfig.ConfigSource
import pureconfig.generic.auto._ import pureconfig.generic.auto._
import zio.ZIO.effectTotal import zio.Console.{printLine, printLineError, readLine}
import zio._
import zio.console._
import zio.interop.catz.core._ import zio.interop.catz.core._
import zio.{ExitCode, Runtime, Scope, UIO, ZAny, ZIO, ZIOAppArgs, ZIOAppDefault}
import java.io.IOException import java.io.IOException
import java.nio.file.{FileAlreadyExistsException, Files, Path, Paths} import java.nio.file.{FileAlreadyExistsException, Files, Path, Paths}
@ -31,7 +30,7 @@ import scala.concurrent.{Await, ExecutionContext, ExecutionContextExecutor}
/** Project manager runner containing the main method. /** Project manager runner containing the main method.
*/ */
object ProjectManager extends App with LazyLogging { object ProjectManager extends ZIOAppDefault with LazyLogging {
/** A configuration of the project manager. */ /** A configuration of the project manager. */
lazy val config: ProjectManagerConfig = lazy val config: ProjectManagerConfig =
@ -52,15 +51,21 @@ object ProjectManager extends App with LazyLogging {
) )
/** ZIO runtime. */ /** ZIO runtime. */
implicit val runtime: Runtime[ZEnv] = implicit override lazy val runtime: Runtime[ZAny] =
Runtime(environment, new ZioPlatform(computeExecutionContext)) zio.Unsafe.unsafe { implicit unsafe =>
zio.Runtime.unsafe.fromLayer(
zio.Runtime.setExecutor(
zio.Executor.fromExecutionContext(computeExecutionContext)
)
)
}
/** Main process starting up the server. */ /** Main process starting up the server. */
def mainProcess( private def mainProcess(
processConfig: MainProcessConfig processConfig: MainProcessConfig
): ZIO[ZEnv, IOException, Unit] = { ): ZIO[ZAny, IOException, Unit] = {
val mainModule = val mainModule =
new MainModule[ZIO[ZEnv, +*, +*]]( new MainModule[ZIO[ZAny, +*, +*]](
config, config,
processConfig, processConfig,
computeExecutionContext computeExecutionContext
@ -68,75 +73,80 @@ object ProjectManager extends App with LazyLogging {
for { for {
binding <- bindServer(mainModule) binding <- bindServer(mainModule)
_ <- logServerStartup() _ <- logServerStartup()
_ <- getStrLn _ <- readLine
_ <- effectTotal { logger.info("Stopping server...") } _ <- ZIO.succeed { logger.info("Stopping server...") }
_ <- effectTotal { binding.unbind() } _ <- ZIO.succeed { binding.unbind() }
_ <- killAllLanguageServer(mainModule) _ <- killAllLanguageServer(mainModule)
_ <- waitTillAllShutdownHooksWillBeFired(mainModule) _ <- waitTillAllShutdownHooksWillBeFired(mainModule)
_ <- effectTotal { mainModule.system.terminate() } _ <- ZIO.succeed { mainModule.system.terminate() }
} yield () } yield ()
} }
private def killAllLanguageServer(mainModule: MainModule[ZIO[ZEnv, +*, +*]]) = private def killAllLanguageServer(mainModule: MainModule[ZIO[ZAny, +*, +*]]) =
mainModule.languageServerGateway mainModule.languageServerGateway
.killAllServers() .killAllServers()
.foldM( .foldZIO(
failure = th => failure = th =>
effectTotal { ZIO.succeed {
logger.error("An error occurred during killing lang servers.", th) logger.error("An error occurred during killing lang servers.", th)
}, },
success = ZIO.succeed(_) success = ZIO.succeed(_)
) )
private def waitTillAllShutdownHooksWillBeFired( private def waitTillAllShutdownHooksWillBeFired(
mainModule: MainModule[ZIO[ZEnv, +*, +*]] mainModule: MainModule[ZIO[ZAny, +*, +*]]
) = ) =
mainModule.languageServerGateway mainModule.languageServerGateway
.waitTillAllHooksFired() .waitTillAllHooksFired()
.foldM( .foldZIO(
failure = th => failure = th =>
effectTotal { ZIO.succeed {
logger logger
.error("An error occurred during waiting for shutdown hooks.", th) .error("An error occurred during waiting for shutdown hooks.", th)
}, },
success = ZIO.succeed(_) success = ZIO.succeed(_)
) )
override def run(args: List[String]): ZIO[ZEnv, Nothing, ExitCode] = { private def runArgs(
args: Seq[String]
): ZIO[Environment with ZIOAppArgs with Scope, Any, Any] = {
Cli.parse(args.toArray) match { Cli.parse(args.toArray) match {
case Right(opts) => case Right(opts) =>
runOpts(opts).catchAll(th => runOpts(opts).catchAll(th =>
effectTotal( ZIO.succeed(
logger.error("An error occurred during the program startup", th) logger.error("An error occurred during the program startup", th)
) *> ) *>
ZIO.succeed(FailureExitCode) ZIO.succeed(FailureExitCode)
) )
case Left(error) => case Left(error) =>
(putStrLn(error) *> (printLine(error) *>
effectTotal(Cli.printHelp()) *> ZIO.succeed(Cli.printHelp()) *>
ZIO.succeed(FailureExitCode)).catchAll(th => ZIO.succeed(FailureExitCode)).catchAll(th =>
effectTotal(logger.error("Unexpected error", th)) *> ZIO.succeed(logger.error("Unexpected error", th)) *>
ZIO.succeed(FailureExitCode) ZIO.succeed(FailureExitCode)
) )
} }
} }
override def run: ZIO[Environment with ZIOAppArgs with Scope, Any, Any] =
getArgs.flatMap(runArgs)
/** Parses and validates the command line arguments. /** Parses and validates the command line arguments.
* *
* @param options the command line arguments * @param options the command line arguments
*/ */
def parseOpts( private def parseOpts(
options: CommandLine options: CommandLine
): ZIO[ZEnv, Throwable, ProjectManagerOptions] = { ): ZIO[ZAny, Throwable, ProjectManagerOptions] = {
val parseProfilingPath = ZIO val parseProfilingPath = ZIO
.effect { .attempt {
Option(options.getOptionValue(Cli.PROFILING_PATH)) Option(options.getOptionValue(Cli.PROFILING_PATH))
.map(Paths.get(_).toAbsolutePath) .map(Paths.get(_).toAbsolutePath)
} }
.flatMap { .flatMap {
case pathOpt @ Some(path) => case pathOpt @ Some(path) =>
ZIO.ifM(ZIO.effect(Files.isDirectory(path)))( ZIO.ifZIO(ZIO.attempt(Files.isDirectory(path)))(
onTrue = putStrLnErr( onTrue = printLineError(
s"Error: ${Cli.PROFILING_PATH} is a directory: $path" s"Error: ${Cli.PROFILING_PATH} is a directory: $path"
) *> ) *>
ZIO.fail(new FileAlreadyExistsException(path.toString)), ZIO.fail(new FileAlreadyExistsException(path.toString)),
@ -146,27 +156,31 @@ object ProjectManager extends App with LazyLogging {
ZIO.succeed(None) ZIO.succeed(None)
} }
.catchAll { err => .catchAll { err =>
putStrLnErr(s"Invalid ${Cli.PROFILING_PATH} argument.") *> ZIO.fail(err) printLineError(s"Invalid ${Cli.PROFILING_PATH} argument.") *> ZIO.fail(
err
)
} }
val parseProfilingTime = ZIO val parseProfilingTime = ZIO
.effect { .attempt {
Option(options.getOptionValue(Cli.PROFILING_TIME)) Option(options.getOptionValue(Cli.PROFILING_TIME))
.map(_.toInt.seconds) .map(_.toInt.seconds)
} }
.catchAll { err => .catchAll { err =>
putStrLnErr(s"Invalid ${Cli.PROFILING_TIME} argument.") *> ZIO.fail(err) printLineError(s"Invalid ${Cli.PROFILING_TIME} argument.") *> ZIO.fail(
err
)
} }
val parseProfilingEventsLogPath = ZIO val parseProfilingEventsLogPath = ZIO
.effect { .attempt {
Option(options.getOptionValue(Cli.PROFILING_EVENTS_LOG_PATH)) Option(options.getOptionValue(Cli.PROFILING_EVENTS_LOG_PATH))
.map(Paths.get(_).toAbsolutePath) .map(Paths.get(_).toAbsolutePath)
} }
.flatMap { .flatMap {
case pathOpt @ Some(path) => case pathOpt @ Some(path) =>
ZIO.ifM(ZIO.effect(Files.isDirectory(path)))( ZIO.ifZIO(ZIO.attempt(Files.isDirectory(path)))(
onTrue = putStrLnErr( onTrue = printLineError(
s"Error: ${Cli.PROFILING_EVENTS_LOG_PATH} is a directory: $path" s"Error: ${Cli.PROFILING_EVENTS_LOG_PATH} is a directory: $path"
) *> ) *>
ZIO.fail(new FileAlreadyExistsException(path.toString)), ZIO.fail(new FileAlreadyExistsException(path.toString)),
@ -176,7 +190,7 @@ object ProjectManager extends App with LazyLogging {
ZIO.succeed(None) ZIO.succeed(None)
} }
.catchAll { err => .catchAll { err =>
putStrLnErr(s"Invalid ${Cli.PROFILING_EVENTS_LOG_PATH} argument.") *> printLineError(s"Invalid ${Cli.PROFILING_EVENTS_LOG_PATH} argument.") *>
ZIO.fail(err) ZIO.fail(err)
} }
@ -194,9 +208,9 @@ object ProjectManager extends App with LazyLogging {
/** The main function of the application, which will be passed the command-line /** The main function of the application, which will be passed the command-line
* arguments to the program and has to return an `IO` with the errors fully handled. * arguments to the program and has to return an `IO` with the errors fully handled.
*/ */
def runOpts(options: CommandLine): ZIO[ZEnv, Throwable, ExitCode] = { private def runOpts(options: CommandLine): ZIO[ZAny, Throwable, ExitCode] = {
if (options.hasOption(Cli.HELP_OPTION)) { if (options.hasOption(Cli.HELP_OPTION)) {
ZIO.effectTotal(Cli.printHelp()) *> ZIO.succeed(Cli.printHelp()) *>
ZIO.succeed(SuccessExitCode) ZIO.succeed(SuccessExitCode)
} else if (options.hasOption(Cli.VERSION_OPTION)) { } else if (options.hasOption(Cli.VERSION_OPTION)) {
displayVersion(options.hasOption(Cli.JSON_OPTION)) displayVersion(options.hasOption(Cli.JSON_OPTION))
@ -229,7 +243,7 @@ object ProjectManager extends App with LazyLogging {
verbosityLevel: Int, verbosityLevel: Int,
logMasking: Boolean, logMasking: Boolean,
profilingLog: Option[Path] profilingLog: Option[Path]
): ZIO[Console, IOException, LogLevel] = { ): ZIO[ZAny, IOException, LogLevel] = {
val level = verbosityLevel match { val level = verbosityLevel match {
case 0 => LogLevel.Info case 0 => LogLevel.Info
case 1 => LogLevel.Debug case 1 => LogLevel.Debug
@ -241,29 +255,29 @@ object ProjectManager extends App with LazyLogging {
val colorMode = ColorMode.Auto val colorMode = ColorMode.Auto
ZIO ZIO
.effect { .attempt {
Logging.setup(Some(level), None, colorMode, logMasking, profilingLog) Logging.setup(Some(level), None, colorMode, logMasking, profilingLog)
} }
.catchAll { exception => .catchAll { exception =>
putStrLnErr(s"Failed to setup the logger: $exception") printLineError(s"Failed to setup the logger: $exception")
} }
.as(level) .as(level)
} }
private def displayVersion( private def displayVersion(
useJson: Boolean useJson: Boolean
): ZIO[Console, IOException, ExitCode] = { ): ZIO[ZAny, IOException, ExitCode] = {
val versionDescription = VersionDescription.make( val versionDescription = VersionDescription.make(
"Enso Project Manager", "Enso Project Manager",
includeRuntimeJVMInfo = false, includeRuntimeJVMInfo = false,
enableNativeImageOSWorkaround = true enableNativeImageOSWorkaround = true
) )
putStrLn(versionDescription.asString(useJson)) *> printLine(versionDescription.asString(useJson)) *>
ZIO.succeed(SuccessExitCode) ZIO.succeed(SuccessExitCode)
} }
private def logServerStartup(): UIO[Unit] = private def logServerStartup(): UIO[Unit] =
effectTotal { ZIO.succeed {
logger.info( logger.info(
"Started server at {}:{}, press enter to kill server", "Started server at {}:{}, press enter to kill server",
config.server.host, config.server.host,
@ -272,9 +286,9 @@ object ProjectManager extends App with LazyLogging {
} }
private def bindServer( private def bindServer(
module: MainModule[ZIO[ZEnv, +*, +*]] module: MainModule[ZIO[ZAny, +*, +*]]
): UIO[Http.ServerBinding] = ): UIO[Http.ServerBinding] =
effectTotal { ZIO.succeed {
Await.result( Await.result(
module.server.bind(config.server.host, config.server.port), module.server.bind(config.server.host, config.server.port),
3.seconds 3.seconds

View File

@ -1,45 +0,0 @@
package org.enso.projectmanager.boot
import com.typesafe.scalalogging.LazyLogging
import zio.{Cause, Supervisor}
import zio.internal.stacktracer.Tracer
import zio.internal.stacktracer.impl.AkkaLineNumbersTracer
import zio.internal.tracing.TracingConfig
import zio.internal.{Executor, Platform, Tracing}
import scala.concurrent.ExecutionContext
/** An environment needed to execute ZIO actions.
*
* @param computeExecutionContext compute thread pool
*/
class ZioPlatform(computeExecutionContext: ExecutionContext)
extends Platform
with LazyLogging {
override def executor: Executor =
Executor.fromExecutionContext(2048)(computeExecutionContext)
override val tracing = Tracing(
Tracer.globallyCached(new AkkaLineNumbersTracer),
TracingConfig.enabled
)
override def fatal(t: Throwable): Boolean =
t.isInstanceOf[VirtualMachineError]
override def reportFatal(t: Throwable): Nothing = {
t.printStackTrace()
try {
System.exit(-1)
throw t
} catch { case _: Throwable => throw t }
}
override def reportFailure(cause: Cause[Any]): Unit =
if (cause.died)
logger.error(cause.prettyPrint)
override def supervisor: Supervisor[Any] =
Supervisor.none
}

View File

@ -1,6 +1,6 @@
package org.enso.projectmanager.control.effect package org.enso.projectmanager.control.effect
import zio.ZEnv import zio.ZAny
import scala.concurrent.Future import scala.concurrent.Future
@ -25,7 +25,7 @@ object Exec {
def apply[F[_, _]](implicit exec: Exec[F]): Exec[F] = exec def apply[F[_, _]](implicit exec: Exec[F]): Exec[F] = exec
implicit def zioExec(implicit runtime: zio.Runtime[ZEnv]): ZioEnvExec = implicit def zioExec(implicit runtime: zio.Runtime[ZAny]): ZioEnvExec =
new ZioEnvExec(runtime) new ZioEnvExec(runtime)
} }

View File

@ -2,7 +2,7 @@ package org.enso.projectmanager.control.effect
import java.io.IOException import java.io.IOException
import zio.{ZEnv, ZIO} import zio.{ZAny, ZIO}
import scala.concurrent.duration.FiniteDuration import scala.concurrent.duration.FiniteDuration
@ -50,6 +50,6 @@ object Sync {
def apply[F[+_, +_]](implicit sync: Sync[F]): Sync[F] = sync def apply[F[+_, +_]](implicit sync: Sync[F]): Sync[F] = sync
implicit val zioSync: Sync[ZIO[ZEnv, +*, +*]] = ZioSync implicit val zioSync: Sync[ZIO[ZAny, +*, +*]] = ZioSync
} }

View File

@ -16,14 +16,14 @@ class ZioAsync[R] extends Async[ZIO[R, +*, +*]] {
override def async[E, A]( override def async[E, A](
register: (Either[E, A] => Unit) => Unit register: (Either[E, A] => Unit) => Unit
): ZIO[R, E, A] = ): ZIO[R, E, A] =
ZIO.effectAsync[R, E, A] { callback => ZIO.async[R, E, A] { callback =>
register { result => callback(ZIO.fromEither(result)) } register { result => callback(ZIO.fromEither(result)) }
} }
/** @inheritdoc */ /** @inheritdoc */
override def fromFuture[A](thunk: () => Future[A]): ZIO[R, Throwable, A] = override def fromFuture[A](thunk: () => Future[A]): ZIO[R, Throwable, A] =
ZIO.effectAsync[R, Throwable, A] { cb => ZIO.async[R, Throwable, A] { cb =>
thunk().onComplete { thunk().onComplete {
case Success(value) => cb(ZIO.succeed(value)) case Success(value) => cb(ZIO.succeed(value))
case Failure(exception) => cb(ZIO.fail(exception)) case Failure(exception) => cb(ZIO.fail(exception))

View File

@ -8,26 +8,27 @@ import scala.concurrent.{Future, Promise}
* *
* @param runtime a ZIO runtime * @param runtime a ZIO runtime
*/ */
class ZioEnvExec(runtime: Runtime[ZEnv]) extends Exec[ZIO[ZEnv, *, *]] { class ZioEnvExec(runtime: Runtime[ZAny]) extends Exec[ZIO[ZAny, *, *]] {
override def exec[E, A](op: ZIO[ZEnv, E, A]): Future[Either[E, A]] = { /** @inheritdoc */
val promise = Promise[Either[E, A]]() override def exec[E, A](op: ZIO[ZAny, E, A]): Future[Either[E, A]] =
runtime.unsafeRunAsync(op) { zio.Unsafe.unsafe { implicit unsafe =>
_.fold( val promise = Promise[Either[E, A]]()
{ cause => runtime.unsafe.fork(
cause.failureOption match { op.foldCause(
case Some(e) => { cause =>
promise.success(Left(e)) cause.failureOption match {
case None => case Some(e) =>
val error = cause.defects.headOption promise.success(Left(e))
.getOrElse(new RuntimeException("ZIO failed")) case None =>
promise.failure(error) val error = cause.defects.headOption
} .getOrElse(new RuntimeException("ZIO failed"))
}, promise.failure(error)
r => promise.success(Right(r)) }
},
r => promise.success(Right(r))
)
) )
promise.future
} }
promise.future
}
} }

View File

@ -24,7 +24,7 @@ class ZioErrorChannel[R] extends ErrorChannel[ZIO[R, +*, +*]] {
override def recoverWith[E, A, B >: A, E1 >: E](fa: ZIO[R, E, A])( override def recoverWith[E, A, B >: A, E1 >: E](fa: ZIO[R, E, A])(
recovery: PartialFunction[E, ZIO[R, E1, B]] recovery: PartialFunction[E, ZIO[R, E1, B]]
): ZIO[R, E1, B] = ): ZIO[R, E1, B] =
fa.foldM( fa.foldZIO(
failure = { error => failure = { error =>
if (recovery.isDefinedAt(error)) recovery(error) if (recovery.isDefinedAt(error)) recovery(error)
else ZIO.fail(error) else ZIO.fail(error)
@ -36,7 +36,7 @@ class ZioErrorChannel[R] extends ErrorChannel[ZIO[R, +*, +*]] {
override def fallbackTo[E, A, B >: A, E1](fa: ZIO[R, E, A])( override def fallbackTo[E, A, B >: A, E1](fa: ZIO[R, E, A])(
fallback: E => ZIO[R, E1, B] fallback: E => ZIO[R, E1, B]
): ZIO[R, E1, B] = ): ZIO[R, E1, B] =
fa.foldM( fa.foldZIO(
failure = { error => fallback(error) }, failure = { error => fallback(error) },
success = ZIO.succeed(_) success = ZIO.succeed(_)
) )
@ -59,7 +59,7 @@ class ZioErrorChannel[R] extends ErrorChannel[ZIO[R, +*, +*]] {
fa: ZIO[R, E, A] fa: ZIO[R, E, A]
)(cleanUp: PartialFunction[E, ZIO[R, Nothing, Unit]]): ZIO[R, E, A] = )(cleanUp: PartialFunction[E, ZIO[R, Nothing, Unit]]): ZIO[R, E, A] =
fa.onError { cause => fa.onError { cause =>
if (cause.failed) { if (cause.isFailure) {
val failure = cause.failureOption.get val failure = cause.failureOption.get
if (cleanUp.isDefinedAt(failure)) cleanUp(failure) if (cleanUp.isDefinedAt(failure)) cleanUp(failure)
else ZIO.unit else ZIO.unit
@ -73,7 +73,7 @@ class ZioErrorChannel[R] extends ErrorChannel[ZIO[R, +*, +*]] {
fa: ZIO[R, E, A] fa: ZIO[R, E, A]
)(cleanUp: PartialFunction[Throwable, ZIO[R, Nothing, Unit]]): ZIO[R, E, A] = )(cleanUp: PartialFunction[Throwable, ZIO[R, Nothing, Unit]]): ZIO[R, E, A] =
fa.onError { cause => fa.onError { cause =>
if (cause.died) { if (cause.isDie) {
val throwable = cause.dieOption.get val throwable = cause.dieOption.get
if (cleanUp.isDefinedAt(throwable)) cleanUp(throwable) if (cleanUp.isDefinedAt(throwable)) cleanUp(throwable)
else ZIO.unit else ZIO.unit

View File

@ -3,30 +3,30 @@ package org.enso.projectmanager.control.effect
import java.io.IOException import java.io.IOException
import zio._ import zio._
import zio.blocking import zio.Duration
import zio.duration.Duration
import scala.concurrent.duration.FiniteDuration import scala.concurrent.duration.FiniteDuration
import zio.ZIO
/** Instance of [[Sync]] class for ZIO. /** Instance of [[Sync]] class for ZIO.
*/ */
object ZioSync extends Sync[ZIO[ZEnv, +*, +*]] { object ZioSync extends Sync[ZIO[ZAny, +*, +*]] {
/** @inheritdoc */ /** @inheritdoc */
override def effect[A](effect: => A): ZIO[ZEnv, Nothing, A] = override def effect[A](effect: => A): ZIO[ZAny, Nothing, A] =
ZIO.effectTotal(effect) ZIO.succeed(effect)
/** @inheritdoc */ /** @inheritdoc */
override def blockingOp[A](effect: => A): ZIO[ZEnv, Throwable, A] = override def blockingOp[A](effect: => A): ZIO[ZAny, Throwable, A] =
blocking.effectBlocking(effect) ZIO.attemptBlocking(effect)
/** @inheritdoc */ /** @inheritdoc */
override def blockingIO[A](effect: => A): ZIO[ZEnv, IOException, A] = override def blockingIO[A](effect: => A): ZIO[ZAny, IOException, A] =
blocking.effectBlockingIO(effect) ZIO.attemptBlockingIO(effect)
/** @inheritdoc */ /** @inheritdoc */
override def timeoutFail[E, E1 >: E, A](fa: ZIO[ZEnv, E, A])(e: E1)( override def timeoutFail[E, E1 >: E, A](fa: ZIO[ZAny, E, A])(e: E1)(
timeout: FiniteDuration timeout: FiniteDuration
): ZIO[zio.ZEnv, E1, A] = fa.timeoutFail(e)(Duration.fromScala(timeout)) ): ZIO[ZAny, E1, A] = fa.timeoutFail(e)(Duration.fromScala(timeout))
} }

View File

@ -53,7 +53,7 @@ import org.scalatest.BeforeAndAfterAll
import pureconfig.ConfigSource import pureconfig.ConfigSource
import pureconfig.generic.auto._ import pureconfig.generic.auto._
import zio.interop.catz.core._ import zio.interop.catz.core._
import zio.{Runtime, Semaphore, ZEnv, ZIO} import zio.{Runtime, Semaphore, ZAny, ZIO}
import scala.concurrent.duration._ import scala.concurrent.duration._
import scala.concurrent.{Await, Future} import scala.concurrent.{Await, Future}
@ -95,13 +95,13 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
) )
val testClock = val testClock =
new ProgrammableClock[ZEnv](OffsetDateTime.now(ZoneOffset.UTC)) new ProgrammableClock[ZAny](OffsetDateTime.now(ZoneOffset.UTC))
def getGeneratedUUID: UUID = { def getGeneratedUUID: UUID = {
Await.result(Future(gen.takeFirst())(system.dispatcher), 3.seconds.dilated) Await.result(Future(gen.takeFirst())(system.dispatcher), 3.seconds.dilated)
} }
lazy val gen = new ObservableGenerator[ZEnv]() lazy val gen = new ObservableGenerator[ZAny]()
val testProjectsRoot = Files.createTempDirectory(null).toFile val testProjectsRoot = Files.createTempDirectory(null).toFile
sys.addShutdownHook(FileUtils.deleteQuietly(testProjectsRoot)) sys.addShutdownHook(FileUtils.deleteQuietly(testProjectsRoot))
@ -131,7 +131,9 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
lazy val fileSystem = new BlockingFileSystem(5.seconds) lazy val fileSystem = new BlockingFileSystem(5.seconds)
lazy val storageSemaphore = lazy val storageSemaphore =
Runtime.default.unsafeRun(Semaphore.make(1)) zio.Unsafe.unsafe { implicit unsafe =>
Runtime.default.unsafe.run(Semaphore.make(1)).getOrThrow()
}
lazy val projectRepository = lazy val projectRepository =
new ProjectFileRepository( new ProjectFileRepository(
@ -141,7 +143,7 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
gen gen
) )
lazy val projectValidator = new MonadicProjectValidator[ZIO[ZEnv, *, *]]() lazy val projectValidator = new MonadicProjectValidator[ZIO[ZAny, *, *]]()
val distributionConfiguration = val distributionConfiguration =
TestDistributionConfiguration( TestDistributionConfiguration(
@ -169,10 +171,10 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
) )
lazy val shutdownHookActivator = lazy val shutdownHookActivator =
system.actorOf(ShutdownHookActivator.props[ZIO[ZEnv, +*, +*]]()) system.actorOf(ShutdownHookActivator.props[ZIO[ZAny, +*, +*]]())
lazy val languageServerGateway = lazy val languageServerGateway =
new LanguageServerGatewayImpl[ZIO[ZEnv, +*, +*]]( new LanguageServerGatewayImpl[ZIO[ZAny, +*, +*]](
languageServerRegistry, languageServerRegistry,
shutdownHookActivator, shutdownHookActivator,
system, system,
@ -180,22 +182,22 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
) )
lazy val projectCreationService = lazy val projectCreationService =
new ProjectCreationService[ZIO[ZEnv, +*, +*]]( new ProjectCreationService[ZIO[ZAny, +*, +*]](
distributionConfiguration, distributionConfiguration,
loggingService loggingService
) )
lazy val globalConfigService = new GlobalConfigService[ZIO[ZEnv, +*, +*]]( lazy val globalConfigService = new GlobalConfigService[ZIO[ZAny, +*, +*]](
distributionConfiguration distributionConfiguration
) )
lazy val projectService = lazy val projectService =
new ProjectService[ZIO[ZEnv, +*, +*]]( new ProjectService[ZIO[ZAny, +*, +*]](
projectValidator, projectValidator,
projectRepository, projectRepository,
projectCreationService, projectCreationService,
globalConfigService, globalConfigService,
new Slf4jLogging[ZIO[ZEnv, +*, +*]], new Slf4jLogging[ZIO[ZAny, +*, +*]],
testClock, testClock,
gen, gen,
languageServerGateway, languageServerGateway,
@ -203,12 +205,12 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
) )
lazy val runtimeVersionManagementService = lazy val runtimeVersionManagementService =
new RuntimeVersionManagementService[ZIO[ZEnv, +*, +*]]( new RuntimeVersionManagementService[ZIO[ZAny, +*, +*]](
distributionConfiguration distributionConfiguration
) )
override def clientControllerFactory: ClientControllerFactory = { override def clientControllerFactory: ClientControllerFactory = {
new ManagerClientControllerFactory[ZIO[ZEnv, +*, +*]]( new ManagerClientControllerFactory[ZIO[ZAny, +*, +*]](
system = system, system = system,
projectService = projectService, projectService = projectService,
globalConfigService = globalConfigService, globalConfigService = globalConfigService,
@ -295,7 +297,9 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
version, version,
forceInstallBroken = false forceInstallBroken = false
) )
Runtime.default.unsafeRun(installAction) zio.Unsafe.unsafe { implicit unsafe =>
Runtime.default.unsafe.run(installAction)
}
} }
def uninstallEngine(version: SemVer): Unit = { def uninstallEngine(version: SemVer): Unit = {
@ -304,7 +308,9 @@ class BaseServerSpec extends JsonRpcServerTestKit with BeforeAndAfterAll {
blackhole, blackhole,
version version
) )
Runtime.default.unsafeRun(action) zio.Unsafe.unsafe { implicit unsafe =>
Runtime.default.unsafe.run(action)
}
} }
def uninstallRuntime(graalVMVersion: GraalVMVersion): Unit = { def uninstallRuntime(graalVMVersion: GraalVMVersion): Unit = {

View File

@ -33,7 +33,12 @@ abstract class ProjectOpenSpecBase
engineVersion = defaultVersion, engineVersion = defaultVersion,
missingComponentAction = MissingComponentAction.Fail missingComponentAction = MissingComponentAction.Fail
) )
ordinaryProject = Runtime.default.unsafeRun(ordinaryAction).id ordinaryProject = zio.Unsafe.unsafe { implicit unsafe =>
Runtime.default.unsafe
.run(ordinaryAction)
.getOrElse(cause => throw new Exception(cause.prettyPrint))
.id
}
val brokenName = "Projbroken" val brokenName = "Projbroken"
val brokenAction = projectService.createUserProject( val brokenAction = projectService.createUserProject(
progressTracker = blackhole, progressTracker = blackhole,
@ -42,7 +47,12 @@ abstract class ProjectOpenSpecBase
engineVersion = defaultVersion, engineVersion = defaultVersion,
missingComponentAction = MissingComponentAction.Fail missingComponentAction = MissingComponentAction.Fail
) )
brokenProject = Runtime.default.unsafeRun(brokenAction).id brokenProject = zio.Unsafe.unsafe { implicit unsafe =>
Runtime.default.unsafe
.run(brokenAction)
.getOrElse(cause => throw new Exception(cause.prettyPrint))
.id
}
// TODO [RW] this hack should not be necessary with #1273 // TODO [RW] this hack should not be necessary with #1273
val projectDir = new File(userProjectDir, brokenName) val projectDir = new File(userProjectDir, brokenName)

View File

@ -5,15 +5,15 @@ import zio.{IO, ZIO}
class NopLogging[R] extends Logging[ZIO[R, +*, +*]] { class NopLogging[R] extends Logging[ZIO[R, +*, +*]] {
override def debug(msg: String): IO[Nothing, Unit] = IO.unit override def debug(msg: String): IO[Nothing, Unit] = ZIO.unit
override def debug(msg: String, args: AnyRef*): IO[Nothing, Unit] = IO.unit override def debug(msg: String, args: AnyRef*): IO[Nothing, Unit] = ZIO.unit
override def info(msg: String): IO[Nothing, Unit] = IO.unit override def info(msg: String): IO[Nothing, Unit] = ZIO.unit
override def info(msg: String, args: AnyRef*): IO[Nothing, Unit] = IO.unit override def info(msg: String, args: AnyRef*): IO[Nothing, Unit] = ZIO.unit
override def error(msg: String): IO[Nothing, Unit] = IO.unit override def error(msg: String): IO[Nothing, Unit] = ZIO.unit
override def error(msg: String, args: AnyRef*): IO[Nothing, Unit] = IO.unit override def error(msg: String, args: AnyRef*): IO[Nothing, Unit] = ZIO.unit
} }

View File

@ -10,7 +10,7 @@ class ObservableGenerator[R] extends Generator[ZIO[R, +*, +*]] {
private var buffer = Vector.empty[UUID] private var buffer = Vector.empty[UUID]
override def randomUUID(): IO[Nothing, UUID] = override def randomUUID(): IO[Nothing, UUID] =
IO.succeed { ZIO.succeed {
val uuid = UUID.randomUUID() val uuid = UUID.randomUUID()
this.synchronized { this.synchronized {
buffer = buffer :+ uuid buffer = buffer :+ uuid

View File

@ -11,10 +11,10 @@ class ProgrammableClock[R](initialNow: OffsetDateTime)
@volatile @volatile
var currentTime = initialNow.withOffsetSameInstant(ZoneOffset.UTC) var currentTime = initialNow.withOffsetSameInstant(ZoneOffset.UTC)
override def now(): IO[Nothing, OffsetDateTime] = IO.succeed(currentTime) override def now(): IO[Nothing, OffsetDateTime] = ZIO.succeed(currentTime)
override def nowInUtc(): IO[Nothing, OffsetDateTime] = override def nowInUtc(): IO[Nothing, OffsetDateTime] =
IO.succeed(currentTime) ZIO.succeed(currentTime)
def moveTimeForward(seconds: Long = 1): Unit = def moveTimeForward(seconds: Long = 1): Unit =
currentTime = currentTime.plusSeconds(seconds) currentTime = currentTime.plusSeconds(seconds)

View File

@ -1 +1 @@
sbt.version=1.7.1 sbt.version=1.8.2

View File

@ -1,60 +0,0 @@
/*
* Copyright 2019-2020 Septimal Mind Ltd
* Copyright 2020 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*
*/
/*
* Copyright 2017-2020 John A. De Goes and the ZIO Contributors
* Copyright 2013-2020 Miles Sabin
*
* 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
*
* http://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.
*/
Copyright 2017-2020 John A. De Goes and the ZIO Contributors
/*
* Copyright 2017-2020 John A. De Goes and the ZIO Contributors
* Copyright 2017-2018 Łukasz Biały, Paul Chiusano, Michael Pilquist,
* Oleg Pyzhcov, Fabio Labella, Alexandru Nedelcu, Pavel Chlupacek.
*
* 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
*
* http://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.
*/
-----------------------
See dev.zio.izumi-reflect_2.13-1.0.0-M5 for more information.

View File

@ -0,0 +1 @@
Copyright 2019-2020 Septimal Mind Ltd

View File

@ -1 +0,0 @@
The Apache 2.0 license file can be located in the licenses directory.

View File

@ -1,11 +0,0 @@
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
http://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.

View File

@ -0,0 +1 @@
Copyright 2019-2020 Septimal Mind Ltd

View File

@ -0,0 +1 @@
Copyright 2017-2020 John A. De Goes and the ZIO Contributors

View File

@ -0,0 +1 @@
Copyright 2021-2023 John A. De Goes and the ZIO Contributors

View File

@ -1,4 +0,0 @@
Copyright 2018-2021 John A. De Goes and the ZIO Contributors
Copyright 2019-2021 John A. De Goes and the ZIO Contributors
Copyright 2020-2021 John A. De Goes and the ZIO Contributors
Copyright 2021 John A. De Goes and the ZIO Contributors

View File

@ -1,3 +0,0 @@
Copyright 2013-2021 Miles Sabin
Copyright 2017-2021 John A. De Goes and the ZIO Contributors
Copyright 2017-2021 Łukasz Biały, Paul Chiusano, Michael Pilquist,

View File

@ -0,0 +1,6 @@
Copyright 2017-2023 John A. De Goes and the ZIO Contributors
Copyright 2018-2023 John A. De Goes and the ZIO Contributors
Copyright 2019-2023 John A. De Goes and the ZIO Contributors
Copyright 2020-2023 John A. De Goes and the ZIO Contributors
Copyright 2021-2023 John A. De Goes and the ZIO Contributors
Copyright 2022-2023 John A. De Goes and the ZIO Contributors

View File

@ -0,0 +1,2 @@
Copyright 2013-2021 Miles Sabin
Copyright 2017-2020 John A. De Goes and the ZIO Contributors

View File

@ -1,3 +1,3 @@
5F7F10B5303656FC01C4D26138CF2035606E7A272ADFD5419121097F009BE008 7520855014B1EA606329CFE36E11F4D56759A574DCFCC9F0DF26118104236E5F
7C1A29901335B64467B939EFDE5AC11ECC703ECF503DAEE810B20EF9F48827EE 703351A5878198A8B8742CB0B36FAA59C9877C59242A447AB89BF11437BEB70D
0 0

View File

@ -1,60 +0,0 @@
/*
* Copyright 2019-2020 Septimal Mind Ltd
* Copyright 2020 John A. De Goes and the ZIO Contributors
*
* 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
*
* http://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.
*
*/
/*
* Copyright 2017-2020 John A. De Goes and the ZIO Contributors
* Copyright 2013-2020 Miles Sabin
*
* 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
*
* http://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.
*/
Copyright 2017-2020 John A. De Goes and the ZIO Contributors
/*
* Copyright 2017-2020 John A. De Goes and the ZIO Contributors
* Copyright 2017-2018 Łukasz Biały, Paul Chiusano, Michael Pilquist,
* Oleg Pyzhcov, Fabio Labella, Alexandru Nedelcu, Pavel Chlupacek.
*
* 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
*
* http://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.
*/
-----------------------
See dev.zio.izumi-reflect_2.13-1.0.0-M5 for more information.

View File

@ -0,0 +1 @@
Copyright 2019-2020 Septimal Mind Ltd

View File

@ -1 +0,0 @@
The Apache 2.0 license file can be located in the licenses directory.

View File

@ -1,11 +0,0 @@
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
http://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.

View File

@ -0,0 +1 @@
Copyright 2019-2020 Septimal Mind Ltd

View File

@ -0,0 +1 @@
Copyright 2017-2020 John A. De Goes and the ZIO Contributors

View File

@ -0,0 +1,3 @@
Copyright 2017-2022 John A. De Goes and the ZIO Contributors
Copyright 2019-2021 John A. De Goes and the ZIO Contributors
Copyright 2021 John A. De Goes and the ZIO Contributors

View File

@ -1,2 +1,2 @@
Copyright (C) 2014-2021 Lightbend Inc. <https://www.lightbend.com> Copyright (C) 2014-2021 Lightbend Inc. <https://www.lightbend.com>
Copyright 2019-2021 John A. De Goes and the ZIO Contributors Copyright 2017-2019 John A. De Goes and the ZIO Contributors

View File

@ -1,2 +0,0 @@
Copyright 2017-2019 John A. De Goes and the ZIO Contributors
Copyright 2021 John A. De Goes and the ZIO Contributors

View File

@ -1 +0,0 @@
Copyright 2019-2021 John A. De Goes and the ZIO Contributors

View File

@ -0,0 +1 @@
Copyright 2021-2023 John A. De Goes and the ZIO Contributors

View File

@ -1,4 +0,0 @@
Copyright 2018-2021 John A. De Goes and the ZIO Contributors
Copyright 2019-2021 John A. De Goes and the ZIO Contributors
Copyright 2020-2021 John A. De Goes and the ZIO Contributors
Copyright 2021 John A. De Goes and the ZIO Contributors

View File

@ -1,3 +0,0 @@
Copyright 2013-2021 Miles Sabin
Copyright 2017-2021 John A. De Goes and the ZIO Contributors
Copyright 2017-2021 Łukasz Biały, Paul Chiusano, Michael Pilquist,

View File

@ -0,0 +1,6 @@
Copyright 2017-2023 John A. De Goes and the ZIO Contributors
Copyright 2018-2023 John A. De Goes and the ZIO Contributors
Copyright 2019-2023 John A. De Goes and the ZIO Contributors
Copyright 2020-2023 John A. De Goes and the ZIO Contributors
Copyright 2021-2023 John A. De Goes and the ZIO Contributors
Copyright 2022-2023 John A. De Goes and the ZIO Contributors

View File

@ -0,0 +1,2 @@
Copyright 2013-2021 Miles Sabin
Copyright 2017-2020 John A. De Goes and the ZIO Contributors

View File

@ -1,3 +1,3 @@
27E62459A95B059D0BA10416285FF20C38FEB28E12343177457C5A7912BB22CD 051DD0405F1257AEDF413F8EBA828011987B66D25A96E3E0396182347B2D6A9C
5D78EC2970BDDC32CF6BBDFA72CEFF618C97C893886687DC96CFB2919995861F 27E3A8F62F0326C873215CCBFDFCAA59D274563640980CF9933531BE696CBEE3
0 0