-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.go
More file actions
55 lines (43 loc) · 1.87 KB
/
app.go
File metadata and controls
55 lines (43 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package example
import (
"database/sql"
"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/domain"
"github.com/dogmatiq/example/integrations"
"github.com/dogmatiq/example/projections"
"github.com/dogmatiq/projectionkit/sqlprojection"
)
// AppKey is the example application's identity key.
const AppKey = "22028264-0bca-43e1-8d9d-cd094efb10b7"
// App is a dogma.Application implementation for the example "bank" domain.
type App struct {
AccountAggregate domain.AccountHandler
CustomerAggregate domain.CustomerHandler
DailyDebitLimitAggregate domain.DailyDebitLimitHandler
TransactionAggregate domain.TransactionHandler
DepositProcess domain.DepositProcessHandler
OpenAccountForNewCustomerProcess domain.OpenAccountForNewCustomerProcessHandler
TransferProcess domain.TransferProcessHandler
WithdrawalProcess domain.WithdrawalProcessHandler
ThirdPartyBank integrations.ThirdPartyBankIntegrationHandler
ReadDB *sql.DB
AccountProjection projections.AccountProjectionHandler
CustomerProjection projections.CustomerProjectionHandler
}
// Configure configures the Dogma engine for this application.
func (a *App) Configure(c dogma.ApplicationConfigurer) {
c.Identity("bank", AppKey)
c.Routes(
dogma.ViaAggregate(a.AccountAggregate),
dogma.ViaAggregate(a.CustomerAggregate),
dogma.ViaAggregate(a.DailyDebitLimitAggregate),
dogma.ViaAggregate(a.TransactionAggregate),
dogma.ViaProcess(a.DepositProcess),
dogma.ViaProcess(a.OpenAccountForNewCustomerProcess),
dogma.ViaProcess(a.TransferProcess),
dogma.ViaProcess(a.WithdrawalProcess),
dogma.ViaIntegration(a.ThirdPartyBank),
dogma.ViaProjection(sqlprojection.New(a.ReadDB, sqlprojection.SQLiteDriver, &a.AccountProjection)),
dogma.ViaProjection(sqlprojection.New(a.ReadDB, sqlprojection.SQLiteDriver, &a.CustomerProjection)),
)
}