-
Notifications
You must be signed in to change notification settings - Fork 26
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
[persistence] Add TaskQuotasConfiguration to workspace configuration #1751
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 StarTree Inc | ||
* | ||
* Licensed under the StarTree Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at http://www.startree.ai/legal/startree-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, | ||
* either express or implied. | ||
* See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package ai.startree.thirdeye.spi.api; | ||
|
||
public class TaskQuotasConfigurationApi { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's have a first level named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ie let's rename, we may want to put more quota values in this field that are not related to tasks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense. on it! |
||
|
||
private Long DetectionTaskQuota; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's have a more explicit name. quotas could be monthly rate, minutely rate, absolute number since account creation, per namespace, per user, etc... also it's non standard to start a field name with an UPPER character. let's use lower character. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no strong opinion on the name, but I'd go with something like
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ack |
||
private Long NotificationTaskQuota; | ||
|
||
public Long getDetectionTaskQuota() { | ||
return DetectionTaskQuota; | ||
} | ||
|
||
public TaskQuotasConfigurationApi setDetectionTaskQuota(final Long detectionTaskQuota) { | ||
this.DetectionTaskQuota = detectionTaskQuota; | ||
return this; | ||
} | ||
|
||
public Long getNotificationTaskQuota() { | ||
return NotificationTaskQuota; | ||
} | ||
|
||
public TaskQuotasConfigurationApi setNotificationTaskQuota(final Long notificationTaskQuota) { | ||
this.NotificationTaskQuota = notificationTaskQuota; | ||
return this; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2024 StarTree Inc | ||
* | ||
* Licensed under the StarTree Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at http://www.startree.ai/legal/startree-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, | ||
* either express or implied. | ||
* See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package ai.startree.thirdeye.spi.datalayer.dto; | ||
|
||
public class TaskQuotasConfigurationDTO { | ||
|
||
/** | ||
* Monthly quota for number of detection task runs | ||
*/ | ||
private Long DetectionTaskQuota; | ||
/** | ||
* Monthly quota for number of notification task runs | ||
*/ | ||
private Long NotificationTaskQuota; | ||
|
||
public Long getDetectionTaskQuota() { | ||
return DetectionTaskQuota; | ||
} | ||
|
||
public TaskQuotasConfigurationDTO setDetectionTaskQuota(final Long detectionTaskQuota) { | ||
this.DetectionTaskQuota = detectionTaskQuota; | ||
return this; | ||
} | ||
|
||
public Long getNotificationTaskQuota() { | ||
return NotificationTaskQuota; | ||
} | ||
|
||
public TaskQuotasConfigurationDTO setNotificationTaskQuota(final Long notificationTaskQuota) { | ||
this.NotificationTaskQuota = notificationTaskQuota; | ||
return this; | ||
} | ||
} |
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.
this will throw a NPE if updated.getTaskQuotasConfiguration() returns null.
Let's override equals properly in the Quota DTO, (in intelliJ: code --> generate --> equals and hashCode)
then let's just use
this will manage the case where .getTaskQuotasConfiguration() returns null and check all the fields, so it'll be more future proof if we ever add fields to the QuotaDto. (as long as
equals
is maintained correctly in the DTO but it's standard practice)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.
nice!
do we need to do this for the underlying taskQuotasConfigurationApi as well?
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.
but this equals will still fail if the object pointers are different
which will likely be the case since we are comparing two different objects
we need a way to just compare the values and not the pointers of objects or underlying fields
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.
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.
addressed all other feedback
will handle this one as a separate commit
do let me know if there are any other concerns
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.
please read
https://www.baeldung.com/java-equals-hashcode-contracts
and Effective Java items 10, 11, 12, 13
see an example of overriding here:
thirdeye/thirdeye-spi/src/main/java/ai/startree/thirdeye/spi/datalayer/dto/AnomalyDTO.java
Line 336 in c3fa292
but no need to write manually you can generate it, see message above
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 had to add the same to taskQuotasConfiguration as well. that's what was missing. Thank you!