package main

import (
	"context"

	"github.com/fiskerinc/cloud-services/services/optimus/controllers"
	"github.com/fiskerinc/cloud-services/services/optimus/server"

	"github.com/fiskerinc/cloud-services/pkg/kafka"
	"github.com/fiskerinc/cloud-services/pkg/logger"
	"github.com/fiskerinc/cloud-services/pkg/tracer"
	"github.com/fiskerinc/cloud-services/pkg/utils/app"
)

var (
	SERVICE_NAME = "optimus"
)

func init() {
	app.Setup(SERVICE_NAME, cleanup)
}

func main() {
	defer cleanup()
	tracer.Start()
	defer tracer.Stop()
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
	go controllers.HealthCheck()
	go server.StartHTTPServer()
	go server.StartConsumer(ctx, []string{kafka.VehicleData})
	select {}
}

func cleanup() {
	logger.Close()
}
