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

feat!: Add improved support for notifications and events #6

Merged
merged 6 commits into from
May 29, 2024

Conversation

mikeymike
Copy link
Contributor

This change brings improvements in Notification and event handling. This gives us better coverage for:

  • /events
  • /notifications
  • Webhook notifications

BREAKING CHANGE:

  • Event and NotificationsEvent are now an interfaces
  • NotificationsEvent has moved package to paddlenotification

BREAKING CHANGE:
  - `Event` and `NotificationsEvent` are now an interfaces
  - `NotificationsEvent` has moved package to paddlenotification
collection.go Outdated
if err != nil {
return err
}
c.results = append(c.results, &Res[T]{value: any(e).(T)})

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
type assertion must be checked (forcetypeassert)

collection.go Outdated
if err := json.Unmarshal(item, &t); err != nil {
return err
}
c.results = append(c.results, &Res[T]{value: t})

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
append only allowed to cuddle with appended value (wsl)

@vifer vifer requested a review from alecsammon May 24, 2024 14:35
if err != nil {
return err
}
c.results = append(c.results, &Res[T]{value: any(e).(T)}) //nolint:forcetypeassert // we know the type is correct.

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
append only allowed to cuddle with appended value (wsl)

if err := json.Unmarshal(item, &t); err != nil {
return err
}
c.results = append(c.results, &Res[T]{value: t}) //nolint:forcetypeassert // we know the type is correct.

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
append only allowed to cuddle with appended value (wsl)

@vifer vifer force-pushed the feature/notifications-and-events branch from b54ec2c to 82487b0 Compare May 27, 2024 08:37
collection.go Outdated
if err != nil {
return err
}

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
File is not gci-ed with --skip-generated -s standard -s prefix(github.com/PaddleHQ/paddle-go-sdk) -s prefix(github.com/PaddleHQ) -s default --custom-order (gci)

@vifer vifer force-pushed the feature/notifications-and-events branch 10 times, most recently from cbc6b9a to 0b06b2a Compare May 27, 2024 11:52
// here v could be used as concrete type TransactionUpdatedEvent
fmt.Println(v.EventID)
fmt.Println(v.Data.ID)
default:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thoughts about making a case for GenericEvent (I believe it should be this type of it's an event not handled by current SDK) and then having default as more of an unhandled case, log and error?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it depends of what we want to do with it, there might be cases where you only care about couple of events like we do in the example and the rest you just want to log it and nothing else.

Copy link
Contributor

Choose a reason for hiding this comment

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

Having a GenericEvent (or UnknownEvent?) is less disruptive than erroring.

If a new event is subscribed to, we wouldn't want that to potentially break an integration running in production. If the integrators implementation isn't handling a default case (or GenericEvent) there's still a chance that subscribing to a new event causes an error on their side, but perhaps lower risk?

In any case we should perhaps document that integrators handle "unknown events"

alecsammon
alecsammon previously approved these changes May 28, 2024
@vifer vifer force-pushed the feature/notifications-and-events branch from 0b06b2a to de769d0 Compare May 28, 2024 08:28
@vifer vifer marked this pull request as ready for review May 28, 2024 08:28
@vifer vifer requested a review from a team as a code owner May 28, 2024 08:28
@vifer vifer requested a review from alecsammon May 28, 2024 08:28
@vifer vifer enabled auto-merge (squash) May 28, 2024 09:10
@vifer vifer force-pushed the feature/notifications-and-events branch from de769d0 to ad03154 Compare May 28, 2024 15:59
@vifer vifer merged commit 000d871 into main May 29, 2024
5 checks passed
@vifer vifer deleted the feature/notifications-and-events branch May 29, 2024 06:53
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.

4 participants