grpc

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//SchemaHTTP represents the http schema
	SchemaHTTP = "http"
	//SchemaHTTPS represents the https schema
	SchemaHTTPS = "https"
)
View Source
const (
	XForwardedPort = "X-Forwarded-Port"
	XForwardedHost = "X-Forwarded-Host"
)

constants for headers

View Source
const (
	Name = "grpc"
)

Variables

View Source
var (
	ErrInvalidResp = errors.New("rest consumer response arg is not *http.Response type")
	//ErrCanceled means Request is canceled by context management
	ErrCanceled = errors.New("request cancelled")
)

ErrInvalidResp invalid input

View Source
var (
	//ErrRestFaultAbort is a variable of type error
	ErrRestFaultAbort = errors.New("injecting abort")
	//ErrRestFault is a variable of type error
	ErrRestFault = errors.New("injecting abort and delay")
	//ErrNilResponse is a variable of type error
	ErrNilResponse = errors.New("http response is nil")
)

Functions

func LocalRequestHandler

func LocalRequestHandler(w http.ResponseWriter, r *http.Request)

LocalRequestHandler is for request from local

func NewClient

func NewClient(opts client.Options) (client.ProtocolClient, error)

NewClient return a new client of grpc

func RecordStatus

func RecordStatus(inv *invocation.Invocation, statusCode int)

RecordStatus record an operation status

func RemoteRequestHandler

func RemoteRequestHandler(w http.ResponseWriter, r *http.Request)

RemoteRequestHandler is for request from remote

func WriteErrorResponse

func WriteErrorResponse(inv *invocation.Invocation, w http.ResponseWriter, r *http.Request, statusCode int, err error)

WriteErrorResponse return proxy errors, not err from real service

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a grpc client

func (*Client) Call

func (c *Client) Call(ctx context.Context, addr string, inv *invocation.Invocation, rsp interface{}) error

Call is a method which uses grpc protocol to transfer invocation

func (*Client) Close

func (c *Client) Close() error

Close close the conn

func (*Client) GetOptions

func (c *Client) GetOptions() client.Options

GetOptions return opts

func (*Client) ReloadConfigs

func (c *Client) ReloadConfigs(opts client.Options)

ReloadConfigs reload config

func (*Client) String

func (c *Client) String() string

String return name

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL