Documentation ¶
Index ¶
- Constants
- Variables
- func AdjustTimePeriod(from, to time.Time) (time.Time, time.Time, error)
- func GetHttpServer(meter RelayMeter, l *logger.Logger) func(w http.ResponseWriter, req *http.Request)
- type ApiError
- type AppRelaysResponse
- type Backend
- type ErrorResponse
- type LoadBalancerRelaysResponse
- type RelayCounts
- type RelayMeter
- type RelayMeterOptions
- type TotalRelaysResponse
- type UserRelaysResponse
Constants ¶
View Source
const ( // TODO: make all time-related parameters configurable TTL_DAILY_METRICS_DEFAULT_SECONDS = 900 TTL_TODAYS_METRICS_DEFAULT_SECONDS = 600 MAX_PAST_DAYS_METRICS_DEFAULT_DAYS = 30 )
View Source
const ( DATE_LAYOUT = time.RFC3339 PARAMETER_FROM = "from" PARAMETER_TO = "to" )
Variables ¶
View Source
var (
ErrLoadBalancerNotFound = errors.New("loadbalancer/endpoint not found")
)
Functions ¶
func AdjustTimePeriod ¶
AdjustTimePeriod sets the two parameters, i.e. from and to, according to the following rules:
- From is adjusted to the start of the day that it originally specifies
- To is adjusted to the start of the next day from the day it originally specifies
func GetHttpServer ¶
func GetHttpServer(meter RelayMeter, l *logger.Logger) func(w http.ResponseWriter, req *http.Request)
TODO: Return 404 on Application not found error TODO: Return 304, i.e. Not Modified, if relevant TODO: 'Accepts' Header in the request serves: /relays/apps
Types ¶
type AppRelaysResponse ¶
TODO: refactor common fields
type Backend ¶
type Backend interface { //TODO: reverse map keys order, i.e. map[app]-> map[day]RelayCounts, at PG level DailyUsage(from, to time.Time) (map[time.Time]map[string]RelayCounts, error) TodaysUsage() (map[string]RelayCounts, error) // Is expected to return the list of applicationIDs owned by the user UserApps(user string) ([]string, error) // LoadBalancer returns the full load balancer struct LoadBalancer(endpoint string) (*repository.LoadBalancer, error) LoadBalancers() ([]*repository.LoadBalancer, error) }
type ErrorResponse ¶
type ErrorResponse struct {
Message string
}
type RelayCounts ¶
type RelayMeter ¶
type RelayMeter interface { // AppRelays returns total number of relays for the app over the specified time period AppRelays(app string, from, to time.Time) (AppRelaysResponse, error) AllAppsRelays(from, to time.Time) ([]AppRelaysResponse, error) UserRelays(user string, from, to time.Time) (UserRelaysResponse, error) TotalRelays(from, to time.Time) (TotalRelaysResponse, error) // LoadBalancerRelays returns the metrics for an Endpoint, AKA loadbalancer LoadBalancerRelays(endpoint string, from, to time.Time) (LoadBalancerRelaysResponse, error) AllLoadBalancersRelays(from, to time.Time) ([]LoadBalancerRelaysResponse, error) }
func NewRelayMeter ¶
func NewRelayMeter(backend Backend, logger *logger.Logger, options RelayMeterOptions) RelayMeter
type RelayMeterOptions ¶
type TotalRelaysResponse ¶
type TotalRelaysResponse struct { Count RelayCounts From time.Time To time.Time }
type UserRelaysResponse ¶
Click to show internal directories.
Click to hide internal directories.