Skip to content

Commit

Permalink
updated newmatcher and newsink based off PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maurafortino committed May 1, 2024
1 parent 5fb8dba commit cbc2cbd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions internal/sink/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ type CommonWebhook struct {
logger *zap.Logger
}

func NewMatcher(l Listener, logger *zap.Logger) (matcher Matcher, version int, err error) {
func NewMatcher(l Listener, logger *zap.Logger) (matcher Matcher, err error) {
switch v := l.(type) {
case *ListenerV1:
m := &MatcherV1{}
m.logger = logger
if err := m.update(*v); err != nil {
return nil, 0, err
return nil, err
}
matcher = m
return matcher, 1, nil
return matcher, nil
default:
return nil, 0, fmt.Errorf("invalid listner")
return nil, fmt.Errorf("invalid listner")
}
}

Expand Down
12 changes: 7 additions & 5 deletions internal/sink/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ type WebhookV1 struct {
// clientMiddleware func(http.Client) http.Client
}

func NewSink(c Config, logger *zap.Logger, id string, version int) Sink {
func NewSink(c Config, logger *zap.Logger, listener Listener) Sink {
var sink Sink
if version == 1 {
v1 := &WebhookV1{
id: id,
switch l := listener.(type) {
case *ListenerV1:
sink = &WebhookV1{
id: l.GetId(),
deliveryInterval: c.DeliveryInterval,
deliveryRetries: c.DeliveryRetries,
logger: logger,
}
sink = v1
default:
return nil
}
return sink
}
Expand Down
5 changes: 2 additions & 3 deletions internal/sink/sinkSender.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ func NewSender(w *wrapper, l Listener) (s *sender, err error) {
}

func (s *sender) Update(l Listener) (err error) {
var version int
s.matcher, version, err = NewMatcher(l, s.logger)
s.sink = NewSink(s.config, s.logger, s.id, version)
s.matcher, err = NewMatcher(l, s.logger)
s.sink = NewSink(s.config, s.logger)

Check failure on line 163 in internal/sink/sinkSender.go

View workflow job for this annotation

GitHub Actions / ci / Build Go Program

not enough arguments in call to NewSink

Check failure on line 163 in internal/sink/sinkSender.go

View workflow job for this annotation

GitHub Actions / ci / Go Unit Tests

not enough arguments in call to NewSink

s.renewalTimeGauge.Set(float64(time.Now().Unix()))

Expand Down

0 comments on commit cbc2cbd

Please sign in to comment.