Skip to content

Webhook notifications#884

Open
vmanilo wants to merge 7 commits into
textileio:masterfrom
vmanilo:webhook-notification
Open

Webhook notifications#884
vmanilo wants to merge 7 commits into
textileio:masterfrom
vmanilo:webhook-notification

Conversation

@vmanilo
Copy link
Copy Markdown

@vmanilo vmanilo commented May 26, 2022

Draft

Copy link
Copy Markdown
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.

Comment thread ffs/types.go
Comment thread ffs/types.go

type WebhookAlert struct {
Type string
Threshold string
Copy link
Copy Markdown
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
Copy Markdown
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.

Miners []string
WalletAddress string
MaxPrice uint64
Notifications []*ffs.NotificationConfig
Copy link
Copy Markdown
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
Copy Markdown
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

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

configs map[ffs.JobID][]*ffs.NotificationConfig
}
Copy link
Copy Markdown
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
Copy Markdown
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

- POWD_DEVNET=true
- POWD_LOTUSHOST=/dns4/lotus/tcp/7777
- POWD_IPFSAPIADDR=/dns4/ipfs/tcp/5001
- POW_GATEWAYHOSTADDR=0.0.0.0:7001
Copy link
Copy Markdown
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
Copy Markdown
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