Skip to content

Commit

Permalink
优化index的init
Browse files Browse the repository at this point in the history
  • Loading branch information
M09Ic committed Jan 10, 2023
1 parent 880b11e commit 75236c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ func NewPool(ctx context.Context, config *pkg.Config) (*Pool, error) {
pool.Statistor.Counts[bl.Status] = 1
}

if _, ok := pool.Statistor.Sources[bl.Source]; ok {
pool.Statistor.Sources[bl.Source]++
} else {
pool.Statistor.Sources[bl.Source] = 1
}

var params map[string]interface{}
if pool.MatchExpr != nil || pool.FilterExpr != nil || pool.RecuExpr != nil {
params = map[string]interface{}{
Expand Down Expand Up @@ -172,7 +178,7 @@ type Pool struct {
func (pool *Pool) Init() error {
// 分成两步是为了避免闭包的线程安全问题
pool.initwg.Add(2)
pool.reqPool.Invoke(newUnit("", InitIndexSource))
pool.reqPool.Invoke(newUnit(pool.url.Path, InitIndexSource))
pool.reqPool.Invoke(newUnit(pool.safePath(pkg.RandPath()), InitRandomSource))
pool.initwg.Wait()
if pool.index.ErrString != "" {
Expand Down

0 comments on commit 75236c7

Please sign in to comment.