states are explicit

This commit is contained in:
Bel LaPointe
2022-01-27 17:27:08 -07:00
parent e19cd7095d
commit 5406250af3
7 changed files with 25 additions and 21 deletions

View File

@@ -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