-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (28 loc) · 889 Bytes
/
main.go
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
package main
import (
"context"
"log"
"runtime"
"time"
"github.com/soumya-codes/airline-reservation-poc/config"
"github.com/soumya-codes/airline-reservation-poc/internal/booking"
"github.com/soumya-codes/airline-reservation-poc/internal/booking/seat"
pgtx "github.com/soumya-codes/airline-reservation-poc/internal/postgres/transaction"
)
func main() {
// Set the maximum number of CPUs that can be executing simultaneously.
runtime.GOMAXPROCS(8)
//cfg := config.DefaultConfig()
cfg := config.NewConfig(
config.WithTxIsolation(pgtx.ReadCommitted),
config.WithLockStrategy(seat.GetSeatWithSharedLock),
config.WithMaxConn(5),
config.WithMaxRetries(3),
)
ctx, cancelFunc := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancelFunc()
err := booking.BookSeats(ctx, cfg)
if err != nil {
log.Fatalf("Error running booking process: %v", err)
}
}