Documentation
¶
Index ¶
Constants ¶
const RequestTag = "Annotate v2.0"
RequestTag is the string associated with v2.0 requests.
Variables ¶
var ErrMoreJSON = errors.New("JSON body not completely consumed")
ErrMoreJSON is returned if the message body was not completely consumed by decoder.
var ErrStatusNotOK = errors.New("http status not StatusOK")
ErrStatusNotOK is returned from GetAnnotation if http status is other than OK. Response body may have more info.
var ( RequestTimeHistogram = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "annotator_external_latency_hist_msec", Help: "annotator latency distributions.", Buckets: []float64{ 1.0, 1.3, 1.6, 2.0, 2.5, 3.2, 4.0, 5.0, 6.3, 7.9, 10, 13, 16, 20, 25, 32, 40, 50, 63, 79, 100, 130, 160, 200, 250, 320, 400, 500, 630, 790, 1000, 1300, 1600, 2000, 2500, 3200, 4000, 5000, 6300, 7900, }, }, []string{"detail"}) )
************************************************************************ * Remote Annotator API * ************************************************************************
Functions ¶
func ConvertAnnotationsToClientAnnotations ¶
func ConvertAnnotationsToClientAnnotations(a *api.Annotations) *uuid.ClientAnnotations
ConvertAnnotationsToClientAnnotations accepts an annotation from the v2 API and returns the equivalent annotator.ClientAnnotations structure from the uuid-annotator. This function is only useful for migrating away from the v2 API and should be retired with the annotation-service once the annotation export processes are complete.
func ConvertAnnotationsToServerAnnotations ¶
func ConvertAnnotationsToServerAnnotations(a *api.Annotations) *uuid.ServerAnnotations
ConvertAnnotationsToServerAnnotations accepts an annotation from the v2 API and returns the equivalent annotator.ServerAnnotations structure from the uuid-annotator. This function is only useful for migrating away from the v2 API and should be retired with the annotation-service once the annotation export processes are complete.
Types ¶
type Annotator ¶
type Annotator interface {
// TODO - make info an regular parameter instead of vararg.
GetAnnotations(ctx context.Context, date time.Time, ips []string, info ...string) (*Response, error)
}
Annotator defines the GetAnnotations method used for annotating. info is an optional string to populate Request.RequestInfo
func GetAnnotator ¶
GetAnnotator returns a v2.Annotator that uses the provided url to make v2 api requests.
type Request ¶
type Request struct {
RequestType string // This should contain "Annotate v2.0"
RequestInfo string // Arbitrary info about the requester, to be used, e.g., for stats.
Date time.Time // The date to be used to annotate the addresses.
IPs []string // The IP addresses to be annotated
}
Request describes the data we expect to receive (json encoded) in the request body.
type RequestWrapper ¶
type RequestWrapper struct {
RequestType string
Body json.RawMessage
}
RequestWrapper will be used for all future request types.
type Response ¶
type Response struct {
// TODO should we include additional metadata about the annotator sources? Perhaps map of filenames?
AnnotatorDate time.Time // The publication date(s) of the dataset used for the annotation
Annotations map[string]*api.Annotations // Map from human readable IP address to GeoData
}
Response describes data returned in V2 responses (json encoded).
func GetAnnotations ¶
func GetAnnotations(ctx context.Context, url string, date time.Time, ips []string, info ...string) (*Response, error)
GetAnnotations takes a url, and Request, makes remote call, and returns parsed ResponseV2 TODO make this unexported once we have migrated all code to use GetAnnotator()