MM-34932: Bump dependencies (#17708)
https://mattermost.atlassian.net/browse/MM-34932 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fff09bf210
Коммит
3299a72adb
10
vendor/github.com/splitio/go-split-commons/v3/service/api/client.go
сгенерированный
поставляемый
10
vendor/github.com/splitio/go-split-commons/v3/service/api/client.go
сгенерированный
поставляемый
@@ -30,7 +30,6 @@ type Client interface {
|
||||
type HTTPClient struct {
|
||||
url string
|
||||
httpClient *http.Client
|
||||
headers map[string]string
|
||||
logger logging.LoggerInterface
|
||||
apikey string
|
||||
metadata dtos.Metadata
|
||||
@@ -44,8 +43,7 @@ func NewHTTPClient(
|
||||
logger logging.LoggerInterface,
|
||||
metadata dtos.Metadata,
|
||||
) Client {
|
||||
var timeout int
|
||||
timeout = cfg.HTTPTimeout
|
||||
timeout := cfg.HTTPTimeout
|
||||
client := &http.Client{Timeout: time.Duration(timeout) * time.Second}
|
||||
return &HTTPClient{
|
||||
url: endpoint,
|
||||
@@ -66,11 +64,9 @@ func (c *HTTPClient) Get(service string, headers map[string]string) ([]byte, err
|
||||
c.logger.Debug("Authorization [ApiKey]: ", logging.ObfuscateAPIKey(authorization))
|
||||
req.Header.Add("Accept-Encoding", "gzip")
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("SplitSDKVersion", c.metadata.SDKVersion)
|
||||
req.Header.Add("SplitSDKMachineName", c.metadata.MachineName)
|
||||
req.Header.Add("SplitSDKMachineIP", c.metadata.MachineIP)
|
||||
parsedHeaders := AddMetadataToHeaders(c.metadata, headers, nil)
|
||||
|
||||
for headerName, headerValue := range headers {
|
||||
for headerName, headerValue := range parsedHeaders {
|
||||
req.Header.Add(headerName, headerValue)
|
||||
}
|
||||
|
||||
|
||||
32
vendor/github.com/splitio/go-split-commons/v3/service/api/helpers.go
сгенерированный
поставляемый
Обычный файл
32
vendor/github.com/splitio/go-split-commons/v3/service/api/helpers.go
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,32 @@
|
||||
package api
|
||||
|
||||
import "github.com/splitio/go-split-commons/v3/dtos"
|
||||
|
||||
const (
|
||||
splitSDKVersion = "SplitSDKVersion"
|
||||
splitSDKMachineName = "SplitSDKMachineName"
|
||||
splitSDKMachineIP = "SplitSDKMachineIP"
|
||||
splitSDKClientKey = "SplitSDKClientKey"
|
||||
|
||||
unknown = "unknown"
|
||||
na = "NA"
|
||||
)
|
||||
|
||||
// AddMetadataToHeaders adds metadata in headers
|
||||
func AddMetadataToHeaders(metadata dtos.Metadata, extraHeaders map[string]string, clientKey *string) map[string]string {
|
||||
headers := make(map[string]string)
|
||||
headers[splitSDKVersion] = metadata.SDKVersion
|
||||
if metadata.MachineName != na && metadata.MachineName != unknown {
|
||||
headers[splitSDKMachineName] = metadata.MachineName
|
||||
}
|
||||
if metadata.MachineIP != na && metadata.MachineIP != unknown {
|
||||
headers[splitSDKMachineIP] = metadata.MachineIP
|
||||
}
|
||||
for header, value := range extraHeaders {
|
||||
headers[header] = value
|
||||
}
|
||||
if clientKey != nil {
|
||||
headers[splitSDKClientKey] = *clientKey
|
||||
}
|
||||
return headers
|
||||
}
|
||||
15
vendor/github.com/splitio/go-split-commons/v3/service/api/http_fetchers.go
сгенерированный
поставляемый
15
vendor/github.com/splitio/go-split-commons/v3/service/api/http_fetchers.go
сгенерированный
поставляемый
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/splitio/go-split-commons/v3/conf"
|
||||
"github.com/splitio/go-split-commons/v3/dtos"
|
||||
"github.com/splitio/go-split-commons/v3/service"
|
||||
"github.com/splitio/go-toolkit/v4/logging"
|
||||
)
|
||||
|
||||
@@ -41,12 +42,7 @@ type HTTPSplitFetcher struct {
|
||||
}
|
||||
|
||||
// NewHTTPSplitFetcher instantiates and return an HTTPSplitFetcher
|
||||
func NewHTTPSplitFetcher(
|
||||
apikey string,
|
||||
cfg conf.AdvancedConfig,
|
||||
logger logging.LoggerInterface,
|
||||
metadata dtos.Metadata,
|
||||
) *HTTPSplitFetcher {
|
||||
func NewHTTPSplitFetcher(apikey string, cfg conf.AdvancedConfig, logger logging.LoggerInterface, metadata dtos.Metadata) service.SplitFetcher {
|
||||
return &HTTPSplitFetcher{
|
||||
httpFetcherBase: httpFetcherBase{
|
||||
client: NewHTTPClient(apikey, cfg, cfg.SdkURL, logger, metadata),
|
||||
@@ -79,12 +75,7 @@ type HTTPSegmentFetcher struct {
|
||||
}
|
||||
|
||||
// NewHTTPSegmentFetcher instantiates and returns a new HTTPSegmentFetcher.
|
||||
func NewHTTPSegmentFetcher(
|
||||
apikey string,
|
||||
cfg conf.AdvancedConfig,
|
||||
logger logging.LoggerInterface,
|
||||
metadata dtos.Metadata,
|
||||
) *HTTPSegmentFetcher {
|
||||
func NewHTTPSegmentFetcher(apikey string, cfg conf.AdvancedConfig, logger logging.LoggerInterface, metadata dtos.Metadata) service.SegmentFetcher {
|
||||
return &HTTPSegmentFetcher{
|
||||
httpFetcherBase: httpFetcherBase{
|
||||
client: NewHTTPClient(apikey, cfg, cfg.SdkURL, logger, metadata),
|
||||
|
||||
149
vendor/github.com/splitio/go-split-commons/v3/service/api/http_recorders.go
сгенерированный
поставляемый
149
vendor/github.com/splitio/go-split-commons/v3/service/api/http_recorders.go
сгенерированный
поставляемый
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/splitio/go-split-commons/v3/conf"
|
||||
"github.com/splitio/go-split-commons/v3/dtos"
|
||||
"github.com/splitio/go-split-commons/v3/service"
|
||||
"github.com/splitio/go-toolkit/v4/logging"
|
||||
)
|
||||
|
||||
@@ -15,20 +16,7 @@ type httpRecorderBase struct {
|
||||
|
||||
// RecordRaw records raw data
|
||||
func (h *httpRecorderBase) RecordRaw(url string, data []byte, metadata dtos.Metadata, extraHeaders map[string]string) error {
|
||||
headers := make(map[string]string)
|
||||
headers["SplitSDKVersion"] = metadata.SDKVersion
|
||||
if metadata.MachineName != "NA" && metadata.MachineName != "unknown" {
|
||||
headers["SplitSDKMachineName"] = metadata.MachineName
|
||||
}
|
||||
if metadata.MachineIP != "NA" && metadata.MachineIP != "unknown" {
|
||||
headers["SplitSDKMachineIP"] = metadata.MachineIP
|
||||
}
|
||||
if extraHeaders != nil {
|
||||
for header, value := range extraHeaders {
|
||||
headers[header] = value
|
||||
}
|
||||
}
|
||||
return h.client.Post(url, data, headers)
|
||||
return h.client.Post(url, data, AddMetadataToHeaders(metadata, extraHeaders, nil))
|
||||
}
|
||||
|
||||
// HTTPImpressionRecorder is a struct responsible for submitting impression bulks to the backend
|
||||
@@ -74,11 +62,7 @@ func (i *HTTPImpressionRecorder) RecordImpressionsCount(pf dtos.ImpressionsCount
|
||||
}
|
||||
|
||||
// NewHTTPImpressionRecorder instantiates an HTTPImpressionRecorder
|
||||
func NewHTTPImpressionRecorder(
|
||||
apikey string,
|
||||
cfg conf.AdvancedConfig,
|
||||
logger logging.LoggerInterface,
|
||||
) *HTTPImpressionRecorder {
|
||||
func NewHTTPImpressionRecorder(apikey string, cfg conf.AdvancedConfig, logger logging.LoggerInterface) service.ImpressionsRecorder {
|
||||
client := NewHTTPClient(apikey, cfg, cfg.EventsURL, logger, dtos.Metadata{})
|
||||
return &HTTPImpressionRecorder{
|
||||
httpRecorderBase: httpRecorderBase{
|
||||
@@ -88,77 +72,6 @@ func NewHTTPImpressionRecorder(
|
||||
}
|
||||
}
|
||||
|
||||
// HTTPMetricsRecorder is a struct responsible for submitting metrics (latency, gauge, counters) to the backend
|
||||
type HTTPMetricsRecorder struct {
|
||||
httpRecorderBase
|
||||
}
|
||||
|
||||
// RecordCounters method submits counter metrics to the backend
|
||||
func (m *HTTPMetricsRecorder) RecordCounters(counters []dtos.CounterDTO, metadata dtos.Metadata) error {
|
||||
data, err := json.Marshal(counters)
|
||||
if err != nil {
|
||||
m.logger.Error("Error marshaling JSON", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.RecordRaw("/metrics/counters", data, metadata, nil)
|
||||
if err != nil {
|
||||
m.logger.Error("Error posting counters", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RecordLatencies method submits latency metrics to the backend
|
||||
func (m *HTTPMetricsRecorder) RecordLatencies(latencies []dtos.LatenciesDTO, metadata dtos.Metadata) error {
|
||||
data, err := json.Marshal(latencies)
|
||||
if err != nil {
|
||||
m.logger.Error("Error marshaling JSON", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.RecordRaw("/metrics/times", data, metadata, nil)
|
||||
if err != nil {
|
||||
m.logger.Error("Error posting latencies", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RecordGauge method submits gauge metrics to the backend
|
||||
func (m *HTTPMetricsRecorder) RecordGauge(gauge dtos.GaugeDTO, metadata dtos.Metadata) error {
|
||||
data, err := json.Marshal(gauge)
|
||||
if err != nil {
|
||||
m.logger.Error("Error marshaling JSON", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.RecordRaw("/metrics/gauge", data, metadata, nil)
|
||||
if err != nil {
|
||||
m.logger.Error("Error posting gauges", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewHTTPMetricsRecorder instantiates an HTTPMetricsRecorder
|
||||
func NewHTTPMetricsRecorder(
|
||||
apikey string,
|
||||
cfg conf.AdvancedConfig,
|
||||
logger logging.LoggerInterface,
|
||||
) *HTTPMetricsRecorder {
|
||||
client := NewHTTPClient(apikey, cfg, cfg.EventsURL, logger, dtos.Metadata{})
|
||||
return &HTTPMetricsRecorder{
|
||||
httpRecorderBase: httpRecorderBase{
|
||||
client: client,
|
||||
logger: logger,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// HTTPEventsRecorder is a struct responsible for submitting events bulks to the backend
|
||||
type HTTPEventsRecorder struct {
|
||||
httpRecorderBase
|
||||
@@ -182,11 +95,7 @@ func (i *HTTPEventsRecorder) Record(events []dtos.EventDTO, metadata dtos.Metada
|
||||
}
|
||||
|
||||
// NewHTTPEventsRecorder instantiates an HTTPEventsRecorder
|
||||
func NewHTTPEventsRecorder(
|
||||
apikey string,
|
||||
cfg conf.AdvancedConfig,
|
||||
logger logging.LoggerInterface,
|
||||
) *HTTPEventsRecorder {
|
||||
func NewHTTPEventsRecorder(apikey string, cfg conf.AdvancedConfig, logger logging.LoggerInterface) service.EventsRecorder {
|
||||
client := NewHTTPClient(apikey, cfg, cfg.EventsURL, logger, dtos.Metadata{})
|
||||
return &HTTPEventsRecorder{
|
||||
httpRecorderBase: httpRecorderBase{
|
||||
@@ -195,3 +104,53 @@ func NewHTTPEventsRecorder(
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// HTTPTelemetryRecorder is a struct responsible for submitting telemetry to the backend
|
||||
type HTTPTelemetryRecorder struct {
|
||||
httpRecorderBase
|
||||
}
|
||||
|
||||
// NewHTTPTelemetryRecorder instantiates an HTTPTelemetryRecorder
|
||||
func NewHTTPTelemetryRecorder(apikey string, cfg conf.AdvancedConfig, logger logging.LoggerInterface) service.TelemetryRecorder {
|
||||
client := NewHTTPClient(apikey, cfg, cfg.TelemetryServiceURL, logger, dtos.Metadata{})
|
||||
return &HTTPTelemetryRecorder{
|
||||
httpRecorderBase: httpRecorderBase{
|
||||
client: client,
|
||||
logger: logger,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// RecordConfig method submits config
|
||||
func (m *HTTPTelemetryRecorder) RecordConfig(config dtos.Config, metadata dtos.Metadata) error {
|
||||
data, err := json.Marshal(config)
|
||||
if err != nil {
|
||||
m.logger.Error("Error marshaling JSON", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.RecordRaw("/metrics/config", data, metadata, nil)
|
||||
if err != nil {
|
||||
m.logger.Error("Error posting config", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RecordStats method submits stats
|
||||
func (m *HTTPTelemetryRecorder) RecordStats(stats dtos.Stats, metadata dtos.Metadata) error {
|
||||
data, err := json.Marshal(stats)
|
||||
if err != nil {
|
||||
m.logger.Error("Error marshaling JSON", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.RecordRaw("/metrics/usage", data, metadata, nil)
|
||||
if err != nil {
|
||||
m.logger.Error("Error posting usage", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
35
vendor/github.com/splitio/go-split-commons/v3/service/api/split.go
сгенерированный
поставляемый
Обычный файл
35
vendor/github.com/splitio/go-split-commons/v3/service/api/split.go
сгенерированный
поставляемый
Обычный файл
@@ -0,0 +1,35 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/splitio/go-split-commons/v3/conf"
|
||||
"github.com/splitio/go-split-commons/v3/dtos"
|
||||
"github.com/splitio/go-split-commons/v3/service"
|
||||
"github.com/splitio/go-toolkit/v4/logging"
|
||||
)
|
||||
|
||||
// SplitAPI struct for fetchers and recorders
|
||||
type SplitAPI struct {
|
||||
AuthClient service.AuthClient
|
||||
SplitFetcher service.SplitFetcher
|
||||
SegmentFetcher service.SegmentFetcher
|
||||
ImpressionRecorder service.ImpressionsRecorder
|
||||
EventRecorder service.EventsRecorder
|
||||
TelemetryRecorder service.TelemetryRecorder
|
||||
}
|
||||
|
||||
// NewSplitAPI creates new splitAPI
|
||||
func NewSplitAPI(
|
||||
apikey string,
|
||||
conf conf.AdvancedConfig,
|
||||
logger logging.LoggerInterface,
|
||||
metadata dtos.Metadata,
|
||||
) *SplitAPI {
|
||||
return &SplitAPI{
|
||||
AuthClient: NewAuthAPIClient(apikey, conf, logger, metadata),
|
||||
SplitFetcher: NewHTTPSplitFetcher(apikey, conf, logger, metadata),
|
||||
SegmentFetcher: NewHTTPSegmentFetcher(apikey, conf, logger, metadata),
|
||||
ImpressionRecorder: NewHTTPImpressionRecorder(apikey, conf, logger),
|
||||
EventRecorder: NewHTTPEventsRecorder(apikey, conf, logger),
|
||||
TelemetryRecorder: NewHTTPTelemetryRecorder(apikey, conf, logger),
|
||||
}
|
||||
}
|
||||
10
vendor/github.com/splitio/go-split-commons/v3/service/api/sse/client.go
сгенерированный
поставляемый
10
vendor/github.com/splitio/go-split-commons/v3/service/api/sse/client.go
сгенерированный
поставляемый
@@ -5,6 +5,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/splitio/go-split-commons/v3/conf"
|
||||
"github.com/splitio/go-split-commons/v3/dtos"
|
||||
"github.com/splitio/go-split-commons/v3/service/api"
|
||||
"github.com/splitio/go-toolkit/v4/logging"
|
||||
"github.com/splitio/go-toolkit/v4/sse"
|
||||
"github.com/splitio/go-toolkit/v4/struct/traits/lifecycle"
|
||||
@@ -28,6 +30,8 @@ type StreamingClientImpl struct {
|
||||
sseClient *sse.Client
|
||||
logger logging.LoggerInterface
|
||||
lifecycle lifecycle.Manager
|
||||
metadata dtos.Metadata
|
||||
clientKey *string
|
||||
}
|
||||
|
||||
// Status constants
|
||||
@@ -42,12 +46,14 @@ const (
|
||||
type IncomingMessage = sse.RawEvent
|
||||
|
||||
// NewStreamingClient creates new SSE Client
|
||||
func NewStreamingClient(cfg *conf.AdvancedConfig, logger logging.LoggerInterface) *StreamingClientImpl {
|
||||
func NewStreamingClient(cfg *conf.AdvancedConfig, logger logging.LoggerInterface, metadata dtos.Metadata, clientKey *string) *StreamingClientImpl {
|
||||
sseClient, _ := sse.NewClient(cfg.StreamingServiceURL, keepAlive, logger)
|
||||
|
||||
client := &StreamingClientImpl{
|
||||
sseClient: sseClient,
|
||||
logger: logger,
|
||||
metadata: metadata,
|
||||
clientKey: clientKey,
|
||||
}
|
||||
client.lifecycle.Setup()
|
||||
return client
|
||||
@@ -72,7 +78,7 @@ func (s *StreamingClientImpl) ConnectStreaming(token string, streamingStatus cha
|
||||
return
|
||||
}
|
||||
firstEventReceived := gtSync.NewAtomicBool(false)
|
||||
out := s.sseClient.Do(params, func(m IncomingMessage) {
|
||||
out := s.sseClient.Do(params, api.AddMetadataToHeaders(s.metadata, nil, s.clientKey), func(m IncomingMessage) {
|
||||
if firstEventReceived.TestAndSet() && !m.IsError() {
|
||||
streamingStatus <- StatusFirstEventOk
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user