Rename layer to live
This commit is contained in:
parent
96b3b77b79
commit
49d6b6c8cc
15 changed files with 27 additions and 29 deletions
|
|
@ -61,19 +61,19 @@ object App extends ZIOAppDefault:
|
||||||
override def run = app.provide(
|
override def run = app.provide(
|
||||||
Server.default,
|
Server.default,
|
||||||
JwtScalaTokenService.live,
|
JwtScalaTokenService.live,
|
||||||
CommandEngine.layer[ClientCommand, ClientEvent, ClientState],
|
CommandEngine.live[ClientCommand, ClientEvent, ClientState],
|
||||||
CommandEngine.layer[ContractCommand, ContractEvent, ContractState],
|
CommandEngine.live[ContractCommand, ContractEvent, ContractState],
|
||||||
ClientHandlers.layer,
|
ClientHandlers.live,
|
||||||
ContractHandlers.layer,
|
ContractHandlers.live,
|
||||||
ClientReducer.layer,
|
ClientReducer.live,
|
||||||
ContractReducer.layer,
|
ContractReducer.live,
|
||||||
ClientEventRepositoryInMemory.layer,
|
ClientEventRepositoryInMemory.live,
|
||||||
ContractEventRepositoryInMemory.layer,
|
ContractEventRepositoryInMemory.live,
|
||||||
ClientStateRepositoryInMemory.layer,
|
ClientStateRepositoryInMemory.live,
|
||||||
ContractStateRepositoryInMemory.layer,
|
ContractStateRepositoryInMemory.live,
|
||||||
ClientController.layer,
|
ClientController.live,
|
||||||
ContractController.layer,
|
ContractController.live,
|
||||||
PremiumServiceImpl.layer,
|
PremiumServiceImpl.live,
|
||||||
EmployeeServiceImpl.layer
|
EmployeeServiceImpl.live
|
||||||
)
|
)
|
||||||
end App
|
end App
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@ import zio.http.codec.PathCodec.path
|
||||||
import zio.http.endpoint.*
|
import zio.http.endpoint.*
|
||||||
import zio.schema.*
|
import zio.schema.*
|
||||||
|
|
||||||
import lu.foyer.auth.UserInfo
|
|
||||||
|
|
||||||
trait CommandEngineController[Command, Event: Schema, State: Schema] extends JsonApiController:
|
trait CommandEngineController[Command, Event: Schema, State: Schema] extends JsonApiController:
|
||||||
|
|
||||||
def commandEngine: CommandEngine[Command, Event, State]
|
def commandEngine: CommandEngine[Command, Event, State]
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,4 @@ class ClientController(val commandEngine: CommandEngine[ClientCommand, ClientEve
|
||||||
override val allEntities = List("clients", "contracts")
|
override val allEntities = List("clients", "contracts")
|
||||||
|
|
||||||
object ClientController:
|
object ClientController:
|
||||||
val layer = ZLayer.fromFunction(ClientController.apply)
|
val live = ZLayer.fromFunction(ClientController.apply)
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@ class ClientEventRepositoryInMemory(events: Ref[Map[String, Event[ClientEvent]]]
|
||||||
)
|
)
|
||||||
|
|
||||||
object ClientEventRepositoryInMemory:
|
object ClientEventRepositoryInMemory:
|
||||||
val layer = ZLayer.fromZIO(Ref.make(Map.empty).map(ClientEventRepositoryInMemory(_)))
|
val live = ZLayer.fromZIO(Ref.make(Map.empty).map(ClientEventRepositoryInMemory(_)))
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,4 @@ class ClientStateRepositoryInMemory(clients: Ref[Map[String, Entity[ClientState]
|
||||||
with InMemoryRepository[Entity[ClientState]](clients)
|
with InMemoryRepository[Entity[ClientState]](clients)
|
||||||
|
|
||||||
object ClientStateRepositoryInMemory:
|
object ClientStateRepositoryInMemory:
|
||||||
val layer = ZLayer.fromZIO(Ref.make(Map.empty).map(ClientStateRepositoryInMemory(_)))
|
val live = ZLayer.fromZIO(Ref.make(Map.empty).map(ClientStateRepositoryInMemory(_)))
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,4 @@ class ContractController(
|
||||||
override val allEntities = List("clients", "contracts")
|
override val allEntities = List("clients", "contracts")
|
||||||
|
|
||||||
object ContractController:
|
object ContractController:
|
||||||
val layer = ZLayer.fromFunction(ContractController.apply)
|
val live = ZLayer.fromFunction(ContractController.apply)
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@ class ContractEventRepositoryInMemory(events: Ref[Map[String, Event[ContractEven
|
||||||
)
|
)
|
||||||
|
|
||||||
object ContractEventRepositoryInMemory:
|
object ContractEventRepositoryInMemory:
|
||||||
val layer = ZLayer.fromZIO(Ref.make(Map.empty).map(ContractEventRepositoryInMemory(_)))
|
val live = ZLayer.fromZIO(Ref.make(Map.empty).map(ContractEventRepositoryInMemory(_)))
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,4 @@ class ContractStateRepositoryInMemory(clients: Ref[Map[String, Entity[ContractSt
|
||||||
with InMemoryRepository[Entity[ContractState]](clients)
|
with InMemoryRepository[Entity[ContractState]](clients)
|
||||||
|
|
||||||
object ContractStateRepositoryInMemory:
|
object ContractStateRepositoryInMemory:
|
||||||
val layer = ZLayer.fromZIO(Ref.make(Map.empty).map(ContractStateRepositoryInMemory(_)))
|
val live = ZLayer.fromZIO(Ref.make(Map.empty).map(ContractStateRepositoryInMemory(_)))
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,4 @@ object EmployeeServiceImpl extends EmployeeService:
|
||||||
)
|
)
|
||||||
else Left("Invalid Employee")
|
else Left("Invalid Employee")
|
||||||
|
|
||||||
val layer = ZLayer.succeed(EmployeeServiceImpl)
|
val live = ZLayer.succeed(EmployeeServiceImpl)
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,5 @@ object PremiumServiceImpl extends PremiumService:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val layer = ZLayer.succeed(PremiumServiceImpl)
|
val live = ZLayer.succeed(PremiumServiceImpl)
|
||||||
end PremiumServiceImpl
|
end PremiumServiceImpl
|
||||||
|
|
|
||||||
|
|
@ -92,5 +92,5 @@ class CommandEngine[Command, Event, State](
|
||||||
end CommandEngine
|
end CommandEngine
|
||||||
|
|
||||||
object CommandEngine:
|
object CommandEngine:
|
||||||
def layer[Command: Tag, Event: Tag, State: Tag] =
|
def live[Command: Tag, Event: Tag, State: Tag] =
|
||||||
ZLayer.fromFunction(CommandEngine[Command, Event, State](_, _, _, _))
|
ZLayer.fromFunction(CommandEngine[Command, Event, State](_, _, _, _))
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ package clients
|
||||||
import zio.*
|
import zio.*
|
||||||
|
|
||||||
object ClientHandlers:
|
object ClientHandlers:
|
||||||
val layer: ULayer[List[CommandHandler[ClientCommand, ClientEvent, ClientState]]] =
|
val live: ULayer[List[CommandHandler[ClientCommand, ClientEvent, ClientState]]] =
|
||||||
ZLayer.succeed(
|
ZLayer.succeed(
|
||||||
List(
|
List(
|
||||||
CreateHandler,
|
CreateHandler,
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,4 @@ class ClientReducer() extends Reducer[ClientEvent, ClientState]:
|
||||||
case (s: ClientState.Actif, _: ClientEvent.Disabled) => s.disable()
|
case (s: ClientState.Actif, _: ClientEvent.Disabled) => s.disable()
|
||||||
|
|
||||||
object ClientReducer:
|
object ClientReducer:
|
||||||
val layer: ULayer[Reducer[ClientEvent, ClientState]] = ZLayer.succeed(ClientReducer())
|
val live: ULayer[Reducer[ClientEvent, ClientState]] = ZLayer.succeed(ClientReducer())
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import lu.foyer.auth.UserInfo
|
||||||
import lu.foyer.clients.*
|
import lu.foyer.clients.*
|
||||||
|
|
||||||
object ContractHandlers:
|
object ContractHandlers:
|
||||||
val layer =
|
val live =
|
||||||
ZLayer.fromFunction(
|
ZLayer.fromFunction(
|
||||||
(
|
(
|
||||||
clientStateRepo: StateRepository[ClientState],
|
clientStateRepo: StateRepository[ClientState],
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,4 @@ class ContractReducer() extends Reducer[ContractEvent, ContractState]:
|
||||||
case (s: ContractState.PendingAmendment, _: ContractEvent.Terminated) => s.terminate()
|
case (s: ContractState.PendingAmendment, _: ContractEvent.Terminated) => s.terminate()
|
||||||
|
|
||||||
object ContractReducer:
|
object ContractReducer:
|
||||||
val layer: ULayer[Reducer[ContractEvent, ContractState]] = ZLayer.succeed(ContractReducer())
|
val live: ULayer[Reducer[ContractEvent, ContractState]] = ZLayer.succeed(ContractReducer())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue