provider

package
v0.0.0-...-a07846c Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const CacheTTL = 365 * 24 * time.Hour
View Source
const GoogleProviderType = "google"
View Source
const OpencageProviderType = "opencage"

Variables

View Source
var DefaultTTL = 180 * 24 * time.Hour

Functions

This section is empty.

Types

type AggregateProvider

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

func (AggregateProvider) Geocode

func (ap AggregateProvider) Geocode(q Query) (*Result, error)

type CacheStore

type CacheStore interface {
	Get(key []byte) (*Result, error)
	Set(key []byte, item *Result) error
	SetWithTTL(key []byte, item *Result, ttl time.Duration) error
	Del(key []byte) error
}

type GeocodingProvider

type GeocodingProvider interface {
	Geocode(q Query) (*Result, error)
}

func NewGeocodingProvider

func NewGeocodingProvider(cs CacheStore, registry *prometheus.Registry, specification config.Specification) (GeocodingProvider, error)

func NewGoogleGeocodeProvider

func NewGoogleGeocodeProvider(key string) (GeocodingProvider, error)

func NewOpencageProvider

func NewOpencageProvider(key string) (GeocodingProvider, error)

type GoogleProvider

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

func (GoogleProvider) Geocode

func (g GoogleProvider) Geocode(q Query) (*Result, error)

type OpencageProvider

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

func (OpencageProvider) Geocode

func (o OpencageProvider) Geocode(q Query) (*Result, error)

type Query

type Query struct {
	Address  string
	Provider string
	Lat      float64
	Lng      float64
	Query    map[string]string
}

func (Query) Hash

func (q Query) Hash() []byte

func (Query) IsValid

func (q Query) IsValid() bool

func (Query) Key

func (q Query) Key() []byte

type Result

type Result struct {
	Provider  string
	Locations []*geocoder.Location
	Metadata  metadata.MD
}

type Store

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

func NewCacheStore

func NewCacheStore(rc *redis.Client) (*Store, error)

func (*Store) Del

func (s *Store) Del(key []byte) error

func (*Store) Get

func (s *Store) Get(key []byte) (*Result, error)

func (Store) Serialize

func (s Store) Serialize(item *Result) ([]byte, error)

func (*Store) Set

func (s *Store) Set(key []byte, item *Result) error

func (Store) SetWithTTL

func (s Store) SetWithTTL(key []byte, item *Result, ttl time.Duration) error

Jump to

Keyboard shortcuts

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