types

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Redacted = "**REDACTED**"
	// When marchsalling a Secret, the value will be replaced with this constant value (**REDACTED**)
	RedactedSecret = []byte(`"` + Redacted + `"`)
)

Functions

func IsRedacted

func IsRedacted(s string) bool

Types

type AuthConfig

type AuthConfig struct {
	// With dynamic, a series of requests can be made before the stress-test is performed.
	// The output can be piped into eachother, and then into the requests made during the stress-test.
	Dynamic DynamicAuth `json:"dynamic,omitempty"`
	// Bearer or Dynamic
	Kind string `json:"kind,omitempty"`
	// Used to impersonate (currently only works with keycloak)
	ImpersionationCredentials ImpersionationCredentials `json:"impersionation_credentials,omitempty"`
	// ClientID to use for
	ClientID     string `json:"client_id,omitempty"`
	RedirectUri  string `json:"redirect_uri,omitempty"`
	ClientSecret Secret `json:"client_secret,omitempty"`
	Endpoint     string `json:"endpoint,omitempty"`
	// Used with kind=Bearer and impersonation. Currenly, only keycloak is supported
	EndpointType string `json:"endpoint_type,omitempty"`
	// The header-key to use. Defaults to Authorization
	HeaderKey string `json:"header_key,omitempty"`
	Token     Secret `json:"token,omitEmpty"`
}

type Config

type Config struct {
	// Auth can be used to configure the authentication performed on a request.
	Auth *AuthConfig `json:"auth,omitempty"`
	// A list of http-status-codes to consider OK. Defaults to 200 and 204.
	OkStatusCodes *[]int `json:"ok_status_codes,omitempty"`
	// Whether or not Response-data should be stored.
	ResponseData *bool `json:"response_data,omitempty"`
	// Concurrency for the requests to be made
	Concurrency *int `json:"concurrency,omitempty"`
	// Number of requests to be performaed
	RequestCount *int     `json:"request_count,omitempty"`
	Secrets      *Secrets `json:"secrets,omitempty"`
}

func (Config) MergeInto

func (c Config) MergeInto(config cmd.Config) cmd.Config

MergeWith will overwrite values with values in argument c.

type Duration

type Duration struct{ time.Duration }

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

type DynamicAuth

type DynamicAuth struct {
	Requests []DynamicRequest `json:"requests,omitempty"`
}

type DynamicRequest

type DynamicRequest struct {
	Method         string            `json:"method,omitempty"`
	Uri            string            `json:"uri,omitempty"`
	Headers        map[string]string `json:"headers,omitempty"`
	JsonRequest    bool              `json:"json_request,omitempty"`
	JsonResponse   bool              `json:"json_response,omitempty"`
	ResultJmesPath string            `json:"result_jmes_path,omitempty"`
	Body           interface{}       `json:"body,omitempty"`
}

type Endpoint

type Endpoint struct {
	requests.Endpoint
	Config *Config `json:"config,omitempty"`
}

type EndpointEntity

type EndpointEntity struct {
	Entity
	Endpoint
}

type EndpointPayload

type EndpointPayload struct {
	// required: true
	// example: https://example.com
	Url     string              `json:"url,omitempty" validate:"required,uri"`
	Headers map[string][]string `json:"headers,omitempty" validate:"dive,max=1000"`
	Config  *Config             `json:"config,omitempty"`
}

type Entity

type Entity struct {
	// Time of which the entity was created in the database
	// Required: true
	CreatedAt time.Time `json:"createdAt,omitempty"`
	// Time of which the entity was updated, if any
	UpdatedAt *time.Time `json:"updatedAt,omitempty"`
	// Unique identifier of the entity
	// Required: true
	ID string `json:"id,omitempty"`
	// If set, the item is considered deleted. The item will normally not get deleted from the database,
	// but it may if cleanup is required.
	Deleted *time.Time `json:"deleted,omitempty"`
}

type Frequency

type Frequency int8
const (
	FrequencyNull   Frequency = iota
	FrequencySecond Frequency = iota
	FrequencyMinute Frequency = iota
	FrequencyHour   Frequency = iota
	FrequencyDay    Frequency = iota
	FrequencyWeek   Frequency = iota
	FrequencyMonth  Frequency = iota
)

type ImpersionationCredentials

type ImpersionationCredentials struct {
	// Username to impersonate with. Needs to have the impersonation-role
	Username string `json:"username,omitempty"`
	Password Secret `json:"password,omitempty"`
	// UserID to impersonate as. This is preferred over UserNameToImpersonate
	UserIDToImpersonate string `json:"user_id_to_impersonate,omitempty"`
	// Will perform a lookup to get the ID of the username.
	UserNameToImpersonate string `json:"user_name_to_impersonate,omitempty"`
}

type RequestEntity

type RequestEntity struct {
	requests.Request
	Entity
	Config *Config `json:"config,omitempty"`
}

type RequestPayload

type RequestPayload struct {
	Body          string                 `json:"body,omitempty"`
	Query         string                 `json:"query,omitempty"`
	Variables     map[string]interface{} `json:"variables,omitempty" validate:"dive,max=1000"`
	Headers       map[string]string      `json:"headers,omitempty" validate:"dive,max=1000"`
	OperationName string                 `json:"operationName,required"`
	Method        string                 `json:"method"`
	Config        *Config                `json:"config,omitempty"`
}

type Schedule

type Schedule struct {
	// These are calculated in create/update. These are used for faster lookups.
	// Should be ordered Ascending, e.g. the first element
	Dates []time.Time `json:"dates"`
	// FIXME: Should not use schedulePaylaod directly here.
	SchedulePayload
	// From these, the dates above can be calculated
	LastRun   *time.Time `json:"lastRun,omitempty"`
	LastError string     `json:"lastError,omitempty"`
}

func (Schedule) NextRun

func (s Schedule) NextRun() *time.Time

Gets the next calculated run. Does not include the ForcedStartDate

func (Schedule) ShouldRun

func (s Schedule) ShouldRun() bool

Indicates whether this schedule should be run based on run-parameters

type ScheduleEntity

type ScheduleEntity struct {
	Entity
	Schedule
	Config *Config `json:"config,omitempty"`
}

type SchedulePayload

type SchedulePayload struct {
	RequestID  string `json:"requestID" validate:"required"`
	EndpointID string `json:"endpointID" validate:"required"`
	// If set to a positive value, the scheduler will not schedule more than this total concurrency
	// when starting this job, and when it is running.
	//
	// Some jobs might have been configured to run very slowly, with low concurrency,
	// high wait-times and can therefore run alongside other such jobs.
	MaxInterJobConcurrency bool       `json:"maxInterJobConcurrency"`
	Label                  string     `json:"label" validate:"required"`
	StartDate              time.Time  `json:"start_date" validate:"required"`
	ForcedStartDate        *time.Time `json:"forced_start_date"`
	EndDate                *time.Time `json:"end_date"`
	Frequency              Frequency  `json:"frequency,omitempty"`
	Multiplier             float64    `json:"multiplier,omitempty"`
	// TODO: either document what this value is or drop it. I dont remember why I added this.
	// I am sure there was a reason, though...
	Offsets []int   `json:"offsets,omitempty"`
	Config  *Config `json:"config,omitempty"`
	ScheduleWeek
}

func (SchedulePayload) CalculateNextRuns

func (s SchedulePayload) CalculateNextRuns(maxCount int) (ts []time.Time)

type ScheduleWeek

type ScheduleWeek struct {
	LocationStr string    `json:"location"`
	Monday      *Duration `json:"monday,omitempty"`
	Tuesday     *Duration `json:"tuesday,omitempty"`
	Wednesday   *Duration `json:"wednesday,omitempty"`
	Thursday    *Duration `json:"thursday,omitempty"`
	Friday      *Duration `json:"friday,omitempty"`
	Saturday    *Duration `json:"saturday,omitempty"`
	Sunday      *Duration `json:"sunday,omitempty"`
}

func (ScheduleWeek) NextRun

func (sw ScheduleWeek) NextRun(start time.Time, end *time.Time) *time.Time

type Secret

type Secret string

func (Secret) MarshalJSON

func (s Secret) MarshalJSON() ([]byte, error)

type Secrets

type Secrets map[string]Secret

type ServerInfo

type ServerInfo struct {
	// When the server was started
	ServerStartedAt time.Time
	// Short githash for current commit
	GitHash string
	// Version-number for commit
	Version string
	// Date of build
	BuildDate time.Time

	// Size of database.
	DatabaseSize    int64
	DatabaseSizeStr string
}

type StatEntity

type StatEntity struct {
	Entity
	requests.CompactRequestStatistics
}

type Storage

type Storage interface {
	Endpoints() (es map[string]EndpointEntity, err error)
	Endpoint(id string) (EndpointEntity, error)
	CreateEndpoint(e EndpointPayload) (EndpointEntity, error)
	UpdateEndpoint(id string, p EndpointPayload) (EndpointEntity, error)
	SoftDeleteEndpoint(id string) (EndpointEntity, error)

	Requests() (es map[string]RequestEntity, err error)
	Request(id string) (RequestEntity, error)
	CreateRequest(e RequestPayload) (RequestEntity, error)
	UpdateRequest(id string, p RequestPayload) (RequestEntity, error)
	SoftDeleteRequest(id string) (RequestEntity, error)

	Schedules() (es map[string]ScheduleEntity, err error)
	Schedule(id string) (ScheduleEntity, error)
	CreateSchedule(e SchedulePayload) (ScheduleEntity, error)
	UpdateSchedule(id string, p Schedule) (ScheduleEntity, error)
	SoftDeleteSchedule(id string) (ScheduleEntity, error)

	CompactStats() (es map[string]StatEntity, err error)
	CleanCompactStats() (err error)

	Size() (int64, error)

	CreateCompactStats(id string, createdAt time.Time, p StatPayload) error

	UpdateCompactStats(id string, createdAt time.Time, p StatPayload) error
}

Jump to

Keyboard shortcuts

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