Documentation ¶
Index ¶
- Constants
- Variables
- func AnnotateContext(ctx context.Context, req *http.Request) (context.Context, context.CancelFunc, error)
- func DefaultHttpClient() *http.Client
- func HttpError(span trace.Span, w http.ResponseWriter, req *http.Request, err error)
- func NewHttpClient(opts ...HttpClientOption) *http.Client
- func NewRPCServer(service *Service) *server
- func SanitizeUrl(addr string) string
- type Client
- type ClientPlugin
- type HTTPClient
- type HttpClientOption
- type Method
- type Service
Constants ¶
const ( ContentTypeProtobuf = "application/protobuf" ContentTypeOctetProtobuf = "application/octet-stream" ContentTypeGrpcProtobuf = "application/grpc+proto" ContentTypeJson = "application/json" )
Variables ¶
var ( DefaultHttpTimeout = 30 * time.Second DefaultIdleConnTimeout = 30 * time.Second DefaultTLSHandshakeTimeout = 10 * time.Second )
var ( // DefaultContextTimeout is used for gRPC call context.WithTimeout whenever a Grpc-Timeout inbound // header isn't present. If the value is 0 the sent `context` will not have a timeout. DefaultContextTimeout = 0 * time.Second )
Functions ¶
func AnnotateContext ¶
func AnnotateContext(ctx context.Context, req *http.Request) (context.Context, context.CancelFunc, error)
AnnotateContext adds context information such as metadata from the request. It is designed to work similar to the gRPC AnnotateContext function. At a minimum, the RemoteAddr is included in the fashion of "X-Forwarded-For" in the metadata.
The implementation is derived from GRPC-Gateway AnnotateContext (BSD3-License). See: https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/context.go#L78
func DefaultHttpClient ¶ added in v0.3.0
DefaultHttpClient will set up a basic client with default timeouts/proxies/etc.
func NewHttpClient ¶ added in v0.5.1
func NewHttpClient(opts ...HttpClientOption) *http.Client
func NewRPCServer ¶
func NewRPCServer(service *Service) *server
NewServer creates a new server. This function is used by the protoc-gen-rangerrpc generated code and should not be used directly.
func SanitizeUrl ¶
SanitizeUrl parses the given url and returns a sanitized url. If no scheme is given, it will be set to https.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client for the Ranger service. It is used as the base client for all service calls.
func (*Client) AddPlugin ¶ added in v0.2.0
func (c *Client) AddPlugin(plugin ClientPlugin)
AddPlugin adds a client plugin. Deprecated: use AddPlugins instead.
func (*Client) AddPlugins ¶ added in v0.4.0
func (c *Client) AddPlugins(plugins ...ClientPlugin)
AddPlugins adds one or many client plugins.
func (*Client) DoClientRequest ¶
func (c *Client) DoClientRequest(ctx context.Context, client HTTPClient, url string, in, out proto.Message) (err error)
DoClientRequest makes a request to the Ranger service. It will marshal the proto.Message into the request body, do the request and then parse the response into the response proto.Message.
type ClientPlugin ¶ added in v0.2.0
ClientPlugin is a plugin that can be used to modify the http headers of a request.
type HttpClientOption ¶ added in v0.5.1
func WithProxy ¶ added in v0.5.1
func WithProxy(proxy *url.URL) HttpClientOption
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package codes defines the canonical error codes used by gRPC.
|
Package codes defines the canonical error codes used by gRPC. |
examples
|
|
internal
|
|
status
Package status implements errors returned by gRPC.
|
Package status implements errors returned by gRPC. |
Package metadata define the structure of the metadata supported by gRPC library.
|
Package metadata define the structure of the metadata supported by gRPC library. |
plugins
|
|
Package status implements errors returned by gRPC.
|
Package status implements errors returned by gRPC. |