database

package
v0.0.0-...-22eab65 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRecordsForURL

func GetRecordsForURL(url string, origin time.Time, timeframe int64) []request.ResponseLog

GetRecordsForURL gets records from the database for all the given URLs the records timestamp is bounded between and [origin - timeframe, origin]

func Set

func Set(database Type) error

Set sets the database name, and initializes the database

func WriteLogToDB

func WriteLogToDB(responseLog request.ResponseLog) error

WriteLogToDB writes logs to our database

Types

type Database

type Database interface {
	Initialize() error
	GetDatabaseName() string
	AddResponseLog(responseLog request.ResponseLog) error
	GetRangeRecords(span int) []client.Result
}

Database interface abstracts the interactions woth influxDB and provides and database agnostic interface for use

type InfluxDb

type InfluxDb struct {
	Host         string `json:"host"`
	Port         int    `json:"port"`
	DatabaseName string `json:"databaseName"`
	Username     string `json:"username"`
	Password     string `json:"password"`
}

func (InfluxDb) AddRecord

func (influxDb InfluxDb) AddRecord(responseLog request.ResponseLog) error

AddRecord adds a new record to InfluxDB

func (InfluxDb) GetRecordsForURL

func (influxDb InfluxDb) GetRecordsForURL(url string, origin time.Time, timeframe int64) []request.ResponseLog

GetRecordsForURL sends a query to InfluxDB to get records of a given URL, older than a given "origin" and restricted by a given timeframe

func (InfluxDb) Initialize

func (influxDb InfluxDb) Initialize() error

Initialize influx db

type Type

type Type struct {
	InfluxDb InfluxDb `json:"influxDb"`
}

Type is the database type ps: if we decide we want to use another db we can add it here

Jump to

Keyboard shortcuts

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