processor

package module
v0.0.0-...-f5f10a3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvgServicesLatenciesCSV

func AvgServicesLatenciesCSV(ctx context.Context, w io.Writer, db Storage) error

AvgServicesLatenciesCSV generates a CSV latencies report of all services.

func ConsumerReportCSV

func ConsumerReportCSV(ctx context.Context, w io.Writer, db Storage, id string) error

ConsumerReportCSV generates a CSV requests report of a consumer with ID id.

func InsertBatch

func InsertBatch(ctx context.Context, db Storage, r io.Reader) error

InsertBatch inserts a stream of log Records into the db Storage. The insertion is made in batches.

func ServiceReportCSV

func ServiceReportCSV(ctx context.Context, w io.Writer, db Storage, id string) error

ServiceReportCSV generates a CSV requets report of a service with ID id.

func ValidRecord

func ValidRecord(r *Record) error

ValidRecord checks if a record is valid.

Types

type AuthenticatedEntity

type AuthenticatedEntity struct {
	ConsumerID struct {
		UUID string `json:"uuid"`
	} `json:"consumer_id"`
}

type Latencies

type Latencies struct {
	Proxy   int64 `json:"proxy"`
	Gateway int64 `json:"gateway"`
	Request int64 `json:"request"`
}

type Record

type Record struct {
	Request             Request             `json:"request"`
	UpstreamURI         string              `json:"upstream_uri"`
	Response            Response            `json:"response"`
	AuthenticatedEntity AuthenticatedEntity `json:"authenticated_entity"`
	Route               Route               `json:"route"`
	Service             Service             `json:"service"`
	Latencies           Latencies           `json:"latencies"`
	ClientIP            string              `json:"client_ip"`
	StartedAt           int64               `json:"started_at"`
}

Record stores log information.

type ReportRow

type ReportRow struct {
	ID                               int64
	ConsumerID                       string
	UpstreamURI                      string
	ResponseID                       string
	RequestID                        string
	RouteID                          string
	ServiceID                        string
	ProxyLatency                     int64
	GatewayLatency                   int64
	RequestLatency                   int64
	ClientIP                         string
	StartedAt                        time.Time
	RspStatus                        int64
	RspSize                          int64
	RspContentLength                 int64
	RspVia                           string
	RspConnection                    string
	RspAccessControlAllowCredentials string
	RspAccessControlAllowOrigin      string
	RspContentType                   string
	RspServer                        string
	ReqMethod                        string
	ReqURI                           string
	ReqURL                           string
	ReqSize                          int64
	ReqQuerystring                   string
	ReqHeaderAccept                  string
	ReqHeaderHost                    string
	ReqUserAgent                     string
}

ReportRow stores information about requests and it's response.

type Request

type Request struct {
	Method      string         `json:"method"`
	URI         string         `json:"uri"`
	URL         string         `json:"url"`
	Size        int            `json:"size"`
	Querystring []string       `json:"querystring"`
	Headers     RequestHeaders `json:"headers"`
}

type RequestHeaders

type RequestHeaders struct {
	Accept    string `json:"accept"`
	Host      string `json:"host"`
	UserAgent string `json:"user-agent"`
}

type Response

type Response struct {
	Status  int64           `json:"status"`
	Size    int             `json:"size"`
	Headers ResponseHeaders `json:"headers"`
}

type ResponseHeaders

type ResponseHeaders struct {
	ContentLength                 string `json:"Content-Length"`
	Via                           string `json:"via"`
	Connection                    string `json:"Connection"`
	AccessControlAllowCredentials string `json:"access-control-allow-credentials"`
	ContentType                   string `json:"Content-Type"`
	Server                        string `json:"server"`
	AccessControlAllowOrigin      string `json:"access-control-allow-origin"`
}

type Route

type Route struct {
	CreatedAt     int64        `json:"created_at"`
	Hosts         string       `json:"hosts"`
	ID            string       `json:"id"`
	Methods       []string     `json:"methods"`
	Paths         []string     `json:"paths"`
	PreserveHost  bool         `json:"preserve_host"`
	Protocols     []string     `json:"protocols"`
	RegexPriority int64        `json:"regex_priority"`
	Service       RouteService `json:"service"`
	StripPath     bool         `json:"strip_path"`
	UpdatedAt     int64        `json:"updated_at"`
}

type RouteService

type RouteService struct {
	ID string `json:"id"`
}

type Service

type Service struct {
	ConnectTimeout int64  `json:"connect_timeout"`
	CreatedAt      int64  `json:"created_at"`
	Host           string `json:"host"`
	ID             string `json:"id"`
	Name           string `json:"name"`
	Path           string `json:"path"`
	Port           int64  `json:"port"`
	Protocol       string `json:"protocol"`
	ReadTimeout    int64  `json:"read_timeout"`
	Retries        int64  `json:"retries"`
	UpdatedAt      int64  `json:"updated_at"`
	WriteTimeout   int64  `json:"write_timeout"`
}

type ServiceLatencies

type ServiceLatencies struct {
	ID           string
	Name         string
	AvgLatencies Latencies
}

ServiceLatencies reports the proxy, request and gateway latencies of each service.

type Storage

type Storage interface {
	// InserRecord inserts the Record into the Storage.
	InsertRecord(context.Context, *Record) error

	// InserRecordBatch inserts a batch of Records into the Storage.
	InsertRecordBatch(context.Context, []Record) error

	// AverageServicesLatencies returns the latencies of all services.
	AverageServicesLatencies(context.Context) ([]ServiceLatencies, error)

	// ConsumerReport returns information about the specified consumer's
	// requests.
	ConsumerReport(ctx context.Context, id string) ([]ReportRow, error)

	//  ServiceReport returns information about the specified service's
	// requests.
	ServiceReport(ctx context.Context, id string) ([]ReportRow, error)
}

Storage is used to persist data, usually a database.

Directories

Path Synopsis
storage

Jump to

Keyboard shortcuts

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