client

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 20 Imported by: 73

Documentation

Index

Constants

View Source
const Version = "2.0.0"

Variables

View Source
var AvailableMetricTypes = []MetricType{HTTP, API, SDK}
View Source
var UserAgentHeader string

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	Message     string            `json:"message"`
	Took        float32           `json:"took"`
	RequestId   string            `json:"requestId"`
	Errors      map[string]string `json:"errors"`
	StatusCode  int
	ErrorHeader string
	// contains filtered or unexported fields
}

func (*ApiError) Error

func (ar *ApiError) Error() string

type ApiMetric

type ApiMetric struct {
	TransactionId  string         `json:"transactionId"`
	Duration       int64          `json:"duration"`
	ResourcePath   string         `json:"resourcePath"`
	ResultMetadata ResultMetadata `json:"resultMetadata, omitempty"`
	HttpResponse   http.Response  `json:"httpResponse, omitempty"`
}

func (*ApiMetric) Type

func (apiMetric *ApiMetric) Type() string

type ApiRequest

type ApiRequest interface {
	Validate() error
	ResourcePath() string
	Method() string
	Metadata(apiRequest ApiRequest) map[string]interface{}
	RequestParams() map[string]string
}

type ApiResult

type ApiResult interface {
	Parse(response *http.Response, result ApiResult) error
	ValidateResultMetadata() error
	// contains filtered or unexported methods
}

type ApiUrl

type ApiUrl string
const (
	API_URL         ApiUrl = "api.opsgenie.com"
	API_URL_EU      ApiUrl = "api.eu.opsgenie.com"
	API_URL_SANDBOX ApiUrl = "api.sandbox.opsgenie.com"
)

type AsyncApiResult

type AsyncApiResult interface {
	ApiResult
	RetrieveStatus(ctx context.Context, request ApiRequest, result ApiResult) error
}

type AsyncBaseResult

type AsyncBaseResult struct {
	Client *OpsGenieClient
}

func (*AsyncBaseResult) RetrieveStatus

func (ar *AsyncBaseResult) RetrieveStatus(ctx context.Context, request ApiRequest, result ApiResult) error

type BaseRequest

type BaseRequest struct {
}

func (*BaseRequest) Metadata

func (r *BaseRequest) Metadata(apiRequest ApiRequest) map[string]interface{}

func (*BaseRequest) RequestParams

func (r *BaseRequest) RequestParams() map[string]string

type Config

type Config struct {
	ApiKey string

	OpsGenieAPIURL ApiUrl

	ProxyConfiguration *ProxyConfiguration

	RequestTimeout time.Duration

	HttpClient *http.Client

	Backoff retryablehttp.Backoff

	RetryPolicy retryablehttp.CheckRetry

	RetryCount int

	LogLevel logrus.Level

	Logger *logrus.Logger
	// contains filtered or unexported fields
}

func Default

func Default() *Config

func (*Config) ConfigureLogLevel

func (conf *Config) ConfigureLogLevel(level string)

func (Config) Validate

func (conf Config) Validate() error

type HttpMetric

type HttpMetric struct {
	TransactionId string  `json:"transactionId"`
	RetryCount    int     `json:"retryCount"`
	Error         error   `json:"error,omitempty"`
	Duration      int64   `json:"duration"`
	ResourcePath  string  `json:"resourcePath"`
	Status        string  `json:"status,omitempty"`
	StatusCode    int     `json:"statusCode,omitempty"`
	HttpRequest   request `json:"request,omitempty"`
}

func (*HttpMetric) Type

func (hm *HttpMetric) Type() string

type Metric

type Metric interface {
	Type() string
}

type MetricPublisher

type MetricPublisher struct {
	SubscriberMap map[string][]MetricSubscriber
	// contains filtered or unexported fields
}

type MetricSubscriber

type MetricSubscriber struct {
	Process Process
}

func (*MetricSubscriber) Register

func (s *MetricSubscriber) Register(metricType MetricType)

type MetricType

type MetricType string
const (
	HTTP MetricType = "http"
	SDK  MetricType = "sdk"
	API  MetricType = "api"
)

type OpsGenieClient

type OpsGenieClient struct {
	RetryableClient *retryablehttp.Client
	Config          *Config
}

func NewOpsGenieClient

func NewOpsGenieClient(cfg *Config) (*OpsGenieClient, error)

func (*OpsGenieClient) Exec

func (cli *OpsGenieClient) Exec(ctx context.Context, request ApiRequest, result ApiResult) error

type Process

type Process func(metric Metric) interface{}

type Protocol

type Protocol string
const (
	Http   Protocol = "http"
	Https  Protocol = "https"
	Socks5 Protocol = "socks5"
)

type ProxyConfiguration

type ProxyConfiguration struct {
	Username string
	Password string
	Host     string
	Protocol Protocol
	Port     int
}

type ResultMetadata

type ResultMetadata struct {
	RequestId       string  `json:"requestId"`
	ResponseTime    float32 `json:"took"`
	RateLimitState  string
	RateLimitReason string
	RateLimitPeriod string
	RetryCount      int
}

func (*ResultMetadata) Parse

func (rm *ResultMetadata) Parse(response *http.Response, result ApiResult) error

func (*ResultMetadata) ValidateResultMetadata

func (rm *ResultMetadata) ValidateResultMetadata() error

type SdkMetric

type SdkMetric struct {
	TransactionId     string     `json:"transactionId"`
	Duration          int64      `json:"duration"`
	ErrorType         string     `json:"errorType"`
	ErrorMessage      string     `json:"errorMessage"`
	ResourcePath      string     `json:"resourcePath"`
	SdkRequestDetails ApiRequest `json:"sdkRequestDetails"`
	SdkResultDetails  ApiResult  `json:"sdkResultDetails"`
}

func (*SdkMetric) Type

func (apiMetric *SdkMetric) Type() string

Jump to

Keyboard shortcuts

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