-
Notifications
You must be signed in to change notification settings - Fork 16
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
6336 Make central record processor generic #6337
6336 Make central record processor generic #6337
Conversation
let changelog_repo = ChangelogRepository::new(&ctx.connection); | ||
let cursor_controller = CursorController::new(KeyType::ContactFormProcessorCursor); | ||
|
||
let cursor_controller = CursorController::new(processor.cursor_type()); |
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.
processor now defines cursor_type and changelog_filter
server/service/src/processors/mod.rs
Outdated
@@ -29,14 +30,14 @@ const CHANNEL_BUFFER_SIZE: usize = 30; | |||
pub struct ProcessorsTrigger { | |||
requisition_transfer: Sender<()>, | |||
invoice_transfer: Sender<()>, | |||
contact_form_to_email: Sender<()>, | |||
central_record: Sender<CentralRecordProcessorType>, |
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.
When triggered we specify which central record type should be processed
@@ -27,21 +26,39 @@ pub(crate) enum ProcessCentralRecordsError { | |||
|
|||
const CHANGELOG_BATCH_SIZE: u32 = 20; | |||
|
|||
#[derive(Clone)] | |||
pub enum CentralRecordProcessorType { |
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.
Type is used because processor will be triggered in generic way, and need to specify which records to process
/// Extra check to see if processor should trigger, like if it's central for contact form email | ||
fn should_run(&self) -> bool { | ||
true | ||
} |
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.
If it's the central server processor, shouldn't it always only run on central server?
impl CentralRecordProcessorType { | ||
pub(super) fn get_processor(&self) -> Box<dyn CentralServerProcessor> { | ||
match self { | ||
CentralRecordProcessorType::ContactFormEmail => Box::new(QueueContactEmailProcessor), |
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.
Should we keep the capability to have multiple processors for the same record type, like we have for invoices?
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 feel like the transfer processors are a bit different, because:
They prepare data in a particular shape before processors run (maybe can be done with some generic, but a bit complex for now ?)
I think we can use the cursor increase function of this generic processors also for transfers, you are right ! I'll have a little go at this now, won't spend too long on it though
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 can use the cursor increase function of this generic processors also for transfers, you are right ! I'll have a little go at this now, won't spend too long on it though
Actually I am getting a bit worried with 'order of operation', so will keep existing transfer logic as is for now
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.
Thanks for this Andrei, knew this needed a little cleaning up π
This feels now like it's just a Processor - we could consolidate the requisition and invoice processors into this one (with should_run always true) - or it should actually just be central only?
@lache-melvin thanks for your review, here is the change for the renaming: c666f7d (sorry now git is confused, and can't seem to recognise that file was moved and changed, in overall diff, but that diff looks ok) I think we can use this 'Processor' in requisition and invoice transfers, but thought to not change too much and was worried a little bit about ordering. The // fn try_process_record(
fn prepare_record_for processing(&self) -> T // Get all the pre requisite records ready to pass to ProcessRecordFucntion
fn get_process_record_functions(&sefl) ->Vec<Box<dyn ProcessRecordFunction<T>>>> {
// ...
// The above should work but when it comes to Box Processor, need to actually specify "T" (so stuck on that) |
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.
LGTM, thanks for changes π
impl ProcessorType { | ||
pub(super) fn get_processor(&self) -> Box<dyn Processor> { | ||
match self { | ||
ProcessorType::ContactFormEmail => Box::new(QueueContactEmailProcessor), |
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.
Only thought is whether this should support a vec of processors, like we have for invoices etc... there might end up being multiple things we want to process with the contact form? But guess we can add that when we get there π
Fixes #6336
π©π»βπ» What does this PR do?
Allow for central record processor to be generic.
Expand central record processor trait to have extra methods:
change_log_table_names
changelogs_filter
cursor_type
should_run
Processor trigger accepts type of central record processor
Relocated processor files to be more structured (now that there is central processor, it lives in parent dir and has contact form as child)
π Any notes for the reviewer?
π§ͺ Testing