mirror of
https://github.com/aljazceru/crawler_v2.git
synced 2025-12-17 07:24:21 +01:00
exported promote and demote funcs
This commit is contained in:
@@ -127,7 +127,7 @@ func arbiterScan(ctx context.Context, config ArbiterConfig, db redb.RedisDB, sen
|
|||||||
case graph.StatusActive:
|
case graph.StatusActive:
|
||||||
// active --> inactive
|
// active --> inactive
|
||||||
if ranks[i] < demotionThreshold {
|
if ranks[i] < demotionThreshold {
|
||||||
if err := demote(db, node.ID); err != nil {
|
if err := Demote(db, node.ID); err != nil {
|
||||||
return promoted, demoted, err
|
return promoted, demoted, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ func arbiterScan(ctx context.Context, config ArbiterConfig, db redb.RedisDB, sen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ranks[i] >= promotionThreshold && time.Since(added) > config.PromotionWait {
|
if ranks[i] >= promotionThreshold && time.Since(added) > config.PromotionWait {
|
||||||
if err := promote(db, node.ID); err != nil {
|
if err := Promote(db, node.ID); err != nil {
|
||||||
return promoted, demoted, err
|
return promoted, demoted, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,8 +172,8 @@ func minPagerank(ctx context.Context, db redb.RedisDB) (float64, error) {
|
|||||||
return float64(walks.N) / float64(total), nil
|
return float64(walks.N) / float64(total), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// demote removes all walks that start from the node and changes its status to inactive.
|
// Demote removes all walks that start from the node and changes its status to inactive.
|
||||||
func demote(db redb.RedisDB, node graph.ID) error {
|
func Demote(db redb.RedisDB, node graph.ID) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@@ -194,8 +194,8 @@ func demote(db redb.RedisDB, node graph.ID) error {
|
|||||||
return db.Demote(ctx, node)
|
return db.Demote(ctx, node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// promote generates random walks for the node and changes its status to active.
|
// Promote generates random walks for the node and changes its status to active.
|
||||||
func promote(db redb.RedisDB, node graph.ID) error {
|
func Promote(db redb.RedisDB, node graph.ID) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user