forked from Project-OSRM/osrm-backend
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use
struct embedding
to avoid interface forwarding
issue: #279
- Loading branch information
1 parent
04d3930
commit fedd283
Showing
16 changed files
with
86 additions
and
149 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
34 changes: 10 additions & 24 deletions
34
integration/service/oasis/stationfinder/cloudfinder/dest_station_finder.go
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 |
---|---|---|
@@ -1,49 +1,35 @@ | ||
package cloudfinder | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/Telenav/osrm-backend/integration/pkg/api/oasis" | ||
"github.com/Telenav/osrm-backend/integration/pkg/api/search/nearbychargestation" | ||
"github.com/Telenav/osrm-backend/integration/pkg/api/search/searchcoordinate" | ||
"github.com/Telenav/osrm-backend/integration/service/oasis/searchconnector" | ||
"github.com/Telenav/osrm-backend/integration/service/oasis/searchhelper" | ||
"github.com/Telenav/osrm-backend/integration/service/oasis/stationfinder/stationfindertype" | ||
) | ||
|
||
//@todo: This number need to be adjusted based on charge station profile | ||
const destMaxSearchCandidateNumber = 999 | ||
|
||
type destStationFinder struct { | ||
tnSearchConnector *searchconnector.TNSearchConnector | ||
oasisReq *oasis.Request | ||
searchResp *nearbychargestation.Response | ||
searchRespLock *sync.RWMutex | ||
bf *basicFinder | ||
oasisReq *oasis.Request | ||
*basicFinder | ||
} | ||
|
||
func NewDestStationFinder(sc *searchconnector.TNSearchConnector, oasisReq *oasis.Request) *destStationFinder { | ||
func newDestStationFinder(sc *searchconnector.TNSearchConnector, oasisReq *oasis.Request) *destStationFinder { | ||
obj := &destStationFinder{ | ||
oasisReq: oasisReq, | ||
bf: newBasicFinder(sc), | ||
oasisReq, | ||
newBasicFinder(sc), | ||
} | ||
obj.prepare() | ||
return obj | ||
} | ||
|
||
func (sf *destStationFinder) prepare() { | ||
func (dFinder *destStationFinder) prepare() { | ||
req, _ := searchhelper.GenerateSearchRequest( | ||
searchcoordinate.Coordinate{ | ||
Lat: sf.oasisReq.Coordinates[1].Lat, | ||
Lon: sf.oasisReq.Coordinates[1].Lon}, | ||
Lat: dFinder.oasisReq.Coordinates[1].Lat, | ||
Lon: dFinder.oasisReq.Coordinates[1].Lon}, | ||
destMaxSearchCandidateNumber, | ||
sf.oasisReq.MaxRange-sf.oasisReq.SafeLevel) | ||
sf.bf.getNearbyChargeStations(req) | ||
|
||
return | ||
} | ||
|
||
// NearbyStationsIterator provides channel which contains near by station information for dest | ||
func (sf *destStationFinder) IterateNearbyStations() <-chan *stationfindertype.ChargeStationInfo { | ||
return sf.bf.IterateNearbyStations() | ||
dFinder.oasisReq.MaxRange-dFinder.oasisReq.SafeLevel) | ||
dFinder.getNearbyChargeStations(req) | ||
} |
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
Oops, something went wrong.