Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // GetLocation gets the location for the given IP address or the // IP of the server if blank. GetLocation(ctx context.Context, ip string) (*WorldLocation, error) // Name provides a client name used to report health check issues. Name() string // Ping checks the client is healthy. Ping(ctx context.Context) error }
Client is the ipapi client interface. It implements a simple in-memory transparent cache to avoid hitting the API too often and getting throttled (429).
type GetLocationFunc ¶
type GetLocationFunc func(ctx context.Context, ip string) (*WorldLocation, error)
GetLocationFunc mocks the GetLocation method.
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock implementation of the ipapi client.
func (*Mock) AddGetLocationFunc ¶
func (m *Mock) AddGetLocationFunc(f GetLocationFunc)
AddGetLocationFunc adds f to the mocked call sequence.
func (*Mock) GetLocation ¶
GetLocation implements the Client interface.
func (*Mock) SetGetLocationFunc ¶
func (m *Mock) SetGetLocationFunc(f GetLocationFunc)
SetGetLocationFunc sets f for all calls to the mocked method.
type WorldLocation ¶
type WorldLocation struct { // Lat is the latitude of the location. Lat float64 `json:"lat"` // Long is the longitude of the location. Long float64 `json:"lon"` // City is the city of the location. City string `json:"city"` // Region is the region/state of the location. Region string `json:"region"` // Country is the country of the location. Country string `json:"country"` }
WorldLocation represents the geographical location of an IP address.
Click to show internal directories.
Click to hide internal directories.