Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify ancla setup and startup #599

Merged

Conversation

denopink
Copy link
Contributor

@denopink denopink commented Dec 9, 2024

  • simplify ancla setup and startup with anclafx.Provide()

- simplify ancla setup and startup with `anclafx.Provide()`
@denopink denopink requested a review from maurafortino December 9, 2024 21:30
@denopink denopink self-assigned this Dec 9, 2024
Comment on lines -133 to -182
webhookConfig := in.WebhookConfig
webhookConfig.Logger = in.Logger
listenerMeasures := ancla.ListenerConfig{
Measures: *in.Measures,
}
webhookConfig.BasicClientConfig.HTTPClient = newHTTPClient(in.ArgusClientTimeout, in.Tracing)

svc, err := ancla.NewService(webhookConfig, sallust.Get)
if err != nil {
return out, fmt.Errorf("failed to initialize webhook service: %s", err)
}
out.GetAllWebhooksHandler = ancla.NewGetAllWebhooksHandler(in.AnclaSvc, ancla.HandlerConfig{})

stopWatches, err := svc.StartListener(listenerMeasures, sallust.With)
if err != nil {
return out, fmt.Errorf("webhook service start listener error: %s", err)
}
in.Logger.Info("Webhook service enabled")

in.Lifecycle.Append(fx.Hook{
OnStop: func(_ context.Context) error {
stopWatches()
return nil
},
})

out.GetAllWebhooksHandler = ancla.NewGetAllWebhooksHandler(svc, ancla.HandlerConfig{
GetLogger: sallust.Get,
})

checker, err := webhookConfig.Validation.BuildURLChecker()
checker, err := ancla.BuildURLChecker(in.WebhookConfig.Validation)
if err != nil {
return out, fmt.Errorf("failed to set up url checker for validation: %s", err)
}
validationOpts := webhookConfig.Validation.BuildOptions(checker)

out.AddWebhookHandler = ancla.NewAddWebhookHandler(svc, ancla.HandlerConfig{
V: validationOpts,
DisablePartnerIDs: webhookConfig.DisablePartnerIDs,
GetLogger: sallust.Get,
out.AddWebhookHandler = ancla.NewAddWebhookHandler(in.AnclaSvc, ancla.HandlerConfig{
V: in.WebhookConfig.Validation.BuildOptions(checker),
DisablePartnerIDs: in.WebhookConfig.DisablePartnerIDs,
})

v2Validators, err := v2WebhookValidators(webhookConfig)
v2Validators, err := v2WebhookValidators(in.WebhookConfig)
if err != nil {
return out, fmt.Errorf("failed to setup v2 webhook validators: %s", err)
}

out.V2AddWebhookHandler = ancla.NewAddWebhookHandler(svc, ancla.HandlerConfig{
out.V2AddWebhookHandler = ancla.NewAddWebhookHandler(in.AnclaSvc, ancla.HandlerConfig{
V: v2Validators,
DisablePartnerIDs: webhookConfig.DisablePartnerIDs,
GetLogger: sallust.Get,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be taken care of by anclafx.Provide()

@denopink denopink marked this pull request as draft December 9, 2024 21:36
@denopink
Copy link
Contributor Author

denopink commented Dec 9, 2024

pending potential changes from xmidt-org/ancla#269

@denopink denopink force-pushed the denopink/refactor/ancla-setup-and-startup branch from cfd4dc9 to 0a89a21 Compare December 9, 2024 21:45
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Please upload report for BASE (feat/caduceus-updates@850fff4). Learn more about missing BASE report.

Files with missing lines Patch % Lines
primaryHandler.go 0.00% 14 Missing ⚠️
main.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##             feat/caduceus-updates     #599   +/-   ##
========================================================
  Coverage                         ?   43.36%           
========================================================
  Files                            ?       16           
  Lines                            ?     1229           
  Branches                         ?        0           
========================================================
  Hits                             ?      533           
  Misses                           ?      684           
  Partials                         ?       12           
Flag Coverage Δ
unittests 43.36% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@denopink denopink marked this pull request as ready for review December 17, 2024 19:16
@denopink denopink merged commit 374af5f into feat/caduceus-updates Dec 17, 2024
16 checks passed
@denopink denopink deleted the denopink/refactor/ancla-setup-and-startup branch December 17, 2024 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant