Shutdown

Random shutdown component that crashes a process using various methods.

Inherits: IConfigurable, IOpenable

Description

The Shutdown class allows you to create a random shutdown component that crashes a process using various methods.

Important points

  • The component is usually used for testing, but it can also be used in production to randomly crash microservices.
  • It follows the concept of “Chaos Monkey” popularized by Netflix.

Configuration parameters

  • mode: null - crash by NullPointer excepiton, zero - crash by dividing by zero, exception = crash by unhandled exception, exit - exit the process
  • min_timeout: minimum crash timeout in milliseconds (default: 5 mins)
  • max_timeout: maximum crash timeout in milliseconds (default: 15 minutes)

Instance methods

close

Closes component and frees used resources.

public Task CloseAsync(string correlationId)

  • correlationId: string - (optional) transaction id used to trace execution through the call chain.

Configure

Configures a component by passing configuration parameters.

public void Configure(ConfigParams config)

  • config: ConfigParams - configuration parameters to be set.

IsOpen

Checks if the component is opened.

public bool IsOpen()

  • returns: bool - true if the component has been opened and false otherwise.

Open

Opens the component.

public Task OpenAsync(string correlationId)

  • correlationId: string - (optional) transaction id used to trace execution through the call chain.

Shutdown

Crashes the process using the configured crash mode.

public void Shutdowns()

Examples

var shutdown = new Shutdown(); 
shutdown.Configure(ConfigParams.FromTuples(
    "mode", "exception"
 ));

shutdown.Shutdowns();         // Result: Bang!!! the process crashes