platform

package
v0.0.0-...-f193432 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package platform provides functionality for sending telemetry data to Percona Platform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is HTTP Percona Platform client.

func New

func New(opts ...Option) *Client

New creates new Percona Platform Telemetry client.

func (*Client) SendTelemetry

func (c *Client) SendTelemetry(ctx context.Context, accessToken string, report *genericv1.ReportRequest) error

SendTelemetry sends telemetry data to Percona Platform.

type Error

type Error struct {
	Code    int      `json:"code"`
	Message string   `json:"message"`
	Details []string `json:"details"`
}

Error is a model of an error response from Percona Platform.

func (Error) Error

func (e Error) Error() string

Error error interface implementation.

func (Error) String

func (e Error) String() string

String returns a string representation of an error.

type Logger

type Logger interface {
	Errorf(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Debugf(format string, v ...interface{})
}

Logger interface is to abstract the logging from Client. Gives control to the Client users, choice of the logger.

type Option

type Option func(*Client)

Option is an option for Client returned by constructor.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL method is to set Base URL in the client instance. It will be used with request raised from this client with relative URL

// Setting HTTP address
client.WithBaseURL("http://myjeeva.com")

// Setting HTTPS address
client.WithBaseURL("https://myjeeva.com").

func WithClientTimeout

func WithClientTimeout(timeout time.Duration) Option

WithClientTimeout method sets timeout for request raised from client.

client.WithClientTimeout(time.Duration(1 * time.Minute)).

func WithLogFullRequest

func WithLogFullRequest() Option

WithLogFullRequest enable/disables logging of request/response body and headers.

func WithLogger

func WithLogger(l Logger) Option

WithLogger method sets given writer for logging client request and response details.

Compliant to interface `Logger`.

func WithResendTimeout

func WithResendTimeout(resendTimeout time.Duration) Option

WithResendTimeout method sets default wait time to sleep before retrying request.

Default is 100 milliseconds.

func WithRetryCount

func WithRetryCount(count int) Option

WithRetryCount method enables retry on client and allows you to set no. of retry count. Client uses a Backoff mechanism.

func WithTLSClientConfig

func WithTLSClientConfig(config *tls.Config) Option

WithTLSClientConfig method sets TLSClientConfig for underling client Transport.

For Example:

// One can set custom root-certificate. Refer: http://golang.org/pkg/crypto/tls/#example_Dial
client.WithTLSClientConfig(&tls.Config{ RootCAs: roots })

// or One can disable security check (https)
client.WithTLSClientConfig(&tls.Config{ InsecureSkipVerify: true })

Note: This method overwrites existing `TLSClientConfig`.

Jump to

Keyboard shortcuts

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