worker

package
v1.0.53 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: Apache-2.0 Imports: 46 Imported by: 1

Documentation

Overview

DO NOT EDIT.. COPY FROM bifrost/app/components/synthetics/helper.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateScriptSnippet

func CreateScriptSnippet(req SyntheticCheck) string

func NewBrowserChecker added in v1.0.39

func NewBrowserChecker(c SyntheticCheck) *browserChecker

func TimerNew

func TimerNew(fun func(), fireInNs time.Duration, interval time.Duration) func()

Types

type AlertConditionsOptions

type AlertConditionsOptions struct {
	RetryCount           int `json:"retry_count"`
	RetryIntervalSeconds int `json:"retry_interval_seconds"`
}

type AssertionsCasesOptions

type AssertionsCasesOptions struct {
	Cases []CaseOptions `json:"cases"`
}

type AssertionsOptions

type AssertionsOptions struct {
	HTTP      AssertionsCasesOptions `json:"http"`
	TCP       AssertionsCasesOptions `json:"tcp"`
	Ssl       AssertionsCasesOptions `json:"ssl"`
	DNS       AssertionsCasesOptions `json:"dns"`
	WebSocket AssertionsCasesOptions `json:"web_socket"`
	UDP       AssertionsCasesOptions `json:"udp"`
	ICMP      AssertionsCasesOptions `json:"icmp"`
	GRPC      AssertionsCasesOptions `json:"grpc"`
}

type Authentication

type Authentication struct {
	ClientCertificate ClientCertificate `json:"client_certificate"`
	Type              string            `json:"type"`
	Basic             Basic             `json:"basic"`
	Digest            Digest            `json:"digest"`
	Ntlm              Ntlm              `json:"ntlm"`
	AwsSignature      AwsSignature      `json:"aws_signature"`
	Oauth21           Oauth21           `json:"oauth2_1"`
}

type AwsSignature

type AwsSignature struct {
	AccessKeyID     string `json:"access_key_id"`
	SecretAccessKey string `json:"secret_access_key"`
	Region          string `json:"region"`
	ServiceName     string `json:"service_name"`
	SessionToken    string `json:"session_token"`
}

type BaseCheckerForTTL added in v1.0.22

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

type Basic

type Basic struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Browser added in v1.0.39

type Browser struct {
	UserAgent string `json:"user_agent"`
}

type BrowserConfig added in v1.0.39

type BrowserConfig struct {
	Region string `json:"region"`
	Device Device `json:"device"`
}

type CacheEntry added in v1.0.29

type CacheEntry struct {
	ExpiryDays int
	Timestamp  time.Time
}

type CaseOptions

type CaseOptions struct {
	Config struct {
		Operator string `json:"operator"`
		Target   string `json:"target"`
		Value    string `json:"value"`
	} `json:"config"`
	Type string `json:"type"`
}

type CheckState

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

type CheckTestRequestHeaders

type CheckTestRequestHeaders struct {
	Authorization string `json:"authorization"`
	AccountID     int    `json:"account_id"`
	AccountUID    string `json:"account_uid"`
	UserId        int    `json:"user_id"`
	CheckId       int    `json:"check_id"`
}

type ClientCertificate

type ClientCertificate struct {
	Certificate string `json:"certificate"`
	PrivateKey  string `json:"private_key"`
}

type CommandArgs added in v1.0.39

type CommandArgs struct {
	CaptureEndpoint string
	Browser         string
	CollectRum      bool
	Device          string
	Region          string
	TestId          string
}

type Config

type Config struct {
	Mode                Mode
	Location            string
	Hostname            string
	PulsarHost          string
	UnsubscribeEndpoint string
	NCAPassword         string
	Token               string
	CaptureEndpoint     string
}

type DefaultNetter added in v1.0.22

type DefaultNetter struct{}

func (*DefaultNetter) ConnClose added in v1.0.22

func (d *DefaultNetter) ConnClose(conn net.Conn) error

func (*DefaultNetter) DialTimeout added in v1.0.22

func (d *DefaultNetter) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)

func (*DefaultNetter) LookupIP added in v1.0.22

func (d *DefaultNetter) LookupIP(host string) ([]net.IP, error)

type Device added in v1.0.39

type Device struct {
	Resolution Resolution `json:"resolution"`
	Browser    Browser    `json:"browser"`
}

type Digest

type Digest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type DomainExpiryCache added in v1.0.29

type DomainExpiryCache struct {
	Store map[int]CacheEntry // checker.c.id -> CacheEntry
	// contains filtered or unexported fields
}

func GetDomainExpiryStoreInstance added in v1.0.29

func GetDomainExpiryStoreInstance() *DomainExpiryCache

GetDomainExpiryStoreInstance returns signleton instance of DomainExpiryCache

func (*DomainExpiryCache) AddOrUpdateCache added in v1.0.29

func (d *DomainExpiryCache) AddOrUpdateCache(id int, entry CacheEntry)

AddOrUpdateCache update the cache

func (*DomainExpiryCache) GetCache added in v1.0.29

func (d *DomainExpiryCache) GetCache(id int) (CacheEntry, bool)

GetCache returns the cache entry for a given id.

type Failure added in v1.0.39

type Failure struct {
	Message string `json:"message"`
}

type GRPCPayloadOptions

type GRPCPayloadOptions struct {
	CheckType                    string `json:"check_type" default:"behaviour"`
	Service                      string `json:"service"`
	ServiceDefinition            string `json:"service_definition"`
	MethodSelection              string `json:"method_selection"`
	ProtoFileContent             string `json:"proto_file_content"`
	Message                      string `json:"message"`
	IgnoreServerCertificateError bool   `json:"ignore_server_certificate_error"`
	Metadata                     []struct {
		Name  string `json:"name"`
		Value string `json:"value"`
	} `json:"metadata"`
	Certificate string `json:"certificate"`
	PrivateKey  string `json:"private_key"`
}

type HTTPHeadersOptions

type HTTPHeadersOptions struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type HTTPMultiStepsOptions

type HTTPMultiStepsOptions struct {
	StepName string                `json:"step_name"`
	Endpoint string                `json:"endpoint"`
	Expect   SyntheticsExpectMeta  `json:"expect"`
	Request  HTTPMultiStepsRequest `json:"request"`
}

type HTTPMultiStepsRequest

type HTTPMultiStepsRequest struct {
	HTTPMethod  string               `json:"http_method"`
	HTTPVersion string               `json:"http_version"`
	HTTPHeaders []HTTPHeadersOptions `json:"http_headers"`
	HTTPPayload HTTPPayloadOptions   `json:"http_payload"`
	Assertions  AssertionsOptions    `json:"assertions"`
}

type HTTPPayloadOptions

type HTTPPayloadOptions struct {
	FollowRedirects              bool   `json:"follow_redirects"`
	IgnoreServerCertificateError bool   `json:"ignore_server_certificate_error"`
	Cookies                      string `json:"cookies"`
	QueryParams                  []struct {
		Name  string `json:"name"`
		Value string `json:"value"`
	} `json:"query_params"`
	RequestBody RequestBody `json:"request_body"`
	Privacy     struct {
		SaveBodyResponse bool `json:"save_body_response"`
	} `json:"privacy"`
	Proxy struct {
		URL     string `json:"url"`
		Headers []struct {
			Name  string `json:"name"`
			Value string `json:"value"`
		} `json:"headers"`
	} `json:"proxy"`
	Authentication Authentication `json:"authentication"`
}

type ICMPPayloadOptions

type ICMPPayloadOptions struct {
	PingsPerTest int `json:"pings_per_test"`
}

type Mode

type Mode uint16
var (
	ModeLocation Mode = 0
	ModeAgent    Mode = 1
)

func (Mode) String

func (m Mode) String() string

type MonitorOptions

type MonitorOptions struct {
	Source                  string        `json:"source"` // slack, email, webhook, etc
	NotifyTo                []interface{} `json:"notify_to"`
	Renotify                bool          `json:"renotify"`
	RenotifyIntervalSeconds int           `json:"renotify_interval_seconds"`
	Priority                string        `json:"priority"`
	TriggerFailsCase        bool          `json:"trigger_fails_case"`
	TriggerFailsCaseCount   int           `json:"trigger_fails_case_count"`
}

type Netter added in v1.0.22

type Netter interface {
	LookupIP(host string) ([]net.IP, error)
	DialTimeout(network, address string,
		timeout time.Duration) (net.Conn, error)
	ConnClose(conn net.Conn) error
}

type Ntlm

type Ntlm struct {
	Username    string `json:"username"`
	Password    string `json:"password"`
	Domain      string `json:"domain"`
	WorkStation string `json:"work_station"`
}

type Oauth21

type Oauth21 struct {
	CredentialsType        string `json:"credentials_type"`
	TokenAPIAuthentication string `json:"token_api_authentication"`
	AccessTokenURL         string `json:"access_token_url"`
	Username               string `json:"username"`
	Password               string `json:"password"`
	ClientID               string `json:"client_id"`
	ClientSecret           string `json:"client_secret"`
	Audience               string `json:"audience"`
	Resource               string `json:"resource"`
	Scopes                 string `json:"scopes"`
}

type RUMConfig added in v1.0.39

type RUMConfig struct {
	Enabled     bool   `json:"enabled"`
	ProjectName string `json:"projectName"`
	ServiceName string `json:"serviceName"`
	AccountKey  string `json:"accountKey"`
	Target      string `json:"target"`
}

type RequestBody

type RequestBody struct {
	Type      string  `json:"type"`
	Content   string  `json:"content"`
	FileName  string  `json:"file_name"`
	FileType  string  `json:"file_type"`
	FileSize  float64 `json:"file_size"`
	BucketKey string  `json:"bucket_key"`
	BucketUrl string  `json:"bucket_url"`
}

type RequestOptions

type RequestOptions struct {
	URL     string
	Method  string
	Headers map[string]string
	Body    map[string]interface{}
}

type Resolution added in v1.0.39

type Resolution struct {
	Width    int  `json:"width"`
	Height   int  `json:"height"`
	IsMobile bool `json:"isMobile"`
}

type RumConfig added in v1.0.39

type RumConfig struct {
	Enabled     bool   `json:"enabled"`
	ProjectName string `json:"projectName"`
	ServiceName string `json:"serviceName"`
	AccountKey  string `json:"accountKey"`
	Target      string `json:"target"`
	SessionID   string `json:"sessionId"`
}

type SpecifyFrequencyOptions

type SpecifyFrequencyOptions struct {
	Type             string           `json:"type"`
	IntervalType     string           `json:"interval_type"`
	SpecifyTimeRange SpecifyTimeRange `json:"specify_time_range"`
}

type SpecifyTimeRange added in v1.0.15

type SpecifyTimeRange struct {
	IsChecked  bool     `json:"is_checked"`
	StartTime  string   `json:"start_time"`
	EndTime    string   `json:"end_time"`
	Timezone   string   `json:"timezone"`
	DaysOfWeek []string `json:"days_of_week"`
}

type SyntheticCheck

type SyntheticCheck struct {
	Uid string
	//Not string
	SyntheticsModel
}

type SyntheticsExpectMeta

type SyntheticsExpectMeta struct {
	HttpCode             int    `json:"http_status_code,omitempty"`
	ResponseText         string `json:"response_text,omitempty"`
	ResponseTimeLessThan int    `json:"response_time_less_than,omitempty"`

	PacketLossLimit float64 `json:"packet_loss_limit,omitempty"`
	LatencyLimit    float64 `json:"latency_limit,omitempty"`
}

type SyntheticsModel

type SyntheticsModel struct {
	Id               int                      `json:"id"`
	AccountId        int                      `json:"account_id"`
	UserId           int                      `json:"user_id"`
	Proto            string                   `json:"proto"`
	SlugName         string                   `json:"slug_name"`
	Endpoint         string                   `json:"endpoint"`
	IntervalSeconds  int                      `json:"interval_seconds"`
	Locations        string                   `json:"locations"`
	Status           string                   `json:"status"`
	Tags             []string                 `json:"tags"`
	Expect           SyntheticsExpectMeta     `json:"expect"`
	Request          SyntheticsRequestOptions `json:"request"`
	CreatedAt        time.Time                `json:"created_at"`
	UpdatedAt        time.Time                `json:"updated_at"`
	Action           string                   `json:"action"`
	AccountKey       string                   `json:"account_key"`
	AccountUID       string                   `json:"account_uid"`
	Details          map[string]interface{}   `json:"details"`
	IsPreviewRequest bool                     `json:"is_preview_request"`
}

type SyntheticsRequestOptions

type SyntheticsRequestOptions struct {
	Topic                     string                  `json:"topic" default:"locations"`
	Premise                   []string                `json:"premise"`
	Environment               []interface{}           `json:"environment"`
	TTL                       bool                    `json:"ttl"`
	SslSignedCertificate      bool                    `json:"ssl_signed_certificate"`
	SslRevokedCertificateFail bool                    `json:"ssl_revoked_certificate_fail"`
	SslServerName             string                  `json:"ssl_server_name"`
	SslCertificatePrivateKey  string                  `json:"ssl_certificate_private_key"`
	SslCertificate            string                  `json:"ssl_certificate"`
	SslMinVersion             int                     `json:"ssl_min_version"`
	SslMaxVersion             int                     `json:"ssl_max_version"`
	DNSServer                 string                  `json:"dns_server"`
	ICMPPayload               ICMPPayloadOptions      `json:"icmp_payload"`
	Port                      string                  `json:"port"`
	HTTPMethod                string                  `json:"http_method"`
	HTTPVersion               string                  `json:"http_version"`
	HTTPHeaders               []HTTPHeadersOptions    `json:"http_headers"`
	HTTPPayload               HTTPPayloadOptions      `json:"http_payload"`
	GRPCPayload               GRPCPayloadOptions      `json:"grpc_payload"`
	UDPPayload                UDPPayloadOptions       `json:"udp_payload"`
	WSPayload                 WSPayloadOptions        `json:"ws_payload"`
	SpecifyFrequency          SpecifyFrequencyOptions `json:"specify_frequency"`
	Assertions                AssertionsOptions       `json:"assertions"`
	AlertConditions           AlertConditionsOptions  `json:"alert_conditions"`
	Monitor                   MonitorOptions          `json:"monitor"`
	CurrentAction             string                  `json:"current_action" default:"play"`
	StepTestIndex             int                     `json:"step_test_index"`
	HTTPMultiTest             bool                    `json:"http_multi_test"`
	HTTPMultiSteps            []HTTPMultiStepsOptions `json:"http_multi_steps"`
	Browsers                  map[string][]string     `json:"browsers"`
	Recording                 json.RawMessage         `json:"recording"`
	RUMConfig                 RUMConfig               `json:"rumConfig"`
	Timeout                   int                     `json:"waitTimeout"`
	StepsCount                int                     `json:"stepsCount"`
	TakeScreenshots           bool                    `json:"take_screenshots"`
	Timezone                  string                  `json:"timezone"`
	Language                  string                  `json:"language"`
	DisableCors               bool                    `json:"disable_cors"`
	DisableCSP                bool                    `json:"disable_csp"`
}

type SyntheticsTags

type SyntheticsTags struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type TestReport added in v1.0.39

type TestReport struct {
	Steps      interface{} `json:"steps"`
	TestResult TestResult  `json:"result"`
}

type TestResult added in v1.0.39

type TestResult struct {
	Config            BrowserConfig `json:"config"`
	TestSummary       TestSummary   `json:"test_summary"`
	Status            string        `json:"status"`
	TestDuration      int64         `json:"test_duration"`
	RecordingURL      string        `json:"recordingUrl"`
	ConsoleURL        string        `json:"consoleUrl"`
	HARUrl            string        `json:"harUrl"`
	TimeToInteractive float64       `json:"timeToInteractive"`
	RumConfig         RumConfig     `json:"rumConfig"`
	Failure           *Failure      `json:"failure,omitempty"`
}

type TestSummary added in v1.0.39

type TestSummary struct {
	Total     int `json:"total"`
	Completed int `json:"completed"`
	Errors    int `json:"errors"`
}

type Timer

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

func SetTimeout

func SetTimeout(fn func(), duration time.Duration, id int) *Timer

SetTimeout runs the specified function after waiting the specified duration (defined in milliseconds)

func (*Timer) Reset

func (timer *Timer) Reset()

Reset the timer

func (*Timer) Start

func (timer *Timer) Start()

Start the timer.

func (*Timer) Stop

func (timer *Timer) Stop()

Stop the timer.

type UDPPayloadOptions

type UDPPayloadOptions struct {
	Message string `json:"message"`
}

type WSPayloadAuthentication

type WSPayloadAuthentication struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type WSPayloadHeaders

type WSPayloadHeaders struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type WSPayloadOptions

type WSPayloadOptions struct {
	Message        string                  `json:"message"`
	Headers        []WSPayloadHeaders      `json:"headers"`
	Authentication WSPayloadAuthentication `json:"authentication"`
}

type Worker

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

Worker is the main worker struct

func New

func New(cfg *Config) (*Worker, error)

New creates a new worker

func (*Worker) DeleteMessage added in v1.0.21

func (w *Worker) DeleteMessage(key string)

func (*Worker) DirectRun added in v1.0.2

func (w *Worker) DirectRun(v SyntheticCheck) (map[string]interface{}, error)

func (*Worker) GetMessage added in v1.0.21

func (w *Worker) GetMessage(key string) (*ws.Msg, bool)

func (*Worker) RealDirectRun added in v1.0.10

func (w *Worker) RealDirectRun(v SyntheticCheck) (map[string]interface{}, error)

func (*Worker) Run

func (w *Worker) Run()

func (*Worker) SetMessage added in v1.0.21

func (w *Worker) SetMessage(key string, msg *ws.Msg)

func (*Worker) SubscribeUpdates

func (w *Worker) SubscribeUpdates(topic string, token string)

func (*Worker) UnsubscribeUpdates

func (w *Worker) UnsubscribeUpdates(topic string, token string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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