states are explicit
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
type NTGVision struct {
|
||||
searcher interface {
|
||||
search(states []config.State) (io.ReadCloser, error)
|
||||
searchStates(states []config.State) (io.ReadCloser, error)
|
||||
searchJobReadCloser(id int64) (io.ReadCloser, error)
|
||||
}
|
||||
}
|
||||
@@ -187,8 +187,8 @@ func (ntg NTGVision) searchJob(id int64) (ntgVisionJobInfo, error) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (ntg NTGVision) Search(states []config.State) ([]Job, error) {
|
||||
rc, err := ntg.searcher.search(states)
|
||||
func (ntg NTGVision) SearchStates(states []config.State) ([]Job, error) {
|
||||
rc, err := ntg.searcher.searchStates(states)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -226,20 +226,20 @@ func setNTGToken(token string) {
|
||||
db.Set(getNTGTokenKey(), []byte(token))
|
||||
}
|
||||
|
||||
func (ntg NTGVision) search(states []config.State) (io.ReadCloser, error) {
|
||||
func (ntg NTGVision) searchStates(states []config.State) (io.ReadCloser, error) {
|
||||
if getNTGToken() == "" {
|
||||
logtr.Debugf("NTG token is empty, refreshing ntg auth")
|
||||
if err := ntg.refreshAuth(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
rc, err := ntg._search(states)
|
||||
rc, err := ntg._searchStates(states)
|
||||
if err == ErrNoAuth {
|
||||
logtr.Debugf("err no auth on search, refreshing ntg auth")
|
||||
if err := ntg.refreshAuth(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rc, err = ntg._search(states)
|
||||
rc, err = ntg._searchStates(states)
|
||||
}
|
||||
return rc, err
|
||||
}
|
||||
@@ -285,7 +285,7 @@ func (ntg NTGVision) _refreshAuth() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ntg NTGVision) _search(states []config.State) (io.ReadCloser, error) {
|
||||
func (ntg NTGVision) _searchStates(states []config.State) (io.ReadCloser, error) {
|
||||
request, err := ntg.newRequest(states)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user