diff --git a/go/inst/candidate_database_instance.go b/go/inst/candidate_database_instance.go index 3bf192192..708f6af4d 100644 --- a/go/inst/candidate_database_instance.go +++ b/go/inst/candidate_database_instance.go @@ -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 { diff --git a/go/inst/candidate_database_instance_dao.go b/go/inst/candidate_database_instance_dao.go index 2bf8f842c..99fe07ba8 100644 --- a/go/inst/candidate_database_instance_dao.go +++ b/go/inst/candidate_database_instance_dao.go @@ -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)