Skip to content
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

Improve timerange validation for retransmission from view #1916

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

faderskd
Copy link
Contributor

@faderskd faderskd commented Oct 17, 2024

What's changed?

When requesting retransmission from view, the user has already prepared proper events, so they should not provide additional time range for this retransmission. For simplicity of logic, the rules are as follows:

  1. For topic table retransmission both start/end timestamps are required.
  2. For view retransmission start/end timestamps must be empty

Basic validation for retransmission (proper parameters, timerange validation, empty checks etc.) is done via Jakarta constraint validators. Any other validation related to persistent state in Zookeeper is done later in the retransmission service.

What's new

As a part of the PR, I've also added possibility of attaching link to the offline retransmission from view documentation, visible in retransmission popup.
Screenshot 2024-10-18 at 11 37 09

bartekdrobczyk
bartekdrobczyk previously approved these changes Oct 23, 2024
@@ -80,4 +82,11 @@ public OfflineRetransmissionRequest getRequest() {
public String toString() {
return "OfflineRetransmissionTask{" + "taskId='" + taskId + '\'' + ", request=" + request + '}';
}

private static String parseTimestamp(@Nullable Instant startTimestamp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe just timestamp as a parameter name since there is passed both startTimestamp and endTimestamp to this function, WDYT?

import jakarta.validation.ConstraintValidatorContext;
import pl.allegro.tech.hermes.api.OfflineRetransmissionRequest;

public class ProperTimeRangePresentForTopicRetransmissionValidator
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can remove Present and Proper from this name? I think that context would rename the same and we would shorten it a little bit 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({TYPE})
@Constraint(validatedBy = TimeRangeAbsentForViewRetransmissionValidator.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is personal opinion, but I think that we can remove Absent from this name. I am not familiar with the pattern of specifying how the validator should behave, and what it should accept in its name. Thanks to this the name would be shorter and more readable in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, fixed


import java.time.Instant

class RetransmissionTimeRangeValidatorTest extends Specification {
Copy link
Contributor

Choose a reason for hiding this comment

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

well written tests 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants