merger

package
v1.15.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Merger

type Merger interface {
	MergeResponses([][]byte) ([]byte, error)
}

Merger represents logic for merging response bodies.

type Noop

type Noop struct{}

Noop is an implementation of the Merger interface which does not actually merge responses, but just returns an arbitrary response(the first in the list). It can be used for write requests where the response is either empty or inconsequential.

func (Noop) MergeResponses

func (Noop) MergeResponses(in [][]byte) ([]byte, error)

type V1Alerts

type V1Alerts struct{}

V1Alerts implements the Merger interface for GET /v1/alerts. It returns the union of alerts over all the responses. When the same alert exists in multiple responses, the alert instance in the earliest response is returned in the final response. We cannot use the UpdatedAt timestamp as for V2Alerts, because the v1 API does not provide it.

func (V1Alerts) MergeResponses

func (V1Alerts) MergeResponses(in [][]byte) ([]byte, error)

type V1SilenceID added in v1.10.0

type V1SilenceID struct{}

V1Silences implements the Merger interface for GET /v1/silences. This re-uses the logic for merging /v2/silences, with additional handling for the enclosing status/data fields. Unlike for alerts, the API definitions for silences are almost identical between v1 and v2. The differences are that the fields in the JSON output are ordered differently, and the timestamps have more precision in v1, but these differences should not be problematic to clients.

func (V1SilenceID) MergeResponses added in v1.10.0

func (V1SilenceID) MergeResponses(in [][]byte) ([]byte, error)

type V1Silences added in v1.10.0

type V1Silences struct{}

V1Silences implements the Merger interface for GET /v1/silences. Unlike for alerts, the API definitions for silences are almost identical between v1 and v2. The differences are that the fields in the JSON output are ordered differently, and the timestamps have more precision in v1, but these differences should not be problematic to clients. Therefore, the implementation re-uses the v2 types, with additional handling for the enclosing status/data fields.

func (V1Silences) MergeResponses added in v1.10.0

func (V1Silences) MergeResponses(in [][]byte) ([]byte, error)

type V2AlertGroups added in v1.10.0

type V2AlertGroups struct{}

V2AlertGroups implements the Merger interface for GET /v2/alerts/groups. It returns the union of alert groups over all the responses. When the same alert exists in the same group for multiple responses, the instance of that alert with the most recent UpdatedAt timestamp is returned in that group within the response.

func (V2AlertGroups) MergeResponses added in v1.10.0

func (V2AlertGroups) MergeResponses(in [][]byte) ([]byte, error)

type V2Alerts added in v1.10.0

type V2Alerts struct{}

V2Alerts implements the Merger interface for GET /v2/alerts. It returns the union of alerts over all the responses. When the same alert exists in multiple responses, the instance of that alert with the most recent UpdatedAt timestamp is returned in the response.

func (V2Alerts) MergeResponses added in v1.10.0

func (V2Alerts) MergeResponses(in [][]byte) ([]byte, error)

type V2SilenceID added in v1.10.0

type V2SilenceID struct{}

V2SilenceID implements the Merger interface for GET /v2/silence/{id}. It returns the most recently updated silence (newest UpdatedAt timestamp).

func (V2SilenceID) MergeResponses added in v1.10.0

func (V2SilenceID) MergeResponses(in [][]byte) ([]byte, error)

type V2Silences added in v1.10.0

type V2Silences struct{}

V2Silences implements the Merger interface for GET /v2/silences. It returns the union of silences over all the responses. When a silence with the same ID exists in multiple responses, the silence most recently updated silence is returned (newest UpdatedAt timestamp).

func (V2Silences) MergeResponses added in v1.10.0

func (V2Silences) MergeResponses(in [][]byte) ([]byte, error)

Jump to

Keyboard shortcuts

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