query

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPRequest

type HTTPRequest struct {
	URL     string
	Method  string
	Headers map[string]string
	Retry   int
	Timeout time.Duration
	Body    io.Reader
}

HTTPRequest default HTTP Request structure

type HTTPResponse

type HTTPResponse struct {
	Body  []byte
	Error error
}

HTTPResponse default query engine response

func MakeHTTPRequest

func MakeHTTPRequest(r *HTTPRequest) *HTTPResponse

MakeHTTPRequest makes HTTP request to given `url` with `headers` and in case of error it will retry request `retry` amount of times. And only after it (if it's still error) error will be returned. Automatically timeout between requests will be calculated using `random`. Note for `timeout` waiting this function uses `time.Sleep()` so it will block execution flow. Better to be used in go-routine.

type HTTPWorkerPool

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

HTTPWorkerPool structure that contain WokerPool HTTP implementation It implements worker pool that will do real HTTP calls to resources using `query.MakeHTTPRequest`

func NewHTTPWorkerPool

func NewHTTPWorkerPool(workerCount int) *HTTPWorkerPool

NewHTTPWorkerPool create new worker pool for queries

func (*HTTPWorkerPool) Query

func (wp *HTTPWorkerPool) Query(req *HTTPRequest) *HTTPResponse

Query makes request to given Request Under the hood it will wrap everything to async query and execute it using worker pool.

type MockWorkerPool

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

MockWorkerPool mock worker pool implementation for tests

func NewMockWorkerPool

func NewMockWorkerPool() *MockWorkerPool

func (*MockWorkerPool) MockBody

func (mwp *MockWorkerPool) MockBody(body string)

func (*MockWorkerPool) MockResp

func (mwp *MockWorkerPool) MockResp(resp *HTTPResponse)

func (*MockWorkerPool) Query

func (mwp *MockWorkerPool) Query(req *HTTPRequest) *HTTPResponse

func (*MockWorkerPool) SetRequestAssertions

func (mwp *MockWorkerPool) SetRequestAssertions(f func(*HTTPRequest))

type WorkerPool

type WorkerPool interface {
	Query(req *HTTPRequest) *HTTPResponse
}

WorkerPool interface for any Query Engine worker pools

Jump to

Keyboard shortcuts

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