Documentation ¶
Overview ¶
Package platform provides functionality for sending telemetry data to Percona Platform.
Index ¶
- type Client
- type Error
- type Logger
- type Option
- func WithBaseURL(url string) Option
- func WithClientTimeout(timeout time.Duration) Option
- func WithLogFullRequest() Option
- func WithLogger(l Logger) Option
- func WithResendTimeout(resendTimeout time.Duration) Option
- func WithRetryCount(count int) Option
- func WithTLSClientConfig(config *tls.Config) Option
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 (*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.
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 ¶
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 ¶
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 ¶
WithLogger method sets given writer for logging client request and response details.
Compliant to interface `Logger`.
func WithResendTimeout ¶
WithResendTimeout method sets default wait time to sleep before retrying request.
Default is 100 milliseconds.
func WithRetryCount ¶
WithRetryCount method enables retry on client and allows you to set no. of retry count. Client uses a Backoff mechanism.
func WithTLSClientConfig ¶
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`.