Skip to content

refactor: simplify ancla setup and startup #599

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/xmidt-org/tr1d1um

go 1.21
go 1.23

require (
github.com/go-kit/kit v0.13.0
Expand All @@ -11,7 +11,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/xmidt-org/ancla v0.3.13-0.20241008222046-37a4b62a9fa8
github.com/xmidt-org/ancla v0.3.13-0.20241209210550-bcd326dfa238
github.com/xmidt-org/arrange v0.4.0
github.com/xmidt-org/bascule v0.11.6
github.com/xmidt-org/candlelight v0.1.19
Expand All @@ -34,14 +34,14 @@ require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
Expand All @@ -51,9 +51,9 @@ require (
github.com/klauspost/compress v1.17.9 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.5 // indirect
github.com/lestrrat-go/httprc v1.0.6 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx/v2 v2.0.21 // indirect
github.com/lestrrat-go/jwx/v2 v2.1.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand Down Expand Up @@ -89,11 +89,11 @@ require (
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/dig v1.18.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/grpc v1.65.0 // indirect
Expand Down
34 changes: 16 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -162,8 +162,8 @@ github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ4
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down Expand Up @@ -335,12 +335,12 @@ github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N
github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E=
github.com/lestrrat-go/httprc v1.0.5 h1:bsTfiH8xaKOJPrg1R+E3iE/AWZr/x0Phj9PBTG/OLUk=
github.com/lestrrat-go/httprc v1.0.5/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo=
github.com/lestrrat-go/httprc v1.0.6 h1:qgmgIRhpvBqexMJjA/PmwSvhNk679oqD1RbovdCGW8k=
github.com/lestrrat-go/httprc v1.0.6/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo=
github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=
github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
github.com/lestrrat-go/jwx/v2 v2.0.21 h1:jAPKupy4uHgrHFEdjVjNkUgoBKtVDgrQPB/h55FHrR0=
github.com/lestrrat-go/jwx/v2 v2.0.21/go.mod h1:09mLW8zto6bWL9GbwnqAli+ArLf+5M33QLQPDggkUWM=
github.com/lestrrat-go/jwx/v2 v2.1.2 h1:6poete4MPsO8+LAEVhpdrNI4Xp2xdiafgl2RD89moBc=
github.com/lestrrat-go/jwx/v2 v2.1.2/go.mod h1:pO+Gz9whn7MPdbsqSJzG8TlEpMZCwQDXnFJ+zsUVh8Y=
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
Expand Down Expand Up @@ -481,10 +481,8 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/xmidt-org/ancla v0.3.13-0.20241008222046-37a4b62a9fa8 h1:WjDZhfsOsz0sttiUOIf59zfSMlDF9+WQ0mOa5b7wZU8=
github.com/xmidt-org/ancla v0.3.13-0.20241008222046-37a4b62a9fa8/go.mod h1:rFd0rT41jSNx7lzVkF7JkIPLgVOx9WlXpYG+yRg0Mw8=
github.com/xmidt-org/ancla v0.3.13-0.20241108154956-ca4c7817340e h1:sq5BEeu3uZvkGDNEIvYrc3Go8Cl7YEx5pM3GRPx5J18=
github.com/xmidt-org/ancla v0.3.13-0.20241108154956-ca4c7817340e/go.mod h1:vk1pz4uivrZXbVwBxK7xYyb8lbmQ7O9GIPR5UMHnxt8=
github.com/xmidt-org/ancla v0.3.13-0.20241209210550-bcd326dfa238 h1:CCrUcd+UwMvSaizBnVNm/MntKoEeUvgE5inO8J3yW5I=
github.com/xmidt-org/ancla v0.3.13-0.20241209210550-bcd326dfa238/go.mod h1:uMF1DSs1J7pvgsbJl/+uPKCHyFJxGKiswz3XnDh2PVI=
github.com/xmidt-org/arrange v0.4.0 h1:DmJJTK58C44B4efyBV78SmMH0mn0G54n3caVn5BopUU=
github.com/xmidt-org/arrange v0.4.0/go.mod h1:MA1eKUZYxaSMIKJL3D/iJEMQruiefmhq+s5E9J4UJv0=
github.com/xmidt-org/bascule v0.11.6 h1:i46FAI97XPMt3OKraiNyKa+mt36AhLO8iuInAypXKNM=
Expand Down Expand Up @@ -584,8 +582,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -785,8 +783,8 @@ golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -798,8 +796,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
reducedTransactionLoggingCodesKey = "logging.reducedLoggingResponseCodes"
authAcquirerKey = "authAcquirer"
webhookConfigKey = "webhook"
anclaClientConfigKey = "webhook.BasicClientConfig"
tracingConfigKey = "tracing"
)

Expand Down Expand Up @@ -182,6 +183,7 @@
os.Exit(0)
}

l = l.With(zap.Time("ts", time.Now().UTC()), zap.Any("caller", zap.WithCaller(true)))
app := fx.New(
arrange.LoggerFunc(l.Sugar().Infof),
fx.Supply(l),
Expand All @@ -191,7 +193,7 @@
arrange.ProvideKey("argusClientTimeout", httpClientTimeout{}),
touchstone.Provide(),
touchhttp.Provide(),
ancla.ProvideMetrics(),

Check failure on line 196 in main.go

View workflow job for this annotation

GitHub Actions / ci / Build Go Program

undefined: ancla.ProvideMetrics

Check failure on line 196 in main.go

View workflow job for this annotation

GitHub Actions / ci / Go Unit Tests

undefined: ancla.ProvideMetrics
arrangepprof.HTTP{
RouterName: "server_pprof",
}.Provide(),
Expand All @@ -207,7 +209,7 @@
Target: configureArgusClientTimeout,
},
loadTracing,
newHTTPClient,
provideAnclaHTTPClient,
),
provideAuthChain("authx.inbound"),
provideServers(),
Expand Down
79 changes: 28 additions & 51 deletions primaryHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package main

import (
"context"
"errors"
"fmt"
"net"
Expand All @@ -17,7 +16,6 @@ import (
"github.com/xmidt-org/arrange"
"github.com/xmidt-org/bascule/acquire"
"github.com/xmidt-org/candlelight"
"github.com/xmidt-org/sallust"
"github.com/xmidt-org/touchstone"
"github.com/xmidt-org/touchstone/touchhttp"
"github.com/xmidt-org/tr1d1um/stat"
Expand Down Expand Up @@ -50,14 +48,20 @@ type authAcquirerConfig struct {

type provideWebhookHandlersIn struct {
fx.In
Lifecycle fx.Lifecycle
V *viper.Viper
WebhookConfig ancla.Config
Lifecycle fx.Lifecycle
V *viper.Viper
WebhookConfig ancla.Config
Logger *zap.Logger
Tracing candlelight.Tracing
Tf *touchstone.Factory
AnclaSvc *ancla.ClientService
}

type provideAnclaHTTPClientIn struct {
fx.In

ArgusClientTimeout httpClientTimeout `name:"argus_client_timeout"`
Logger *zap.Logger
Measures *chrysom.Measures
Tracing candlelight.Tracing
Tf *touchstone.Factory
}

type provideWebhookHandlersOut struct {
Expand All @@ -84,6 +88,10 @@ type ServiceOptionsOut struct {
TranslationServiceOptions *translation.ServiceOptions
}

func provideAnclaHTTPClient(in provideAnclaHTTPClientIn) chrysom.HTTPClient {
return newHTTPClient(in.ArgusClientTimeout, in.Tracing)
}

func newHTTPClient(timeouts httpClientTimeout, tracing candlelight.Tracing) *http.Client {
var transport http.RoundTripper = &http.Transport{
Dial: (&net.Dialer{
Expand Down Expand Up @@ -114,72 +122,40 @@ func createAuthAcquirer(config authAcquirerConfig) (acquire.Acquirer, error) {
}

func v2WebhookValidators(c ancla.Config) ([]webhook.Option, error) {
checker, err := c.Validation.BuildURLChecker()
checker, err := ancla.BuildURLChecker(c.Validation)
if err != nil {
return nil, err
}
v := c.Validation.BuildOptions(checker)

return v, nil
return c.Validation.BuildOptions(checker), nil
}

func provideWebhookHandlers(in provideWebhookHandlersIn) (out provideWebhookHandlersOut, err error) {
// Webhooks (if not configured, handlers are not set up)
if !in.V.IsSet(webhookConfigKey) {
if !in.V.IsSet(anclaClientConfigKey) {
in.Logger.Info("Webhook service disabled")
return
}

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,
Comment on lines -133 to -182
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()

DisablePartnerIDs: in.WebhookConfig.DisablePartnerIDs,
})

in.Logger.Info("Webhook service enabled")
Expand All @@ -191,6 +167,7 @@ func provideHandlers() fx.Option {
arrange.ProvideKey(authAcquirerKey, authAcquirerConfig{}),
fx.Provide(
arrange.UnmarshalKey(webhookConfigKey, ancla.Config{}),
arrange.UnmarshalKey(anclaClientConfigKey, chrysom.BasicClientConfig{}),
arrange.UnmarshalKey("prometheus", touchstone.Config{}),
arrange.UnmarshalKey("prometheus.handler", touchhttp.Config{}),
provideWebhookHandlers,
Expand Down
8 changes: 3 additions & 5 deletions tr1d1um.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,9 @@ webhook:
# (Optional). Defaults to 'simple'.
JWTParserType: "raw"
BasicClientConfig:
# listen is the subsection that configures the listening feature of the argus client
# pullInterval provides how often the current webhooks list gets refreshed.
# (Optional)
listen:
# pullInterval provides how often the current webhooks list gets refreshed.
pullInterval: 5s
pullInterval: 5s

# bucket is the partition name where webhooks will be stored.
bucket: "webhooks"
Expand All @@ -218,7 +216,7 @@ webhook:
auth:
# basic configures basic authentication for argus.
# Must be of form: 'Basic xyz=='
basic: "Basic dXNlcjpwYXNz"
# basic: "Basic dXNlcjpwYXNz"
#
# # jwt configures jwt style authentication for argus.
# JWT:
Expand Down
Loading