mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-02 00:11:56 +03:00
fix: tighten ScoutConnCollected encapsulation and add concurrency test
- Move error check before Snapshot() to avoid unnecessary allocation - Update existing tests to use Snapshot() instead of direct field access - Add TestConcurrentAddSnapshot to explicitly exercise the mutex
This commit is contained in:
@@ -61,10 +61,14 @@ func (s Scout) learn(ctx context.Context, url string) (ScoutResult, error) {
|
||||
client.CloseIdleConnections()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return ScoutResult{}, err
|
||||
}
|
||||
|
||||
data, writeIndex := results.Snapshot()
|
||||
|
||||
if err != nil || len(data) == 0 {
|
||||
return ScoutResult{}, err
|
||||
if len(data) == 0 {
|
||||
return ScoutResult{}, nil
|
||||
}
|
||||
|
||||
var result ScoutResult
|
||||
|
||||
Reference in New Issue
Block a user