fifo

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fifo provides Group, which is a list of modifiers that are executed consecutively. By default, when an error is returned by a modifier, the execution of the modifiers is halted, and the error is returned. Optionally, when errror aggregation is enabled (by calling SetAggretateErrors(true)), modifier execution is not halted, and errors are aggretated and returned after all modifiers have been executed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

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

Group is a martian.RequestResponseModifier that maintains lists of request and response modifiers executed on a first-in, first-out basis. The Group allows adding new modifiers on the run.

func NewGroup

func NewGroup() *Group

NewGroup returns a modifier group.

func (*Group) AddRequestModifier

func (g *Group) AddRequestModifier(reqmod martian.RequestModifier)

AddRequestModifier adds a RequestModifier to the group's list of request modifiers.

func (*Group) AddResponseModifier

func (g *Group) AddResponseModifier(resmod martian.ResponseModifier)

AddResponseModifier adds a ResponseModifier to the group's list of response modifiers.

func (*Group) ModifyRequest

func (g *Group) ModifyRequest(req *http.Request) error

ModifyRequest modifies the request. By default, aggregateErrors is false; if an error is returned by a RequestModifier the error is returned and no further modifiers are run. When aggregateErrors is set to true, the errors returned by each modifier in the group are aggregated.

func (*Group) ModifyResponse

func (g *Group) ModifyResponse(res *http.Response) error

ModifyResponse modifies the request. By default, aggregateErrors is false; if an error is returned by a RequestModifier the error is returned and no further modifiers are run. When aggregateErrors is set to true, the errors returned by each modifier in the group are aggregated.

func (*Group) SetAggregateErrors

func (g *Group) SetAggregateErrors(aggerr bool)

SetAggregateErrors sets the error behavior for the Group. When true, the Group will continue to execute consecutive modifiers when a modifier in the group encounters an error. The Group will then return all errors returned by each modifier after all modifiers have been executed. When false, if an error is returned by a modifier, the error is returned by ModifyRequest/Response and no further modifiers are run. By default, error aggregation is disabled.

func (*Group) ToImmutable

func (g *Group) ToImmutable() *ImmutableGroup

ToImmutable creates ImmutableGroup from existing Group. If a Group has a modifier that is another Group it will also become immutable. Moreover, if the aggregateErrors settings match between the two groups the other group's modifiers are inlined.

type ImmutableGroup

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

ImmutableGroup is a martian.RequestResponseModifier that maintains lists of request and response modifiers executed on a first-in, first-out basis. ImmutableGroup can be constructed only from a Group. It cannot be modified.

func (*ImmutableGroup) ModifyRequest

func (g *ImmutableGroup) ModifyRequest(req *http.Request) error

ModifyRequest modifies the request. By default, aggregateErrors is false; if an error is returned by a RequestModifier the error is returned and no further modifiers are run. When aggregateErrors is set to true, the errors returned by each modifier in the group are aggregated.

func (*ImmutableGroup) ModifyResponse

func (g *ImmutableGroup) ModifyResponse(res *http.Response) error

ModifyResponse modifies the request. By default, aggregateErrors is false; if an error is returned by a RequestModifier the error is returned and no further modifiers are run. When aggregateErrors is set to true, the errors returned by each modifier in the group are aggregated.

Jump to

Keyboard shortcuts

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