contract

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collections

type Collections struct {
	Data map[string]gtly.Collection `json:",omitempty"`
	// contains filtered or unexported fields
}

Collections represents a registry

func NewData

func NewData() *Collections

NewData creates new data

func (*Collections) Get

func (r *Collections) Get(key string) gtly.Collection

Get returns a collection for provided key

func (*Collections) Put

func (r *Collections) Put(key string, value gtly.Collection)

Put add data key

type Data

type Data map[string]interface{}

Data represents data

func (Data) MarshalJSON

func (r Data) MarshalJSON() ([]byte, error)

type ErrorInfo

type ErrorInfo struct {
	Message  string
	Location string
	Type     string
}

ErrorInfo represents an error info

type Request

type Request struct {
	TraceID     string
	Path        string
	Headers     http.Header
	PathParams  url.Values
	QueryParams url.Values
	EventTime   time.Time
	Data        map[string]interface{}
	Metrics     string `json:",omitempty"`
	CaseFormat  string `json:",omitempty"` //source data case format
}

Request represents base request

func (*Request) BasicAuth

func (r *Request) BasicAuth() (username, password string, ok bool)

BasicAuth returns the username and password provided in the request's Authorization header, if the request uses HTTP Basic Authentication. See RFC 2617, Section 2.

func (*Request) Init

func (r *Request) Init(request *http.Request) error

Init initialises request

func (*Request) Validate

func (r *Request) Validate() error

Validate checks if request is valid

type Response

type Response struct {
	StatusInfo
	Data    Data        `json:",omitempty"`
	Headers http.Header `json:",omitempty"`
	// contains filtered or unexported fields
}

Response represents base response

func NewResponse

func NewResponse() *Response

NewResponse creates a response

func (*Response) Put

func (r *Response) Put(key string, value interface{})

func (Response) WriteHeaders

func (r Response) WriteHeaders(writer http.ResponseWriter)

WriteHeaders writes headers

type StatusInfo

type StatusInfo struct {
	JobID           string `json:",omitempty"`
	Status          string
	Errors          []*ErrorInfo    `json:",omitempty"`
	Metrics         *metric.Metrics `json:",omitempty"`
	RuleURL         string          `json:",omitempty"`
	Rule            *config.Rule    `json:",omitempty"`
	Rules           int             `json:",omitempty"`
	ServiceTimeMs   int             `json:",omitempty"`
	ExecutionTimeMs int             `json:",omitempty"`
	CreateTime      time.Time       `json:",omitempty"`
	StartTime       time.Time       `json:",omitempty"`
	// contains filtered or unexported fields
}

StatusInfo represents status

func NewStatusInfo

func NewStatusInfo() StatusInfo

func (*StatusInfo) AddError

func (i *StatusInfo) AddError(errType, location string, err error)

AddError add an error to response

func (*StatusInfo) ApplyFilter

func (i *StatusInfo) ApplyFilter(metrics string) *StatusInfo

ApplyFilter applies info filter

func (StatusInfo) Clone

func (i StatusInfo) Clone() *StatusInfo

Clone clones status info

func (*StatusInfo) OnDone

func (i *StatusInfo) OnDone()

OnDone computes time taken

Jump to

Keyboard shortcuts

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