-
Notifications
You must be signed in to change notification settings - Fork 12
Feature/webhooks pt1 #668
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
base: launch/v1.0.0
Are you sure you want to change the base?
Feature/webhooks pt1 #668
Conversation
This reverts commit 99ca79e. DB table not required: send events to Redis directly
…tation is called (working)
… runs, config missing)
thoth-api/src/graphql/model.rs
Outdated
| Work::create(&context.db, &data).map_err(|e| e.into()) | ||
| let result = Work::create(&context.db, &data).map_err(|e| e.into()); | ||
|
|
||
| if let Ok(created_work) = result.clone() { |
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.
no need to clone here, you can just reference created_work: if let Ok(ref created_work) = result
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 don't think we need these to be juniper objects
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.
thoth-api/src/graphql/model.rs
Outdated
| // update the work and, if it succeeds, synchronise its children statuses and pub. date | ||
| match work.update(&context.db, &data, &account_id) { | ||
| Ok(w) => { | ||
| let _ = send_event(&context.redis, EventType::WorkUpdated, &w).await; |
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.
To discuss: do we need both a WorkUpdated and a WorkPublished when publishing a book?
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.
Actually, I don't think we do. I think we should just trigger one event, since if a Work is published, that implies it was updated.
From the broker's perspective, we'd want to avoid double processing the same change.
thoth-api/src/event/handler.rs
Outdated
| is_published: work.is_active_withdrawn_superseded(), | ||
| event_timestamp: work.updated_at, | ||
| }; | ||
| lpush(redis, QUEUE_KEY, &serde_json::to_string(&event)?).await |
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 think we'd want a rpush here so we implement a FIFO queue, ie. RPUSH/LPOP
…and hard-coded URL)
…karound and hard-coded URL)" This reverts commit a7d9fb2.
…L (tested, working)
No description provided.