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

Add registration valid until data in event. #125

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type Registration struct {
// StatusCode holds the HTTP status code returned by the webhook registration.
StatusCode int

// Until holds the time the registration expires if applicable.
Until time.Time

// Err holds any error that occurred while performing the registration.
Err error
}
Expand All @@ -51,6 +54,7 @@ func (r Registration) String() string {
buf.WriteString(fmt.Sprintf(" Duration: %s\n", r.Duration.String()))
buf.WriteString(fmt.Sprintf(" Body: '%s'\n", string(r.Body)))
buf.WriteString(fmt.Sprintf(" StatusCode: %d\n", r.StatusCode))
buf.WriteString(fmt.Sprintf(" Until: %s\n", r.Until.Format(time.RFC3339)))
buf.WriteString(fmt.Sprintf(" Err: %v\n", r.Err))
buf.WriteString("}\n")

Expand Down
1 change: 1 addition & 0 deletions event/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestString(t *testing.T) {
" Duration: 0s\n" +
" Body: ''\n" +
" StatusCode: 0\n" +
" Until: 0001-01-01T00:00:00Z\n" +
" Err: <nil>\n" +
"}\n",
}, {
Expand Down
1 change: 1 addition & 0 deletions listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func (l *Listener) register(locked bool) error {
evnt.StatusCode = resp.StatusCode

if resp.StatusCode == http.StatusOK {
evnt.Until = evnt.At.Add(time.Duration(l.registration.Duration))
return l.dispatch(evnt)
}

Expand Down