Documentation ¶
Overview ¶
Package clientgeo supports interfaces to different data sources to help identify client geo location for server selection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadLatLonFormat is returned with a lat,lon header is missing or corrupt. ErrBadLatLonFormat = errors.New("lat,lon format was missing or corrupt") // ErrNullLatLon is returned with a 0,0 lat/lon value is provided. ErrNullLatLon = errors.New("lat,lon value was null: " + nullLatLon) )
var ( ErrNoUserParameters = errors.New("no user location parameters provided") ErrUnusableUserParameters = errors.New("user provided location parameters were unusable") )
Error values returned by Locate.
Functions ¶
This section is empty.
Types ¶
type AppEngineLocator ¶
type AppEngineLocator struct{}
AppEngineLocator finds a client location using AppEngine headers for lat/lon, region, or country.
func NewAppEngineLocator ¶
func NewAppEngineLocator() *AppEngineLocator
NewAppEngineLocator creates a new AppEngineLocator.
func (*AppEngineLocator) Locate ¶
func (sl *AppEngineLocator) Locate(req *http.Request) (*Location, error)
Locate finds a location for the given client request using AppEngine headers. If no location is found, an error is returned.
func (*AppEngineLocator) Reload ¶
func (sl *AppEngineLocator) Reload(ctx context.Context)
Reload does nothing.
type MaxmindLocator ¶
type MaxmindLocator struct {
// contains filtered or unexported fields
}
MaxmindLocator manages access to the maxmind database.
func NewMaxmindLocator ¶
func NewMaxmindLocator(ctx context.Context, mm content.Provider) *MaxmindLocator
NewMaxmindLocator creates a new MaxmindLocator and loads the current copy of MaxMind data stored in GCS.
func (*MaxmindLocator) Locate ¶
func (mml *MaxmindLocator) Locate(req *http.Request) (*Location, error)
Locate finds the Location of the given request using client's remote IP or IP from X-Forwarded-For header.
func (*MaxmindLocator) Reload ¶
func (mml *MaxmindLocator) Reload(ctx context.Context)
Reload is intended to be regularly called in a loop. It should check whether the data in GCS is newer than the local data, and, if it is, then download and load that new data into memory and then replace it in the annotator.
type MultiLocator ¶
type MultiLocator []Locator
MultiLocator wraps several Locator types into the Locate interface.
func (MultiLocator) Locate ¶
func (g MultiLocator) Locate(req *http.Request) (*Location, error)
Locate calls Locate on all client Locators. The first successfully identifiec location is returned. If all Locators returns an error, a multierror.Error is returned as an error with all Locator error messages.
func (MultiLocator) Reload ¶
func (g MultiLocator) Reload(ctx context.Context)
Reload calls Reload on all Client Locators.
type NullLocator ¶
type NullLocator struct{}
NullLocator always returns a client location of 0,0.
type UserLocator ¶
type UserLocator struct{}
UserLocator definition for accepting user provided location hints.