This repository was archived by the owner on Dec 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Application Loader
Arsene edited this page Sep 10, 2020
·
3 revisions
The application loader defines how your lagom-pb/lagom based application should start. Two loading are available:
- the development mode (for local development)
- the production mode
To define the application loader, we must first define the application by extending the io.superflat.lagompb.BaseApplication.
Once the application is implemented then we can define the application loader by extending the com.lightbend.lagom.scaladsl.server.LagomApplicationLoader.
Example:
abstract class AccountApplication(context: LagomApplicationContext) extends BaseApplication(context) {
// Let us hook in the readSide Processor
lazy val accountRepository: AccountRepository =
wire[AccountRepository]
// wire up the various event and command handler
lazy val eventHandler: TypedEventHandler[BankAccount] = wire[AccountEventHandler]
lazy val commandHandler: TypedCommandHandler[BankAccount] = wire[AccountCommandHandler]
lazy val aggregate: AggregateRoot[BankAccount] = wire[AccountAggregate]
lazy val encryptor: ProtoEncryption = NoEncryption
override def aggregateRoot: AggregateRoot[_] = aggregate
override def server: LagomServer =
serverFor[AccountService](wire[AccountServiceImpl])
.additionalRouter(wire[AccountGrpcServiceImpl])
lazy val accountReadProcessor: AccountReadProcessor = wire[AccountReadProcessor]
lazy val kafkaPublisher: AccountKafkaPublisher = wire[AccountKafkaPublisher]
accountReadProcessor.init()
kafkaPublisher.init()
}
class AccountApplicationLoader extends LagomApplicationLoader {
override def load(context: LagomApplicationContext): LagomApplication =
new AccountApplication(context) with AkkaDiscoveryComponents
override def loadDevMode(context: LagomApplicationContext): LagomApplication =
new AccountApplication(context) with LagomDevModeComponents
override def describeService: Option[Descriptor] = Some(readDescriptor[AccountService])
}
Once you define the application make sure to add it to the application.conf as play.application.loader=<your-loader>
Example:
include "lagompb.conf"
play.application.loader=io.superflat.lagompb.samples.account.AccountApplicationLoaderCopyright © 2020 superflat