annotation

package
v2.4.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnnotatorURL = "https://annotator-dot-" +
	os.Getenv("GCLOUD_PROJECT") +
	".appspot.com"

AnnotatorURL holds the https address of the annotator. TODO(gfr) See if there is a better way of determining where to send the request (there almost certainly is)

View Source
var BaseURL = AnnotatorURL + "/annotate?"

BaseURL provides the base URL for single annotation requests

View Source
var BatchURL = AnnotatorURL + "/batch_annotate"

BatchURL provides the base URL for batch annotation requests

Functions

func AddGeoAnnotations

func AddGeoAnnotations(ips []string, timestamp time.Time, geoDest []*api.GeolocationIP)

AddGeoAnnotations takes a slice of string ip addresses, a timestamp, and a slice of pointers to corresponding GeolocationIP structs. Slices must be the same length, or the function will immediately return. It calls the batch annotator, using the ip addresses and the timestamp and uses the response to fill in the structs pointed to by the slice of GeolocationIP pointers. Deprecated: Use Annotatable interface and parser.Base instead.

func BatchQueryAnnotationService

func BatchQueryAnnotationService(url string, data []api.RequestData) ([]byte, error)

BatchQueryAnnotationService takes a url to POST the request to and a slice of RequestDatas to be sent in the body in a JSON format. It will copy the response into a []byte and return it to the user, returning an error if any occurs TODO(gfr) Should pass the annotator's request context through and use it here.

func FetchAllAnnotations

func FetchAllAnnotations(ips []string, timestamp time.Time) []*api.GeoData

FetchAllAnnotations takes a slice of strings containing ip addresses, a timestamp. It returns an array of pointers to GeoData structs corresponding to the ip addresses, or nil if there is an error. Deprecated: Use Annotatable interface and parser.Base instead.

func GetAndInsertGeolocationIPStruct

func GetAndInsertGeolocationIPStruct(geo *api.GeolocationIP, ip string, timestamp time.Time)

GetAndInsertGeolocationIPStruct takes a NON-NIL pointer to a pre-allocated GeolocationIP struct, an IP address, and a timestamp. It will connect to the annotation service, get the geo data, and insert the geo data into the reigion pointed to by the GeolocationIP pointer.

func GetBatchGeoData

func GetBatchGeoData(url string, data []api.RequestData) map[string]api.GeoData

GetBatchGeoData combines the functionality of BatchQueryAnnotationService and BatchParseJSONGeoDataResponse to query the annotator service and return the corresponding map of ip-timestamp strings to GeoData structs, or a nil map if it encounters any error and cannot get the data for any reason TODO - dedup common code in GetGeoData Deprecated: Use Annotatable interface and parser.Base instead.

func GetGeoData

func GetGeoData(url string) *api.GeoData

GetGeoData combines the functionality of QueryAnnotationService and ParseJSONGeoDataResponse to query the annotator service and return the corresponding GeoData if it can, or a nil pointer if it encounters any error and cannot get the data for any reason

func ParseJSONGeoDataResponse

func ParseJSONGeoDataResponse(jsonBuffer []byte) (*api.GeoData, error)

ParseJSONGeoDataResponse takes a byte slice containing the test of the JSON from the annotator service and parses it into a GeoData struct, for easy manipulation. It returns a pointer to the struct on success and an error if an error occurs.

func QueryAnnotationService

func QueryAnnotationService(url string) ([]byte, error)

QueryAnnotationService will connect to the annotation service and copy the body of a valid response to a byte slice and return it to a user, returning an error if any occurs

Types

This section is empty.

Jump to

Keyboard shortcuts

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