driver

package
v0.0.0-...-14e87fa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2017 License: MIT Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type City

type City struct {
	Name string  `json:"name"`
	Lat  float64 `json:"lat"`
	Lon  float64 `json:"lon"`
}

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

type GeoJson

type GeoJson struct {
	Type        string    `json:"type"`
	Coordinates []float64 `json:"coordinates"`
}

struct for storing geo location in mongodb

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL