Skip to content

Commit

Permalink
feat: integrate pendo client
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Visiedo <[email protected]>
  • Loading branch information
avisiedo authored and pvoborni committed Aug 15, 2024
1 parent 7f1902b commit 7f31fe8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cmd/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
impl_service "github.com/podengo-project/idmsvc-backend/internal/infrastructure/service/impl"
"github.com/podengo-project/idmsvc-backend/internal/interface/client/rbac"
client_inventory "github.com/podengo-project/idmsvc-backend/internal/usecase/client/inventory"
client_pendo "github.com/podengo-project/idmsvc-backend/internal/usecase/client/pendo"
client_rbac "github.com/podengo-project/idmsvc-backend/internal/usecase/client/rbac"
)

Expand Down Expand Up @@ -53,7 +54,8 @@ func main() {
ctx, cancel := startSignalHandler(context.Background())
inventory := client_inventory.NewHostInventory(cfg)
rbac := initRbacWrapper(ctx, cfg)
s := impl_service.NewApplication(ctx, wg, cfg, db, inventory, rbac)
pendo := client_pendo.NewClient(cfg)
s := impl_service.NewApplication(ctx, wg, cfg, db, inventory, rbac, pendo)
if e := s.Start(); e != nil {
panic(e)
}
Expand Down
5 changes: 4 additions & 1 deletion internal/handler/impl/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/podengo-project/idmsvc-backend/internal/config"
"github.com/podengo-project/idmsvc-backend/internal/handler"
client_inventory "github.com/podengo-project/idmsvc-backend/internal/interface/client/inventory"
client_pendo "github.com/podengo-project/idmsvc-backend/internal/interface/client/pendo"
client_rbac "github.com/podengo-project/idmsvc-backend/internal/interface/client/rbac"
"github.com/podengo-project/idmsvc-backend/internal/interface/interactor"
"github.com/podengo-project/idmsvc-backend/internal/interface/presenter"
Expand Down Expand Up @@ -41,9 +42,10 @@ type application struct {
hostconfjwk hostconfJwkComponent
db *gorm.DB
inventory client_inventory.HostInventory
pendo client_pendo.Pendo
}

func NewHandler(config *config.Config, db *gorm.DB, m *metrics.Metrics, inventory client_inventory.HostInventory, rbac client_rbac.Rbac) handler.Application {
func NewHandler(config *config.Config, db *gorm.DB, m *metrics.Metrics, inventory client_inventory.HostInventory, rbac client_rbac.Rbac, pendo client_pendo.Pendo) handler.Application {
if config == nil {
panic("config is nil")
}
Expand Down Expand Up @@ -75,5 +77,6 @@ func NewHandler(config *config.Config, db *gorm.DB, m *metrics.Metrics, inventor
host: hc,
hostconfjwk: hcjc,
inventory: inventory,
pendo: pendo,
}
}
14 changes: 12 additions & 2 deletions internal/infrastructure/service/impl/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
handler_impl "github.com/podengo-project/idmsvc-backend/internal/handler/impl"
"github.com/podengo-project/idmsvc-backend/internal/infrastructure/service"
client_inventory "github.com/podengo-project/idmsvc-backend/internal/interface/client/inventory"
client_pendo "github.com/podengo-project/idmsvc-backend/internal/interface/client/pendo"
client_rbac "github.com/podengo-project/idmsvc-backend/internal/interface/client/rbac"
"github.com/podengo-project/idmsvc-backend/internal/metrics"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -26,7 +27,7 @@ type svcApplication struct {
// AdditionalService service.ApplicationService
}

func NewApplication(ctx context.Context, wg *sync.WaitGroup, cfg *config.Config, db *gorm.DB, inventory client_inventory.HostInventory, rbac client_rbac.Rbac) service.ApplicationService {
func NewApplication(ctx context.Context, wg *sync.WaitGroup, cfg *config.Config, db *gorm.DB, inventory client_inventory.HostInventory, rbac client_rbac.Rbac, pendo client_pendo.Pendo) service.ApplicationService {
if ctx == nil {
panic("ctx is nil")
}
Expand All @@ -39,6 +40,15 @@ func NewApplication(ctx context.Context, wg *sync.WaitGroup, cfg *config.Config,
if db == nil {
panic("db is nil")
}
if inventory == nil {
panic("inventory is nil")
}
if rbac == nil {
panic("rbac is nil")
}
if pendo == nil {
panic("pendo is nil")
}

s := &svcApplication{}
s.Config = cfg
Expand All @@ -49,7 +59,7 @@ func NewApplication(ctx context.Context, wg *sync.WaitGroup, cfg *config.Config,
metrics := metrics.NewMetrics(reg)

// Create application handlers
handler := handler_impl.NewHandler(s.Config, db, metrics, inventory, rbac)
handler := handler_impl.NewHandler(s.Config, db, metrics, inventory, rbac, pendo)

// Create Metrics service
s.Metrics = NewMetrics(s.Context, s.WaitGroup, s.Config, handler)
Expand Down

0 comments on commit 7f31fe8

Please sign in to comment.