Documentation ¶
Index ¶
- Variables
- func WriteBodyLine(out io.StringWriter, requestID int, line string)
- func WriteError(out io.StringWriter, requestID int, err error)
- type Client
- type Field
- func (f Field) String() string
- func (f Field) Write(out io.StringWriter, value string)
- func (f Field) WriteForRequest(out io.StringWriter, requestID int, value string)
- func (f Field) WriteKeyValue(out io.StringWriter, key, value string)
- func (f Field) WriteKeyValueForRequest(out io.StringWriter, requestID int, key, value string)
- func (f Field) WriteNonEmpty(out io.StringWriter, value string)
- type HeaderType
- type Response
- type Responses
Constants ¶
This section is empty.
Variables ¶
var ( URLFieldRegex = regexp.MustCompile(string(URLField) + "=(.*)") ClusterFieldRegex = regexp.MustCompile(string(ClusterField) + "=(.*)") IstioVersionFieldRegex = regexp.MustCompile(string(IstioVersionField) + "=(.*)") IPFieldRegex = regexp.MustCompile(string(IPField) + "=(.*)") SourceIPFieldRegex = regexp.MustCompile(string(SourceIPField) + "=(.*)") )
var GlobalEchoRequests = atomic.NewUint64(0)
GlobalEchoRequests records how many echo calls we have made total, from all sources. Note: go tests are distinct binaries per test suite, so this is the suite level number of calls
Functions ¶
func WriteBodyLine ¶
func WriteBodyLine(out io.StringWriter, requestID int, line string)
func WriteError ¶
func WriteError(out io.StringWriter, requestID int, err error)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client of an Echo server that simplifies request/response processing for Forward commands.
func New ¶
func New(address string, tlsSettings *common.TLSSettings, extraDialOpts ...grpc.DialOption) (*Client, error)
New creates a new echo client.Instance that is connected to the given server address.
func (*Client) ForwardEcho ¶
func (c *Client) ForwardEcho(ctx context.Context, request *proto.ForwardEchoRequest) (Responses, error)
ForwardEcho sends the given forward request and parses the response for easier processing. Only fails if the request fails.
type Field ¶
type Field string
Field is a list of fields returned in responses from the Echo server.
const ( RequestIDField Field = "X-Request-Id" ServiceVersionField Field = "ServiceVersion" ServicePortField Field = "ServicePort" StatusCodeField Field = "StatusCode" URLField Field = "URL" ForwarderURLField Field = "Url" ForwarderMessageField Field = "Echo" ForwarderHeaderField Field = "Header" HostField Field = "Host" HostnameField Field = "Hostname" NamespaceField Field = "Namespace" MethodField Field = "Method" ProtocolField Field = "Proto" ProxyProtocolField Field = "ProxyProtocol" AlpnField Field = "Alpn" RequestHeaderField Field = "RequestHeader" ResponseHeaderField Field = "ResponseHeader" ClusterField Field = "Cluster" IstioVersionField Field = "IstioVersion" IPField Field = "IP" // The Requester’s IP Address, as reported from the destination SourceIPField Field = "SourceIP" // The Requester’s IP Address, as reported from the source. LatencyField Field = "Latency" ActiveRequestsField Field = "ActiveRequests" DNSProtocolField Field = "Protocol" DNSQueryField Field = "Query" DNSServerField Field = "DnsServer" CipherField Field = "Cipher" TLSVersionField Field = "Version" TLSServerName Field = "ServerName" )
func (Field) WriteForRequest ¶
func (f Field) WriteForRequest(out io.StringWriter, requestID int, value string)
func (Field) WriteKeyValue ¶
func (f Field) WriteKeyValue(out io.StringWriter, key, value string)
func (Field) WriteKeyValueForRequest ¶
func (f Field) WriteKeyValueForRequest(out io.StringWriter, requestID int, key, value string)
func (Field) WriteNonEmpty ¶
func (f Field) WriteNonEmpty(out io.StringWriter, value string)
type HeaderType ¶
type HeaderType string
HeaderType is a helper enum for retrieving Headers from a Response.
const ( RequestHeader HeaderType = "request" ResponseHeader HeaderType = "response" )
type Response ¶
type Response struct { // RequestURL is the requested URL. This differs from URL, which is the just the path. // For example, RequestURL=http://foo/bar, URL=/bar RequestURL string // Method used (for HTTP). Method string // Protocol used for the request. Protocol string // Alpn value (for HTTP). Alpn string // ProxyProtocol value. ProxyProtocol string // RawContent is the original unparsed content for this response RawContent string // ID is a unique identifier of the resource in the response ID string // URL is the url the request is sent to URL string // Version is the version of the resource in the response Version string // Port is the port of the resource in the response Port string // Code is the response code Code string // Host is the host called by the request Host string // Hostname is the host that responded to the request Hostname string // The cluster where the server is deployed. Cluster string // IstioVersion for the Istio sidecar. IstioVersion string // IP is the client IP, as seen by the server. IP string // SourceIP is the client's source IP. This can differ from IP when there are multiple hops. SourceIP string // RawBody gives a map of all key/values in the body of the response. RawBody map[string]string RequestHeaders http.Header ResponseHeaders http.Header }
Response represents a response to a single echo request.
func (Response) GetHeaders ¶
func (r Response) GetHeaders(hType HeaderType) http.Header
GetHeaders returns the appropriate headers for the given type.
type Responses ¶
type Responses []Response
Responses is an ordered list of parsed response objects.
func ParseResponses ¶
func ParseResponses(req *proto.ForwardEchoRequest, resp *proto.ForwardEchoResponse) Responses