Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #843 from sjmudd/smudd/promotion_rule_expiry
Browse files Browse the repository at this point in the history
Modify bulk-promotion-rules api call to return the promotion rule expiry timestamp
  • Loading branch information
Shlomi Noach authored Mar 24, 2019
2 parents 5f02604 + f5520ae commit 2c818cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions go/inst/candidate_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type CandidateDatabaseInstance struct {
Port int
PromotionRule CandidatePromotionRule
LastSuggestedString string
PromotionRuleExpiry string // generated when retrieved from database for consistency reasons
}

func NewCandidateDatabaseInstance(instanceKey *InstanceKey, promotionRule CandidatePromotionRule) *CandidateDatabaseInstance {
Expand Down
6 changes: 4 additions & 2 deletions go/inst/candidate_database_instance_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ func BulkReadCandidateDatabaseInstance() ([]CandidateDatabaseInstance, error) {
hostname,
port,
promotion_rule,
last_suggested
last_suggested,
last_suggested + INTERVAL ? MINUTE AS promotion_rule_expiry
FROM
candidate_database_instance
`
err := db.QueryOrchestrator(query, nil, func(m sqlutils.RowMap) error {
err := db.QueryOrchestrator(query, sqlutils.Args(config.Config.CandidateInstanceExpireMinutes), func(m sqlutils.RowMap) error {
cdi := CandidateDatabaseInstance{
Hostname: m.GetString("hostname"),
Port: m.GetInt("port"),
PromotionRule: CandidatePromotionRule(m.GetString("promotion_rule")),
LastSuggestedString: m.GetString("last_suggested"),
PromotionRuleExpiry: m.GetString("promotion_rule_expiry"),
}
// add to end of candidateDatabaseInstances
candidateDatabaseInstances = append(candidateDatabaseInstances, cdi)
Expand Down

0 comments on commit 2c818cb

Please sign in to comment.