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.
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.
I don't think we need these to be juniper objects
There was a problem hiding this comment.
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.
To discuss: do we need both a WorkUpdated and a WorkPublished when publishing a book?
There was a problem hiding this comment.
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.
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.