This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build.sbt and fmt migrated * migrated zio-actors * migrated zio-persistence * migrated persistence-jdbc * migrated akka-interop * migrated-examples * removed empty test file * generated new docs * remove most workflows * Revert "remove most workflows" This reverts commit 1f50136. * Revert "generated new docs" This reverts commit 94e26bb. * reverted ! interface * private val inte BuildHelper * fix docs * more docs warnings fixed * Fixes from compiler-flags, unused private functions * updated README * type warnings fixed * Fixed serialization.... * Separate classes * scala-2 folder * Add annotation for overridden Serialization method * formatting * Get all versions to play together * formatting * genereted docs/README * Added Scala 3.3.1 as CI build * Add docs again to build * formatting in scala-3 folder * fix packages * simplify * Break out as much common logic as possible * only use refActorMap in ActorSystem, and change name to be consistent * Helped scala 2.12 compiler * formating * BaseActorSystem private * Fix docs not compiling * Break out logic for Context class * README finds version * fix website-workflow import error * sbt publishLocal fails. Reverted imports to ._ * removed unused file * Removed more scala 3 syntax * bit sloppy, reverted more imports and wildcards * remove xSource3 flag for scala2.12 * Manges to move all business logic to BaseActorSystem * reverted akka upgrade --------- Co-authored-by: Ragnar Englund <[email protected]>
- Loading branch information
Showing
35 changed files
with
831 additions
and
582 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
java: ['[email protected]', '[email protected]'] | ||
scala: ['2.12.15', '2.13.8'] | ||
scala: ['2.12.15', '2.13.8', '3.3.1'] | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: olafurpg/setup-scala@v10 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
version = "2.6.3" | ||
version = "3.7.15" | ||
maxColumn = 120 | ||
align = most | ||
align.preset = most | ||
continuationIndent.defnSite = 2 | ||
docstrings.style = Asterisk | ||
assumeStandardLibraryStripMargin = true | ||
docstrings = JavaDoc | ||
lineEndings = preserve | ||
includeCurlyBraceInSelectChains = false | ||
danglingParentheses = true | ||
danglingParentheses.preset = true | ||
spaces { | ||
inImportCurlyBraces = true | ||
} | ||
optIn.annotationNewlines = true | ||
|
||
rewrite.rules = [SortImports, RedundantBraces] | ||
runner.dialect = scala3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package zio.actors | ||
|
||
import zio.actors.ActorSystemUtils._ | ||
import zio.actors.ActorsConfig._ | ||
import zio.{ Ref, Task, UIO, ZIO } | ||
|
||
import java.io._ | ||
|
||
/** | ||
* Object providing constructor for Actor System with optional remoting module. | ||
*/ | ||
object ActorSystem { | ||
|
||
/** | ||
* Constructor for Actor System | ||
* | ||
* @param sysName | ||
* \- Identifier for Actor System | ||
* @param configFile | ||
* \- Optional configuration for a remoting internal module. If not provided the actor system will only handle local | ||
* actors in terms of actor selection. When provided - remote messaging and remote actor selection is possible | ||
* @return | ||
* instantiated actor system | ||
*/ | ||
def apply(sysName: String, configFile: Option[File] = None): Task[ActorSystem] = | ||
for { | ||
initActorRefMap <- Ref.make(Map.empty[String, Actor[Any]]) | ||
config <- retrieveConfig(configFile) | ||
remoteConfig <- retrieveRemoteConfig(sysName, config) | ||
actorSystem <- ZIO.attempt(new ActorSystem(sysName, config, remoteConfig, initActorRefMap, parentActor = None)) | ||
_ <- ZIO | ||
.succeed(remoteConfig) | ||
.flatMap(_.fold[Task[Unit]](ZIO.unit)(c => actorSystem.receiveLoop(c.addr, c.port))) | ||
} yield actorSystem | ||
} | ||
|
||
/** | ||
* Type representing running instance of actor system provisioning actor herding, remoting and actor creation and | ||
* selection. | ||
*/ | ||
final class ActorSystem private[actors] ( | ||
override private[actors] val actorSystemName: String, | ||
override private[actors] val config: Option[String], | ||
private val remoteConfig: Option[RemoteConfig], | ||
private val initActorRefMap: Ref[Map[String, Actor[Any]]], | ||
private val parentActor: Option[String] | ||
) extends BaseActorSystem(actorSystemName, config, remoteConfig, parentActor) { | ||
|
||
override private[actors] def refActorMap[F[+_]]: Ref[Map[String, Actor[F]]] = | ||
initActorRefMap.asInstanceOf[Ref[Map[String, Actor[F]]]] | ||
|
||
override private[actors] def newActorSystem[F[+_]]( | ||
actorSystemName: String, | ||
config: Option[String], | ||
remoteConfig: Option[RemoteConfig], | ||
refActorMap: Ref[Map[String, Actor[F]]], | ||
parentActor: Option[String] | ||
): ActorSystem = | ||
new ActorSystem( | ||
actorSystemName, | ||
config, | ||
remoteConfig, | ||
refActorMap.asInstanceOf[Ref[Map[String, Actor[Any]]]], | ||
parentActor | ||
) | ||
|
||
override private[actors] def newChildrenRefSet[F[+_]]: UIO[Ref[Set[ActorRef[F]]]] = | ||
Ref.make(Set.empty[ActorRef[F]]) | ||
|
||
override private[actors] def newContext[F[+_]]( | ||
path: String, | ||
derivedSystem: ActorSystem, | ||
childrenSet: Ref[Set[ActorRef[F]]] | ||
): Context = new Context(path, derivedSystem, childrenSet.asInstanceOf[Ref[Set[ActorRef[Any]]]]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package zio.actors | ||
|
||
import zio.Ref | ||
|
||
/** | ||
* Context for actor used inside Stateful which provides self actor reference and actor creation/selection API | ||
*/ | ||
final class Context private[actors] ( | ||
private val path: String, | ||
private val actorSystem: ActorSystem, | ||
private val initChildrenRef: Ref[Set[ActorRef[Any]]] | ||
) extends BaseContext(path, actorSystem) { | ||
|
||
private[actors] def childrenRef[F[+_]]: Ref[Set[ActorRef[F]]] = initChildrenRef.asInstanceOf[Ref[Set[ActorRef[F]]]] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package zio.actors | ||
|
||
import zio.actors.ActorSystemUtils.* | ||
import zio.actors.ActorsConfig.* | ||
import zio.{ Ref, Task, UIO, ZIO } | ||
|
||
import java.io.* | ||
|
||
/** | ||
* Object providing constructor for Actor System with optional remoting module. | ||
*/ | ||
object ActorSystem { | ||
|
||
/** | ||
* Constructor for Actor System | ||
* | ||
* @param sysName | ||
* \- Identifier for Actor System | ||
* @param configFile | ||
* \- Optional configuration for a remoting internal module. If not provided the actor system will only handle local | ||
* actors in terms of actor selection. When provided - remote messaging and remote actor selection is possible | ||
* @return | ||
* instantiated actor system | ||
*/ | ||
def apply(sysName: String, configFile: Option[File] = None): Task[ActorSystem] = | ||
for { | ||
initActorRefMap <- Ref.make(Map.empty[String, Actor[?]]) | ||
config <- retrieveConfig(configFile) | ||
remoteConfig <- retrieveRemoteConfig(sysName, config) | ||
actorSystem <- ZIO.attempt(new ActorSystem(sysName, config, remoteConfig, initActorRefMap, parentActor = None)) | ||
_ <- ZIO | ||
.succeed(remoteConfig) | ||
.flatMap(_.fold[Task[Unit]](ZIO.unit)(c => actorSystem.receiveLoop(c.addr, c.port))) | ||
} yield actorSystem | ||
} | ||
|
||
/** | ||
* Type representing running instance of actor system provisioning actor herding, remoting and actor creation and | ||
* selection. | ||
*/ | ||
final class ActorSystem private[actors] ( | ||
override private[actors] val actorSystemName: String, | ||
override private[actors] val config: Option[String], | ||
private val remoteConfig: Option[RemoteConfig], | ||
private val initActorRefMap: Ref[Map[String, Actor[?]]], | ||
private val parentActor: Option[String] | ||
) extends BaseActorSystem(actorSystemName, config, remoteConfig, parentActor) { | ||
|
||
override private[actors] def refActorMap[F[+_]]: Ref[Map[String, Actor[F]]] = | ||
initActorRefMap.asInstanceOf[Ref[Map[String, Actor[F]]]] | ||
|
||
override private[actors] def newActorSystem[F[+_]]( | ||
actorSystemName: String, | ||
config: Option[String], | ||
remoteConfig: Option[RemoteConfig], | ||
refActorMap: Ref[Map[String, Actor[F]]], | ||
parentActor: Option[String] | ||
): ActorSystem = | ||
new ActorSystem( | ||
actorSystemName, | ||
config, | ||
remoteConfig, | ||
refActorMap.asInstanceOf[Ref[Map[String, Actor[?]]]], | ||
parentActor | ||
) | ||
|
||
override private[actors] def newChildrenRefSet[F[+_]]: UIO[Ref[Set[ActorRef[F]]]] = | ||
Ref.make(Set.empty[ActorRef[F]]) | ||
|
||
override private[actors] def newContext[F[+_]]( | ||
path: String, | ||
derivedSystem: ActorSystem, | ||
childrenSet: Ref[Set[ActorRef[F]]] | ||
): Context = new Context(path, derivedSystem, childrenSet.asInstanceOf[Ref[Set[ActorRef[?]]]]) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package zio.actors | ||
|
||
import zio.Ref | ||
|
||
/** | ||
* Context for actor used inside Stateful which provides self actor reference and actor creation/selection API | ||
*/ | ||
final class Context private[actors] ( | ||
private val path: String, | ||
private val actorSystem: ActorSystem, | ||
private val initChildrenRef: Ref[Set[ActorRef[?]]] | ||
) extends BaseContext(path, actorSystem) { | ||
|
||
override private[actors] def childrenRef[F[+_]]: Ref[Set[ActorRef[F]]] = | ||
initChildrenRef.asInstanceOf[Ref[Set[ActorRef[F]]]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.