stats

package
v0.0.0-...-c68f62e Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Modes = [...]Mode{Memory, Kafka}

Modes contains all the possible modes

Functions

func ModesToSlice

func ModesToSlice() []string

ModesToSlice transforms the modes into a slice

Types

type Mode

type Mode int

Mode of the primitive to transform

const (
	// Memory mode to store the statistics
	Memory Mode = iota
	// Kafka mode to track requests
	Kafka
)

func GetMode

func GetMode(s string) Mode

GetMode from given string

func (Mode) String

func (i Mode) String() string

type Repository

type Repository interface {
	GetAll() []*Request
	Increment(path string, input map[string]interface{}) error
	io.Closer
}

Repository to store stats

type Request

type Request struct {
	Path       string                 `json:"path"`
	NbHits     int                    `json:"nbHits"`
	Parameters map[string]interface{} `json:"parameters,omitempty"`
}

Request stats data structure

type Service

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

Service to store stats

func NewService

func NewService(r Repository) *Service

NewService creates a service to handle request stats

func (*Service) GetAll

func (s *Service) GetAll() []*Request

GetAll request stats from the storage

func (*Service) GetMostUsed

func (s *Service) GetMostUsed() *Request

GetMostUsed request

func (*Service) Increment

func (s *Service) Increment(path string, input map[string]interface{}) error

Increment number of hits for a given path

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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