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

Webhook notifications #884

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

vmanilo
Copy link

@vmanilo vmanilo commented May 26, 2022

Draft

Copy link
Member

@asutula asutula left a comment

Choose a reason for hiding this comment

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

Nice work so far. The way you've written the code is easy to follow and understand, so I don't have many comments on the code for now (this is a good thing).

I see you injected the Notifier into the deals module. That is a fine place to start, but I'm guessing there will be a different place we may want to leverage the Notifier, or at least an additional place or two.

If I'm remembering things correctly, the Scheduler will be a very good place to use Notifier. The Scheduler manages all things related to storing, retrieving, renewing and repairing deals. For this reason, it will be a source for many notifications. I'd imagine those events might be higher level with less detailed information, so maybe we augment those notifications with finer grained notifications from the deals module or any other module that makes sense.

So, sounds like we should dig into the Scheduler and understand how it works and how notifications fit in.

ffs/types.go Outdated Show resolved Hide resolved

type WebhookAlert struct {
Type string
Threshold string
Copy link
Member

Choose a reason for hiding this comment

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

Curious to see what you're thinking for Threshold use cases. Sounds interesting.

Copy link
Member

@asutula asutula left a comment

Choose a reason for hiding this comment

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

Coming along really nicely. It seems like everywhere you're integrating the notifier into the system makes sense to me. I like the implementation of the notifier and the way you define notification types, process events, and calculate notification to send. Nice work.

@@ -38,6 +38,7 @@ type RetrievalAction struct {
Miners []string
WalletAddress string
MaxPrice uint64
Notifications []*ffs.NotificationConfig
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why this addition is only in RetreivalAction and not StorageAction, but maybe I'll learn this later in my review.

Copy link
Author

Choose a reason for hiding this comment

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

StorageAction already contains ffs.StorageConfig, which has Notifications []*NotificationConfig

https://github.com/textileio/powergate/pull/884/files#diff-c9cfa7a6e3661251bc9aec6067691ec59f7f9b166127bd8757502e3b8223d0e4R141

ffs/scheduler/internal/sjstore/sjstore.go Show resolved Hide resolved
notifications/events.go Show resolved Hide resolved
notifications/events.go Outdated Show resolved Hide resolved
notifications/final_job_status.go Outdated Show resolved Hide resolved
notifications/notifier.go Outdated Show resolved Hide resolved
Comment on lines +9 to +13
type configStore struct {
sync.RWMutex

configs map[ffs.JobID][]*ffs.NotificationConfig
}
Copy link
Member

Choose a reason for hiding this comment

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

Will this need to write to a persistent store (database) at some point?

Copy link
Author

Choose a reason for hiding this comment

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

yes, I think at some point would be better to put it to persistent store, for the beginning I guess we can keep it in memory

depends_on:
- ipfs
- lotus
environment:
- POWD_DEVNET=true
- POWD_LOTUSHOST=/dns4/lotus/tcp/7777
- POWD_IPFSAPIADDR=/dns4/ipfs/tcp/5001
- POW_GATEWAYHOSTADDR=0.0.0.0:7001
Copy link
Member

Choose a reason for hiding this comment

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

Just curious why these changes popped up (and in docker-compose.yaml as well). Maybe something you needed for local testing? If it's generally useful, feel free to keep the changes.

Copy link
Author

Choose a reason for hiding this comment

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

yes, it's just for local testing, would need to revert it back
when I tested locally found that on my laptop some battery management uses this port :)

@vmanilo vmanilo marked this pull request as ready for review July 20, 2022 20:40
@vmanilo vmanilo requested a review from asutula July 20, 2022 20:42
@vmanilo vmanilo changed the title Draft: webhook notifications Webhook notifications Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants