chaos

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package chaos is used to simulate Chaos engineering (random failures) in the SMTPD server. See https://en.wikipedia.org/wiki/Chaos_engineering See https://mailpit.axllent.org/docs/integration/chaos/

Index

Constants

This section is empty.

Variables

View Source
var (
	// Enabled is a flag to enable or disable support for chaos
	Enabled = false

	// Config is the global Chaos configuration
	Config = Triggers{
		Sender:         Trigger{ErrorCode: 451, Probability: 0},
		Recipient:      Trigger{ErrorCode: 451, Probability: 0},
		Authentication: Trigger{ErrorCode: 535, Probability: 0},
	}
)

Functions

func Set

func Set(key string, errorCode int, probability int) error

Set will set the chaos configuration for the given key (CLI & setMap())

func SetFromStruct

func SetFromStruct(c Triggers) error

SetFromStruct will set a whole map of chaos configurations (ie: API)

Types

type Trigger

type Trigger struct {
	// SMTP error code to return. The value must range from 400 to 599.
	// required: true
	// example: 451
	ErrorCode int

	// Probability (chance) of triggering the error. The value must range from 0 to 100.
	// required: true
	// example: 5
	Probability int
}

Trigger for Chaos

func (Trigger) Trigger

func (c Trigger) Trigger() (bool, int)

Trigger will return whether the Chaos rule is triggered based on the configuration and a randomly-generated percentage value.

type Triggers

type Triggers struct {
	// Sender trigger to fail on From, Sender
	Sender Trigger
	// Recipient trigger to fail on To, Cc, Bcc
	Recipient Trigger
	// Authentication trigger to fail while authenticating (auth must be configured)
	Authentication Trigger
}

Triggers for the Chaos configuration

swagger:model Triggers

Jump to

Keyboard shortcuts

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