Documentation ¶
Overview ¶
package service provides functions and methods for creating and running the api of the proxy service
Index ¶
- Constants
- func Call(client ProxyServiceClient, request *http.Request, result interface{}) error
- func CreateRequest(method string, path string, params interface{}) (*http.Request, error)
- func MarshalJSONResponse(obj interface{}, w http.ResponseWriter) error
- func NewError(message, url string, statusCode int) error
- type DatabaseStatusResponse
- type ProxyService
- type ProxyServiceClient
- type ProxyServiceClientConfig
- type RequestError
- type RequestInterceptor
Constants ¶
const ( DefaultAnonymousUserAgent = "anon" // Service defined context keys DecodedRequestContextKey = "X-FURY-PROXY-DECODED-REQUEST-BODY" OriginRoundtripLatencyMillisecondsKey = "X-FURY-PROXY-ORIGIN-ROUNDTRIP-LATENCY-MILLISECONDS" RequestStartTimeContextKey = "X-FURY-PROXY-REQUEST-START-TIME" RequestHostnameContextKey = "X-FURY-PROXY-REQUEST-HOSTNAME" RequestIPContextKey = "X-FURY-PROXY-REQUEST-IP" RequestUserAgentContextKey = "X-FURY-PROXY-USER-AGENT" RequestRefererContextKey = "X-FURY-PROXY-REFERER" RequestOriginContextKey = "X-FURY-PROXY-ORIGIN" // Values defined by upstream services LoadBalancerForwardedForHeaderKey = "X-Forwarded-For" UserAgentHeaderkey = "User-Agent" RefererHeaderKey = "Referer" OriginHeaderKey = "Origin" )
const (
DatabaseStatusPath = "/status/database"
)
Variables ¶
This section is empty.
Functions ¶
func Call ¶
func Call(client ProxyServiceClient, request *http.Request, result interface{}) error
Call makes an http request to a JSON HTTP api decoding the JSON response to the result interface if non-nil returning error (if any)
func CreateRequest ¶
CreateRequest isolates duplicate code in creating http search request.
func MarshalJSONResponse ¶
func MarshalJSONResponse(obj interface{}, w http.ResponseWriter) error
MarshalJSONResponse marshals an interface into the response body and sets JSON content type headers
Types ¶
type DatabaseStatusResponse ¶
type DatabaseStatusResponse struct { LatestProxiedRequestMetricPartitionTableName string `json:"latest_proxied_request_metric_partition_table_name"` // name of the latest created and currently attached partition for the proxied_request_metrics table TotalProxiedRequestMetricPartitions int64 `json:"total_proxied_request_metric_partitions"` // total number of attached partitions for the proxied_request_metrics table }
DatabaseStatusResponse wraps values returned by calls to /status/database
type ProxyService ¶
type ProxyService struct { Database *database.PostgresClient *logging.ServiceLogger // contains filtered or unexported fields }
ProxyService represents an instance of the proxy service API
func New ¶
func New(ctx context.Context, config config.Config, serviceLogger *logging.ServiceLogger) (ProxyService, error)
New returns a new ProxyService with the specified config and error (if any)
func (*ProxyService) Run ¶
func (p *ProxyService) Run() error
Run runs the proxy service, returning error (if any) in the event the proxy service stops
type ProxyServiceClient ¶
type ProxyServiceClient struct { *http.Client DebugLogResponses bool // contains filtered or unexported fields }
ProxyServiceClient provides a client for making requests and decoding responses to the proxy service API
func NewProxyServiceClient ¶
func NewProxyServiceClient(config ProxyServiceClientConfig) (*ProxyServiceClient, error)
NewProxyServiceClient creates a new ProxyServiceClient using the provided config, returning the client and error (if any)
func (*ProxyServiceClient) GetDatabaseStatus ¶
func (c *ProxyServiceClient) GetDatabaseStatus(ctx context.Context) (DatabaseStatusResponse, error)
GetDatabaseStatus calls `DatabaseStatusPath` to get metadata related to proxy service database operations such as proxied request metrics compaction and partitioning
type ProxyServiceClientConfig ¶
ProxyServiceClientConfig wraps values used to create a new ProxyServiceClient
type RequestError ¶
RequestError provides additional details about the failed request.
func (*RequestError) Error ¶
func (err *RequestError) Error() string
Error implements the error interface for RequestError.
type RequestInterceptor ¶
RequestInterceptors (a.k.a. 🦖🦖) are functions run by the proxy service to modify the original request sent by the caller or the response returned by the backend