Skip to content

Commit 1e148d3

Browse files
Use tabs for golang indentation
1 parent ec15040 commit 1e148d3

File tree

3 files changed

+39
-41
lines changed

3 files changed

+39
-41
lines changed

docs/extension/database.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ In order to work with the Postgres aggregate and stream projector a postgres Lis
66
import "github.com/hellofresh/goengine/extension/pq"
77

88
listener, err := pq.NewListener(
9-
s.PostgresDSN,
10-
string(projection.FromStream()),
11-
time.Millisecond,
12-
time.Second,
13-
s.GetLogger(),
9+
s.PostgresDSN,
10+
string(projection.FromStream()),
11+
time.Millisecond,
12+
time.Second,
13+
s.GetLogger(),
1414
)
1515
```
1616

docs/extension/logging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ In order to use [logrus] as your logger GoEngine provides a wrapper for both `*l
44

55
```golang
66
import (
7-
"github.com/hellofresh/goengine"
8-
goengineLogger "github.com/hellofresh/goengine/extension/logrus"
9-
"github.com/sirupsen/logrus"
7+
"github.com/hellofresh/goengine"
8+
goengineLogger "github.com/hellofresh/goengine/extension/logrus"
9+
"github.com/sirupsen/logrus"
1010
)
1111

1212
var logger goengine.Logger

docs/quick-start.md

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ var _ aggregate.Root = &BankAccount{}
1818

1919
// BankAccount a simple AggregateRoot representing a BankAccount
2020
type BankAccount struct {
21-
aggregate.BaseRoot
21+
aggregate.BaseRoot
2222

23-
accountID aggregate.ID
23+
accountID aggregate.ID
2424
}
2525

2626
// AggregateID returns the bank accounts aggregate.ID
@@ -39,7 +39,7 @@ Before we can implement the `OpenBankAccount` action we first need to define the
3939
```golang
4040
// BankAccountOpened a DomainEvent indicating that a bank account was opened
4141
type BankAccountOpened struct {
42-
AccountID aggregate.ID `json:"account_id"`
42+
AccountID aggregate.ID `json:"account_id"`
4343
}
4444
```
4545

@@ -85,17 +85,17 @@ import "errors"
8585

8686
// BankAccountCredited a DomainEvent indicating that a bank account was credited
8787
type BankAccountCredited struct {
88-
Amount uint `json:"amount"`
88+
Amount uint `json:"amount"`
8989
}
9090

9191
// BankAccountDebited a DomainEvent indicating that a bank account was debited
9292
type BankAccountDebited struct {
93-
Amount uint `json:"amount"`
93+
Amount uint `json:"amount"`
9494
}
9595

9696
type BankAccount struct {
97-
// ...
98-
balance uint
97+
// ...
98+
balance uint
9999
}
100100

101101
// Apply changes the state of the BankAccount based on the aggregate.Changed message
@@ -126,7 +126,6 @@ func (b *BankAccount) Withdraw(amount uint) error {
126126

127127
return aggregate.RecordChange(b, BankAccountDebited{Amount: amount})
128128
}
129-
130129
```
131130

132131
Great we are done with our bank account let's take a look at how we can store the aggregate root
@@ -156,11 +155,11 @@ type BankAccountRepository struct {
156155

157156
// NewBankAccountRepository create a new BankAccountRepository
158157
func NewBankAccountRepository(store goengine.EventStore, name goengine.StreamName) (
159-
*BankAccountRepository, error) {
160-
// Create a a aggregate.Type to allow the repository to reconstitute the BankAccount
158+
*BankAccountRepository, error) {
159+
// Create a a aggregate.Type to allow the repository to reconstitute the BankAccount
161160
bankAccountType, err := aggregate.NewType(BankAccountTypeName, func() aggregate.Root {
162-
return &BankAccount{}
163-
})
161+
return &BankAccount{}
162+
})
164163
if err != nil {
165164
return nil, err
166165
}
@@ -175,7 +174,7 @@ func NewBankAccountRepository(store goengine.EventStore, name goengine.StreamNam
175174

176175
// Get loads the bank account
177176
func (r *BankAccountRepository) Get(ctx context.Context, aggregateID aggregate.ID) (
178-
*BankAccount, error) {
177+
*BankAccount, error) {
179178
root, err := r.repo.GetAggregateRoot(ctx, aggregateID)
180179
if err != nil {
181180
return nil, err
@@ -190,7 +189,6 @@ func (r *BankAccountRepository) Get(ctx context.Context, aggregateID aggregate.I
190189
func (r *BankAccountRepository) Save(ctx context.Context, bankAccount *BankAccount) error {
191190
return r.repo.SaveAggregateRoot(ctx, bankAccount)
192191
}
193-
194192
```
195193

196194
Now that we have a BankAccountRepository we need to configure the Event Store which manages the events for that the aggregate root.
@@ -261,10 +259,10 @@ Great we now have a event store, aggregate repository and aggregate root so we c
261259

262260
```golang
263261
func main() {
264-
// ...
265-
ctx := context.Background()
266-
267-
myFirstBankAccount, err := OpenBankAccount()
262+
// ...
263+
ctx := context.Background()
264+
265+
myFirstBankAccount, err := OpenBankAccount()
268266
if err != nil {
269267
panic(err)
270268
}
@@ -336,24 +334,24 @@ func (p *BankTotalsProjection) Handlers() map[string]goengine.MessageHandler {
336334
Great now that we have our projection let's run it and listen to the event store.
337335
```golang
338336
import (
339-
"time"
337+
"time"
340338

341-
driverSQL "github.com/hellofresh/goengine/driver/sql"
342-
"github.com/hellofresh/goengine/extension/pq"
339+
driverSQL "github.com/hellofresh/goengine/driver/sql"
340+
"github.com/hellofresh/goengine/extension/pq"
343341
)
344342

345343
func main() {
346-
// ...
347-
348-
var manager postgres.SingleStreamStrategy
349-
350-
projector, err := manager.NewStreamProjector(
351-
"bank_account_projections",
352-
NewBankTotalsProjection(postgresDB),
353-
func(error, *driverSQL.ProjectionNotification) driverSQL.ProjectionErrorAction {
354-
return driverSQL.ProjectionFail
355-
},
356-
)
344+
// ...
345+
346+
var manager postgres.SingleStreamStrategy
347+
348+
projector, err := manager.NewStreamProjector(
349+
"bank_account_projections",
350+
NewBankTotalsProjection(postgresDB),
351+
func(error, *driverSQL.ProjectionNotification) driverSQL.ProjectionErrorAction {
352+
return driverSQL.ProjectionFail
353+
},
354+
)
357355
if err != nil {
358356
panic(err)
359357
}
@@ -364,7 +362,7 @@ func main() {
364362
}
365363

366364
if err := projector.RunAndListen(ctx, listener); err != nil {
367-
panic(err)
365+
panic(err)
368366
}
369367
}
370368
```

0 commit comments

Comments
 (0)