Documentation ¶
Index ¶
- type City
- type DriverData
- func (d *DriverData) CreateIndex(collectionName string) error
- func (d *DriverData) DriversRedis(city, idDistrict string) []DriverData
- func (d *DriverData) Find(name string) *DriverData
- func (d *DriverData) GetAvailableDriver(city, idDistrict string) []DriverData
- func (d *DriverData) GetConn(mongoSession *mgo.Session, redisConnection *redis.Client)
- func (d *DriverData) GetLastDistrict(idDriver string) string
- func (d *DriverData) GetNearLocation(distance int64, lat, lon float64) []DriverData
- func (d *DriverData) Insert(collectionName string, name string, lat, lon float64, status bool)
- func (d *DriverData) InsertBulk(collectionName string, drivers []interface{}) error
- func (d *DriverData) Remove(idDriver, collectionKey string)
- func (d *DriverData) SaveDriversRedis(drivers []DriverData, city, idDistrict string)
- func (d *DriverData) SaveLastDistrict(idDriver, city, idDistrict string)
- func (d *DriverData) Update(city, idDistrict string, driver DriverData) error
- type GeoJson
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DriverData ¶
type DriverData struct { Id bson.ObjectId `json:"id" bson:"_id,omitempty"` Name string `json:"name"` Status bool `json:"status"` Location GeoJson `json:"location"` }
func (*DriverData) CreateIndex ¶
func (d *DriverData) CreateIndex(collectionName string) error
create index for location and status for speed read query.
func (*DriverData) DriversRedis ¶
func (d *DriverData) DriversRedis(city, idDistrict string) []DriverData
the format of the key is : city_district_id-mongodb return the Drivers data from redis
func (*DriverData) Find ¶
func (d *DriverData) Find(name string) *DriverData
func (*DriverData) GetAvailableDriver ¶
func (d *DriverData) GetAvailableDriver(city, idDistrict string) []DriverData
func (*DriverData) GetConn ¶
func (d *DriverData) GetConn(mongoSession *mgo.Session, redisConnection *redis.Client)
func (*DriverData) GetLastDistrict ¶
func (d *DriverData) GetLastDistrict(idDriver string) string
to get driver last location we used the date and their unique id from redis and get the
func (*DriverData) GetNearLocation ¶
func (d *DriverData) GetNearLocation(distance int64, lat, lon float64) []DriverData
get Near driver with given distance in meters
func (*DriverData) Insert ¶
func (d *DriverData) Insert(collectionName string, name string, lat, lon float64, status bool)
func (*DriverData) InsertBulk ¶
func (d *DriverData) InsertBulk(collectionName string, drivers []interface{}) error
func (*DriverData) Remove ¶
func (d *DriverData) Remove(idDriver, collectionKey string)
func (*DriverData) SaveDriversRedis ¶
func (d *DriverData) SaveDriversRedis(drivers []DriverData, city, idDistrict string)
the format of the key is : city_district_id-mongodb saves drivers data to redis
func (*DriverData) SaveLastDistrict ¶
func (d *DriverData) SaveLastDistrict(idDriver, city, idDistrict string)
saving the last location drivers in redis. the purpose is so that we can make sure the drivers data is not exist in the last collection, if in case the drivers go to new dristrict and update his status in new district.
func (*DriverData) Update ¶
func (d *DriverData) Update(city, idDistrict string, driver DriverData) error
update data if exist if not the insert it
Click to show internal directories.
Click to hide internal directories.