locator

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2023 License: MIT Imports: 8 Imported by: 0

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
	GetLocation(ctx context.Context, ip string) (*WorldLocation, error)
}

Client is a client for the locator service.

func New

func New(cc *grpc.ClientConn) Client

New instantiates a new locator service client.

type GetLocationFunc

type GetLocationFunc func(ctx context.Context, ip string) (*WorldLocation, error)

GetLocationFunc mocks the GetIPLocation method.

type Mock

type Mock struct {
	// contains filtered or unexported fields
}

Mock implementation of the locator client.

func NewMock

func NewMock(t *testing.T) *Mock

NewMock returns a new mock client.

func (*Mock) AddGetLocationFunc

func (m *Mock) AddGetLocationFunc(f GetLocationFunc)

AddGetIPLocationFunc adds f to the mocked call sequence.

func (*Mock) GetLocation

func (m *Mock) GetLocation(ctx context.Context, ip string) (*WorldLocation, error)

GetLocation implements the Client interface.

func (*Mock) HasMore

func (m *Mock) HasMore() bool

HasMore returns true if there are more calls to be made.

func (*Mock) SetGetLocationFunc

func (m *Mock) SetGetLocationFunc(f GetLocationFunc)

SetGetIPLocationFunc sets f for all calls to the mocked method.

type WorldLocation

type WorldLocation struct {
	// Lat is the latitude of the location.
	Lat float64
	// Long is the longitude of the location.
	Long float64
	// City is the city of the location.
	City string
	// Region is the region/state of the location.
	Region string
	// Country is the country of the location.
	Country string
}

WorldLocation represents the location for the given IP address.

Jump to

Keyboard shortcuts

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