Moarr work!
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import com.devsoap.dbt.DBTModule
|
||||
import com.devsoap.dbt.app.DatabaseService
|
||||
import com.devsoap.dbt.config.DBTConfig
|
||||
import com.devsoap.dbt.DBTManager
|
||||
import com.devsoap.dbt.handlers.ExecutorHandler
|
||||
import com.devsoap.dbt.handlers.LedgerHandler
|
||||
import com.devsoap.dbt.services.LedgerService
|
||||
|
||||
import com.devsoap.dbt.services.TransactionManagerService
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.h2.jdbcx.JdbcDataSource
|
||||
import ratpack.config.ConfigData
|
||||
import ratpack.session.SessionModule
|
||||
|
||||
import javax.sql.DataSource
|
||||
|
||||
@@ -14,41 +16,29 @@ import static ratpack.groovy.Groovy.ratpack
|
||||
ratpack {
|
||||
|
||||
serverConfig {
|
||||
|
||||
/**
|
||||
* DBT Framework config
|
||||
*/
|
||||
require("", DBTConfig)
|
||||
sysProps()
|
||||
require('/dbt', DBTConfig)
|
||||
}
|
||||
|
||||
bindings {
|
||||
bindInstance(new ObjectMapper())
|
||||
|
||||
module SessionModule
|
||||
module (DBTModule) {
|
||||
it.ledger.remoteUrl = 'http://localhost:5050/ledger'
|
||||
it.executor.remoteUrl = 'http://localhost:5050/executor'
|
||||
}
|
||||
|
||||
bindInstance(DataSource, new JdbcDataSource(url: 'jdbc:h2:mem:dbtdb;DB_CLOSE_DELAY=-1', user: ''))
|
||||
bindInstance(new DatabaseService())
|
||||
|
||||
|
||||
/**
|
||||
* DBT Framework manager
|
||||
*/
|
||||
bind(DBTManager)
|
||||
bind(LedgerService)
|
||||
bind(ExecutorHandler)
|
||||
bind(LedgerHandler)
|
||||
bind DatabaseService
|
||||
}
|
||||
|
||||
handlers {
|
||||
|
||||
/**
|
||||
* DBT Framework handlers
|
||||
*/
|
||||
path('executor', ExecutorHandler)
|
||||
path('ledger', LedgerHandler)
|
||||
|
||||
/**
|
||||
* Consumer services
|
||||
*/
|
||||
get('frontend') {
|
||||
get(DBTManager).execute { transaction ->
|
||||
get(TransactionManagerService).execute { transaction ->
|
||||
transaction.query("INSERT INTO LOGS(LOG_ID,LOG_VALUE) VALUES (${new Random().nextInt()}, 'HELLO')")
|
||||
}.then {
|
||||
redirect("/gateway/${it['id'].textValue()}")
|
||||
@@ -56,7 +46,7 @@ ratpack {
|
||||
}
|
||||
|
||||
get('gateway/:transactionId?') {
|
||||
get(DBTManager).execute(pathTokens.transactionId, { transaction ->
|
||||
get(TransactionManagerService).execute(pathTokens.transactionId, { transaction ->
|
||||
transaction.query("INSERT INTO LOGS(LOG_ID,LOG_VALUE) VALUES (${new Random().nextInt()}, 'WORLD')")
|
||||
}).then {
|
||||
redirect("/gateway2/${it['id'].textValue()}")
|
||||
@@ -64,7 +54,7 @@ ratpack {
|
||||
}
|
||||
|
||||
get('gateway2/:transactionId?') {
|
||||
get(DBTManager).execute(pathTokens.transactionId, { transaction ->
|
||||
get(TransactionManagerService).execute(pathTokens.transactionId, { transaction ->
|
||||
transaction.query("SELECT * FROM LOGS")
|
||||
transaction.complete()
|
||||
}).then {
|
||||
|
||||
Reference in New Issue
Block a user