Documentation ¶
Overview ¶
Package runner provides models and methods to interact with browsers to perform HTTP requests on websites. It is used to generate load and to delivers insights on the implication of that load.
Index ¶
Constants ¶
const (
// CacheDirName is the name of the global directory used for runner caches.
CacheDirName = "loago_runner"
)
Variables ¶
var ( // ErrInvalidContext is an error indicating that a given context is no runner context. ErrInvalidContext = errors.New("not a runner context") // ErrNoNetworkEventFound is an error indicating that no network event was found. ErrNoNetworkEventFound = errors.New("no network event for base url found") )
Functions ¶
func Call ¶
Call executes an request on url using the runner context. ctx must be a valid runner context created with WithContext method of a runner instance. It returns the response time, HTTP response code, the HTTP response message an a boolean indicating if the content comes from a browser cache.
If an error occurred while performing the request an error is returned with zero values on all other return values.
Types ¶
type ChromeRunner ¶
type ChromeRunner struct { // ID of this runner. ID int // Browser cache directory path. CacheDir string // Executor interface for interacting with a browser communication library. Executor browser.Executor // contains filtered or unexported fields }
A ChromeRunner implements the runner interface. It interacts with a chrome browser via chromedp. See: https://github.com/chromedp/chromedp
func NewChromeRunner ¶
func NewChromeRunner(id int, e browser.Executor) *ChromeRunner
NewChromeRunner creates a new chrome runner instance.
func (*ChromeRunner) WithContext ¶
func (r *ChromeRunner) WithContext(ctx context.Context) context.Context
WithContext derives a new context from ctx associated with both a runner and chromedp configuration. This context can be used as a context to call the Run() method. It also creates a new goroutine in background waiting for the context to be closed to clean up ressources such as the cache dir.
type FakeRunner ¶
type FakeRunner uint
FakeRunner is a runner which fakes requests. Instead of performing real HTTP requests, it only returns fake values. This is useful for testing purposes.
func (*FakeRunner) WithContext ¶
func (r *FakeRunner) WithContext(ctx context.Context) context.Context
WithContext returns a new runner context derived from ctx.
type Runner ¶
Runner is an abstraction to represent objects interacting with browsers. Implementations of runner's are able to communicate with browsers (or other HTTP capable libraries).
func FromContext ¶
FromContext extracts the runner instance from ctx.