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(
|
||||
Server.default,
|
||||
JwtScalaTokenService.live,
|
||||
CommandEngine.layer[ClientCommand, ClientEvent, ClientState],
|
||||
CommandEngine.layer[ContractCommand, ContractEvent, ContractState],
|
||||
ClientHandlers.layer,
|
||||
ContractHandlers.layer,
|
||||
ClientReducer.layer,
|
||||
ContractReducer.layer,
|
||||
ClientEventRepositoryInMemory.layer,
|
||||
ContractEventRepositoryInMemory.layer,
|
||||
ClientStateRepositoryInMemory.layer,
|
||||
ContractStateRepositoryInMemory.layer,
|
||||
ClientController.layer,
|
||||
ContractController.layer,
|
||||
PremiumServiceImpl.layer,
|
||||
EmployeeServiceImpl.layer
|
||||
CommandEngine.live[ClientCommand, ClientEvent, ClientState],
|
||||
CommandEngine.live[ContractCommand, ContractEvent, ContractState],
|
||||
ClientHandlers.live,
|
||||
ContractHandlers.live,
|
||||
ClientReducer.live,
|
||||
ContractReducer.live,
|
||||
ClientEventRepositoryInMemory.live,
|
||||
ContractEventRepositoryInMemory.live,
|
||||
ClientStateRepositoryInMemory.live,
|
||||
ContractStateRepositoryInMemory.live,
|
||||
ClientController.live,
|
||||
ContractController.live,
|
||||
PremiumServiceImpl.live,
|
||||
EmployeeServiceImpl.live
|
||||
)
|
||||
end App
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import zio.http.codec.PathCodec.path
|
|||
import zio.http.endpoint.*
|
||||
import zio.schema.*
|
||||
|
||||
import lu.foyer.auth.UserInfo
|
||||
|
||||
trait CommandEngineController[Command, Event: Schema, State: Schema] extends JsonApiController:
|
||||
|
||||
def commandEngine: CommandEngine[Command, Event, State]
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ class ClientController(val commandEngine: CommandEngine[ClientCommand, ClientEve
|
|||
override val allEntities = List("clients", "contracts")
|
||||
|
||||
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:
|
||||
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)
|
||||
|
||||
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")
|
||||
|
||||
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:
|
||||
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)
|
||||
|
||||
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")
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -92,5 +92,5 @@ class CommandEngine[Command, Event, State](
|
|||
end 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](_, _, _, _))
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ package clients
|
|||
import zio.*
|
||||
|
||||
object ClientHandlers:
|
||||
val layer: ULayer[List[CommandHandler[ClientCommand, ClientEvent, ClientState]]] =
|
||||
val live: ULayer[List[CommandHandler[ClientCommand, ClientEvent, ClientState]]] =
|
||||
ZLayer.succeed(
|
||||
List(
|
||||
CreateHandler,
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ class ClientReducer() extends Reducer[ClientEvent, ClientState]:
|
|||
case (s: ClientState.Actif, _: ClientEvent.Disabled) => s.disable()
|
||||
|
||||
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.*
|
||||
|
||||
object ContractHandlers:
|
||||
val layer =
|
||||
val live =
|
||||
ZLayer.fromFunction(
|
||||
(
|
||||
clientStateRepo: StateRepository[ClientState],
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ class ContractReducer() extends Reducer[ContractEvent, ContractState]:
|
|||
case (s: ContractState.PendingAmendment, _: ContractEvent.Terminated) => s.terminate()
|
||||
|
||||
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