Skip to content

wip(taskbroker): Add consumer step to resend delayed task to kafka #297

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

john-z-yang
Copy link
Member

@john-z-yang john-z-yang commented Apr 7, 2025

TODO:

  • Make parameters configurable
  • Separate our 3 kafka configs better (consumer config, producer for retry config, producer for delayed tasks config)
  • Determine if there's a better retry behaviour when kafka producer fail to write delayed tasks.
  • Add some tests for the 3 reducer steps

Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 0% with 98 lines in your changes missing coverage. Please review.

Project coverage is 82.22%. Comparing base (02e887f) to head (9c42502).

Files with missing lines Patch % Lines
src/kafka/kafka_writer.rs 0.00% 91 Missing ⚠️
src/main.rs 0.00% 5 Missing ⚠️
src/kafka/activation_store_writer.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #297      +/-   ##
==========================================
- Coverage   84.30%   82.22%   -2.08%     
==========================================
  Files          20       21       +1     
  Lines        3771     3866      +95     
==========================================
  Hits         3179     3179              
- Misses        592      687      +95     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@john-z-yang john-z-yang force-pushed the john/reroute-delay-task branch from c4367d5 to 1aa01ea Compare April 7, 2025 23:56
@john-z-yang john-z-yang force-pushed the john/reroute-delay-task branch from 1aa01ea to 9c42502 Compare April 7, 2025 23:57
@john-z-yang john-z-yang changed the title feat(taskbroker): Add consumer step to resend delayed task to kafka wip(taskbroker): Add consumer step to resend delayed task to kafka Apr 8, 2025
store: Arc<InflightActivationStore>,
batch: Option<Vec<InflightActivation>>,
}

impl InflightActivationWriter {
pub fn new(store: Arc<InflightActivationStore>, config: ActivationWriterConfig) -> Self {
impl ActivationStoreWriter {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should deprecate 'inflightactivation' 🤔 we'll need a term to disambiguate the protobuf form and the sqlite mapped struct though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree

let (ready_activations, delayed_activations): (Vec<_>, Vec<_>) = take(&mut self.batch)
.unwrap()
.into_iter()
.partition(|_| true);
Copy link
Member

Choose a reason for hiding this comment

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

We'll need a field in the protobuf to make this work for real. Options I've thought of are countdown and runafter 🤷

Comment on lines +83 to +98
let deliveries = payloads
.into_iter()
.map(|payload| {
let producer = self.producer.clone();
let config = self.config.clone();
async move {
producer
.send(
FutureRecord::<(), Vec<u8>>::to(&config.kafka_topic)
.payload(&payload),
Timeout::After(Duration::from_millis(config.kafka_send_timeout_ms)),
)
.await
}
})
.collect::<FuturesUnordered<_>>();
Copy link
Member

Choose a reason for hiding this comment

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

We have this pattern in a few places now, should we try making a function for it?

Copy link
Member Author

Choose a reason for hiding this comment

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

We should, they're all slightly different tho. So we need to be clever with our abstraction.

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