-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
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)}) |
There was a problem hiding this comment.
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}) |
There was a problem hiding this comment.
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 != nil { | ||
return err | ||
} | ||
c.results = append(c.results, &Res[T]{value: any(e).(T)}) //nolint:forcetypeassert // we know the type is correct. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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)
b54ec2c
to
82487b0
Compare
collection.go
Outdated
if err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
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)
cbc6b9a
to
0b06b2a
Compare
// here v could be used as concrete type TransactionUpdatedEvent | ||
fmt.Println(v.EventID) | ||
fmt.Println(v.Data.ID) | ||
default: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
0b06b2a
to
de769d0
Compare
de769d0
to
ad03154
Compare
This change brings improvements in Notification and event handling. This gives us better coverage for:
/events
/notifications
BREAKING CHANGE:
Event
andNotificationsEvent
are now an interfacesNotificationsEvent
has moved package to paddlenotification