-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from hearchco/refactor-search
refactor(search,bucket,sedefaults): better project structure
- Loading branch information
Showing
96 changed files
with
750 additions
and
646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package bucket | ||
|
||
import ( | ||
"github.com/hearchco/hearchco/src/search/engines" | ||
"github.com/hearchco/hearchco/src/search/result" | ||
) | ||
|
||
func MakeSEResult(urll string, title string, description string, searchEngineName engines.Name, sePage int, seOnPageRank int) *result.RetrievedResult { | ||
ser := result.RetrievedRank{ | ||
SearchEngine: searchEngineName, | ||
Rank: 0, | ||
Page: uint(sePage), | ||
OnPageRank: uint(seOnPageRank), | ||
} | ||
res := result.RetrievedResult{ | ||
URL: urll, | ||
Title: title, | ||
Description: description, | ||
Rank: ser, | ||
} | ||
return &res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package bucket | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/hearchco/hearchco/src/search/result" | ||
) | ||
|
||
type Relay struct { | ||
ResultMap map[string]*result.Result | ||
Mutex sync.RWMutex | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package bucket | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gocolly/colly/v2" | ||
"github.com/hearchco/hearchco/src/search/engines" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
func SetResultResponse(link string, response *colly.Response, relay *Relay, seName engines.Name) error { | ||
log.Trace(). | ||
Str("engine", seName.String()). | ||
Str("link", link). | ||
Msg("Got response") | ||
|
||
relay.Mutex.Lock() | ||
mapRes, exists := relay.ResultMap[link] | ||
|
||
if !exists { | ||
relay.Mutex.Unlock() | ||
relay.Mutex.RLock() | ||
err := fmt.Errorf("bucket.SetResultResponse(): URL not in map when adding response, should not be possible. URL: %v.\nRelay: %v", link, relay) | ||
relay.Mutex.RUnlock() | ||
return err | ||
} else { | ||
mapRes.Response = response | ||
relay.Mutex.Unlock() | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.