Skip to content

Commit

Permalink
The acual cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
masv3971 committed Oct 11, 2024
1 parent 9d8ab15 commit b24099d
Show file tree
Hide file tree
Showing 93 changed files with 918 additions and 3,154 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
"eduseal",
"ehic",
"eidas",
"envconfig",
"gofakeit",
"gonic",
"goretask",
"gosdjwt",
"gosunetca",
"grpcserver",
"httphelpers",
"Karlsson",
"kvclient",
"Ladok",
"lithammer",
"masv",
"messagebroker",
"MIMEJSON",
"mockas",
"moogar",
Expand All @@ -39,6 +43,7 @@
"SDJWT",
"sdktrace",
"semconv",
"shortuuid",
"simplequeue",
"skatteverket",
"stretchr",
Expand Down
48 changes: 19 additions & 29 deletions cmd/apigw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import (
"vc/internal/apigw/httpserver"
"vc/internal/apigw/inbound"
"vc/internal/apigw/outbound"
"vc/internal/apigw/simplequeue"
"vc/pkg/configuration"
"vc/pkg/kvclient"
"vc/pkg/logger"
"vc/pkg/trace"
)
Expand All @@ -22,47 +20,38 @@ type service interface {
Close(ctx context.Context) error
}

var GitCommit string

func main() {
var wg sync.WaitGroup
ctx := context.Background()

services := make(map[string]service)

cfg, err := configuration.Parse(ctx, logger.NewSimple("Configuration"))
var (
wg = &sync.WaitGroup{}
ctx = context.Background()
services = make(map[string]service)
serviceName string = "apigw"
)

cfg, err := configuration.New(ctx)
if err != nil {
panic(err)
}

log, err := logger.New("vc_apigw", cfg.Common.Log.FolderPath, cfg.Common.Production)
if err != nil {
panic(err)
}
tracer, err := trace.New(ctx, cfg, log, "vc", "apigw")
log, err := logger.New(serviceName, cfg.Common.Log.FolderPath, cfg.Common.Production)
if err != nil {
panic(err)
}

kvClient, err := kvclient.New(ctx, cfg, tracer, log.New("kvClient"))
services["kvClient"] = kvClient
if err != nil {
panic(err)
}
dbService, err := db.New(ctx, cfg, tracer, log.New("db"))
services["dbService"] = dbService
// main function log
mainLog := log.New("main")

tracer, err := trace.New(ctx, cfg, serviceName, log)
if err != nil {
panic(err)
}

simpleQueueService, err := simplequeue.New(ctx, kvClient, tracer, cfg, log.New("queue"))
services["queueService"] = simpleQueueService
dbService, err := db.New(ctx, cfg, tracer, log)
services["dbService"] = dbService
if err != nil {
panic(err)
}

mainLog := log.New("main")

var eventPublisher apiv1.EventPublisher
if cfg.IsAsyncEnabled(mainLog) {
var err error
Expand All @@ -73,18 +62,19 @@ func main() {
}
}

apiv1Client, err := apiv1.New(ctx, kvClient, dbService, simpleQueueService, tracer, cfg, log.New("apiv1"))
apiv1Client, err := apiv1.New(ctx, dbService, tracer, cfg, log)
if err != nil {
panic(err)
}
httpService, err := httpserver.New(ctx, cfg, apiv1Client, tracer, log.New("httpserver"), eventPublisher)

httpService, err := httpserver.New(ctx, cfg, apiv1Client, tracer, eventPublisher, log)
services["httpService"] = httpService
if err != nil {
panic(err)
}

if cfg.IsAsyncEnabled(mainLog) {
eventConsumer, err := inbound.New(ctx, cfg, log.New("eventConsumer"), apiv1Client, tracer)
eventConsumer, err := inbound.New(ctx, cfg, apiv1Client, tracer, log.New("eventConsumer"))
services["eventConsumer"] = eventConsumer
if err != nil {
panic(err)
Expand Down
30 changes: 17 additions & 13 deletions cmd/issuer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,49 @@ type service interface {
}

func main() {
var wg sync.WaitGroup
ctx := context.Background()

services := make(map[string]service)

cfg, err := configuration.Parse(ctx, logger.NewSimple("Configuration"))
var (
wg = &sync.WaitGroup{}
ctx = context.Background()
services = make(map[string]service)
serviceName string = "issuer"
)

cfg, err := configuration.New(ctx)
if err != nil {
panic(err)
}

log, err := logger.New("vc_issuer", cfg.Common.Log.FolderPath, cfg.Common.Production)
log, err := logger.New(serviceName, cfg.Common.Log.FolderPath, cfg.Common.Production)
if err != nil {
panic(err)
}

tracer, err := trace.New(ctx, cfg, log, "vc", "issuer")
// main function log
mainLog := log.New("main")

tracer, err := trace.New(ctx, cfg, serviceName, log)
if err != nil {
panic(err)
}

auditLogService, err := auditlog.New(ctx, cfg, log.New("auditlog"))
auditLogService, err := auditlog.New(ctx, cfg, log)
services["auditLogService"] = auditLogService
if err != nil {
panic(err)
}

apiv1Client, err := apiv1.New(ctx, auditLogService, cfg, tracer, log.New("apiv1"))
apiv1Client, err := apiv1.New(ctx, auditLogService, cfg, tracer, log)
if err != nil {
panic(err)
}

httpService, err := httpserver.New(ctx, cfg, apiv1Client, tracer, log.New("httpserver"))
httpService, err := httpserver.New(ctx, cfg, apiv1Client, tracer, log)
services["httpService"] = httpService
if err != nil {
panic(err)
}

grpcService, err := grpcserver.New(ctx, cfg, apiv1Client, log.New("grpcserver"))
grpcService, err := grpcserver.New(ctx, cfg, apiv1Client, log)
services["grpcService"] = grpcService
if err != nil {
panic(err)
Expand All @@ -69,7 +74,6 @@ func main() {

<-termChan // Blocks here until interrupted

mainLog := log.New("main")
mainLog.Info("HALTING SIGNAL!")

for serviceName, service := range services {
Expand Down
24 changes: 14 additions & 10 deletions cmd/mockas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,32 @@ type service interface {
}

func main() {
var wg sync.WaitGroup
ctx := context.Background()

services := make(map[string]service)

cfg, err := configuration.Parse(ctx, logger.NewSimple("Configuration"))
var (
wg = &sync.WaitGroup{}
ctx = context.Background()
services = make(map[string]service)
serviceName string = "mockas"
)

cfg, err := configuration.New(ctx)
if err != nil {
panic(err)
}

log, err := logger.New("vc_mock_as", cfg.Common.Log.FolderPath, cfg.Common.Production)
log, err := logger.New(serviceName, cfg.Common.Log.FolderPath, cfg.Common.Production)
if err != nil {
panic(err)
}

tracer, err := trace.New(ctx, cfg, log, "vc", "mock_as")
// main function log
mainLog := log.New("main")

tracer, err := trace.New(ctx, cfg, serviceName, log)
if err != nil {
panic(err)
}

apiv1Client, err := apiv1.New(ctx, cfg, tracer, log.New("apiv1"))
apiv1Client, err := apiv1.New(ctx, cfg, tracer, log)
if err != nil {
panic(err)
}
Expand All @@ -50,7 +55,6 @@ func main() {
panic(err)
}

mainLog := log.New("main")
if cfg.IsAsyncEnabled(mainLog) {
eventConsumer, err := inbound.New(ctx, cfg, log.New("eventConsumer"), apiv1Client, tracer)
services["eventConsumer"] = eventConsumer
Expand Down
44 changes: 17 additions & 27 deletions cmd/persistent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import (
"vc/internal/persistent/apiv1"
"vc/internal/persistent/db"
"vc/internal/persistent/httpserver"
"vc/internal/persistent/simplequeue"
"vc/pkg/configuration"
"vc/pkg/kvclient"
"vc/pkg/logger"
"vc/pkg/trace"
)
Expand All @@ -21,51 +19,44 @@ type service interface {
}

func main() {
var wg sync.WaitGroup
ctx := context.Background()

services := make(map[string]service)

cfg, err := configuration.Parse(ctx, logger.NewSimple("Configuration"))
var (
wg = &sync.WaitGroup{}
ctx = context.Background()
services = make(map[string]service)
serviceName string = "persistent"
)

cfg, err := configuration.New(ctx)
if err != nil {
panic(err)
}

log, err := logger.New("vc_persistent", cfg.Common.Log.FolderPath, cfg.Common.Production)
if err != nil {
panic(err)
}
tracer, err := trace.New(ctx, cfg, log, "vc_persistent", "cache")
log, err := logger.New(serviceName, cfg.Common.Log.FolderPath, cfg.Common.Production)
if err != nil {
panic(err)
}

kvClient, err := kvclient.New(ctx, cfg, tracer, log.New("kvClient"))
services["kvClient"] = kvClient
// main function log
mainLog := log.New("main")

tracer, err := trace.New(ctx, cfg, serviceName, log)
if err != nil {
log.Error(err, "kvClient")
panic(err)
}
dbService, err := db.New(ctx, cfg, tracer, log.New("db"))

dbService, err := db.New(ctx, cfg, tracer, log)
services["dbService"] = dbService
if err != nil {
log.Error(err, "dbService")
panic(err)
}

queueService, err := simplequeue.New(ctx, kvClient, dbService, tracer, cfg, log.New("queue"))
services["queueService"] = queueService
if err != nil {
log.Error(err, "queueService")
panic(err)
}

apiv1Client, err := apiv1.New(ctx, kvClient, dbService, tracer, cfg, log.New("apiv1"))
apiv1Client, err := apiv1.New(ctx, dbService, tracer, cfg, log)
if err != nil {
log.Error(err, "apiv1Client")
panic(err)
}
httpService, err := httpserver.New(ctx, cfg, apiv1Client, tracer, log.New("httpserver"))
httpService, err := httpserver.New(ctx, cfg, apiv1Client, tracer, log)
services["httpService"] = httpService
if err != nil {
panic(err)
Expand All @@ -77,7 +68,6 @@ func main() {

<-termChan // Blocks here until interrupted

mainLog := log.New("main")
mainLog.Info("HALTING SIGNAL!")

for serviceName, service := range services {
Expand Down
Loading

0 comments on commit b24099d

Please sign in to comment.