v1

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// GRPCContentType is the MIME media type for grpc
	GRPCContentType = "application/grpc"
	// JSONContentType is the MIME media type for JSON
	JSONContentType = "application/json"
	// ProtobufContentType is the MIME media type for Protobuf
	ProtobufContentType = "application/x-protobuf"

	// ContentTypeHeader is the header key of content-type
	ContentTypeHeader = "content-type"
	// DaprHeaderPrefix is the prefix if metadata is defined by non user-defined http headers
	DaprHeaderPrefix = "dapr-"

	// DestinationIDHeader is the header carrying the value of the invoked app id
	DestinationIDHeader = "destination-app-id"
)
View Source
const (
	// DefaultAPIVersion is the default Dapr API version
	DefaultAPIVersion = internalv1pb.APIVersion_V1
)

Variables

This section is empty.

Functions

func CodeFromHTTPStatus

func CodeFromHTTPStatus(httpStatusCode int) codes.Code

CodeFromHTTPStatus converts http status code to gRPC status code See: https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md

func ErrorFromHTTPResponseCode added in v0.8.0

func ErrorFromHTTPResponseCode(code int, detail string) error

ErrorFromHTTPResponseCode converts http response code to gRPC status error

func ErrorFromInternalStatus added in v0.8.0

func ErrorFromInternalStatus(internalStatus *internalv1pb.Status) error

ErrorFromInternalStatus converts internal status to gRPC status error

func HTTPStatusFromCode

func HTTPStatusFromCode(code codes.Code) int

HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status. https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/errors.go#L15 See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto

func InternalMetadataToGrpcMetadata

func InternalMetadataToGrpcMetadata(ctx context.Context, internalMD DaprInternalMetadata, httpHeaderConversion bool) metadata.MD

InternalMetadataToGrpcMetadata converts internal metadata map to gRPC metadata

func InternalMetadataToHTTPHeader

func InternalMetadataToHTTPHeader(ctx context.Context, internalMD DaprInternalMetadata, setHeader func(string, string))

InternalMetadataToHTTPHeader converts internal metadata pb to HTTP headers

func IsGRPCProtocol

func IsGRPCProtocol(internalMD DaprInternalMetadata) bool

IsGRPCProtocol checks if metadata is originated from gRPC API

func IsJSONContentType

func IsJSONContentType(contentType string) bool

IsJSONContentType returns true if contentType is the mime media type for JSON

Types

type DaprInternalMetadata

type DaprInternalMetadata map[string]*internalv1pb.ListStringValue

DaprInternalMetadata is the metadata type to transfer HTTP header and gRPC metadata from user app to Dapr.

func MetadataToInternalMetadata added in v0.9.0

func MetadataToInternalMetadata(md map[string][]string) DaprInternalMetadata

MetadataToInternalMetadata converts metadata to dapr internal metadata map

type InvokeMethodRequest

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

InvokeMethodRequest holds InternalInvokeRequest protobuf message and provides the helpers to manage it.

func FromInvokeRequestMessage

func FromInvokeRequestMessage(pb *commonv1pb.InvokeRequest) *InvokeMethodRequest

FromInvokeRequestMessage creates InvokeMethodRequest object from InvokeRequest pb object

func InternalInvokeRequest

func InternalInvokeRequest(pb *internalv1pb.InternalInvokeRequest) (*InvokeMethodRequest, error)

InternalInvokeRequest creates InvokeMethodRequest object from InternalInvokeRequest pb object

func NewInvokeMethodRequest

func NewInvokeMethodRequest(method string) *InvokeMethodRequest

NewInvokeMethodRequest creates InvokeMethodRequest object for method

func (*InvokeMethodRequest) APIVersion

func (imr *InvokeMethodRequest) APIVersion() internalv1pb.APIVersion

APIVersion gets API version of InvokeMethodRequest

func (*InvokeMethodRequest) Actor

func (imr *InvokeMethodRequest) Actor() *internalv1pb.Actor

Actor returns actor type and id

func (*InvokeMethodRequest) EncodeHTTPQueryString

func (imr *InvokeMethodRequest) EncodeHTTPQueryString() string

EncodeHTTPQueryString generates querystring for http using http extension object

func (*InvokeMethodRequest) Message

Message gets InvokeRequest Message object

func (*InvokeMethodRequest) Metadata

func (imr *InvokeMethodRequest) Metadata() DaprInternalMetadata

Metadata gets Metadata of InvokeMethodRequest

func (*InvokeMethodRequest) Proto

Proto returns InternalInvokeRequest Proto object

func (*InvokeMethodRequest) RawData

func (imr *InvokeMethodRequest) RawData() (string, []byte)

RawData returns content_type and byte array body

func (*InvokeMethodRequest) WithActor

func (imr *InvokeMethodRequest) WithActor(actorType, actorID string) *InvokeMethodRequest

WithActor sets actor type and id

func (*InvokeMethodRequest) WithFastHTTPHeaders added in v0.9.0

func (imr *InvokeMethodRequest) WithFastHTTPHeaders(header *fasthttp.RequestHeader) *InvokeMethodRequest

WithFastHTTPHeaders sets fasthttp request headers

func (*InvokeMethodRequest) WithHTTPExtension

func (imr *InvokeMethodRequest) WithHTTPExtension(verb string, querystring string) *InvokeMethodRequest

WithHTTPExtension sets new HTTP extension with verb and querystring

func (*InvokeMethodRequest) WithMetadata

func (imr *InvokeMethodRequest) WithMetadata(md map[string][]string) *InvokeMethodRequest

WithMetadata sets metadata

func (*InvokeMethodRequest) WithRawData

func (imr *InvokeMethodRequest) WithRawData(data []byte, contentType string) *InvokeMethodRequest

WithRawData sets message data and content_type

type InvokeMethodResponse

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

InvokeMethodResponse holds InternalInvokeResponse protobuf message and provides the helpers to manage it.

func InternalInvokeResponse

func InternalInvokeResponse(resp *internalv1pb.InternalInvokeResponse) (*InvokeMethodResponse, error)

InternalInvokeResponse returns InvokeMethodResponse for InternalInvokeResponse pb to use the helpers

func NewInvokeMethodResponse

func NewInvokeMethodResponse(statusCode int32, statusMessage string, statusDetails []*any.Any) *InvokeMethodResponse

NewInvokeMethodResponse returns new InvokeMethodResponse object with status

func (*InvokeMethodResponse) Headers

Headers gets Headers metadata

func (*InvokeMethodResponse) IsHTTPResponse

func (imr *InvokeMethodResponse) IsHTTPResponse() bool

IsHTTPResponse returns true if response status code is http response status

func (*InvokeMethodResponse) Message

Message returns message field in InvokeMethodResponse

func (*InvokeMethodResponse) Proto

Proto clones the internal InvokeMethodResponse pb object

func (*InvokeMethodResponse) RawData

func (imr *InvokeMethodResponse) RawData() (string, []byte)

RawData returns content_type and byte array body

func (*InvokeMethodResponse) Status

func (imr *InvokeMethodResponse) Status() *internalv1pb.Status

Status gets Response status

func (*InvokeMethodResponse) Trailers

Trailers gets Trailers metadata

func (*InvokeMethodResponse) WithFastHTTPHeaders

func (imr *InvokeMethodResponse) WithFastHTTPHeaders(header *fasthttp.ResponseHeader) *InvokeMethodResponse

WithFastHTTPHeaders populates fasthttp response header to gRPC header metadata

func (*InvokeMethodResponse) WithHeaders

func (imr *InvokeMethodResponse) WithHeaders(headers metadata.MD) *InvokeMethodResponse

WithHeaders sets gRPC response header metadata

func (*InvokeMethodResponse) WithMessage

WithMessage sets InvokeResponse pb object to Message field

func (*InvokeMethodResponse) WithRawData

func (imr *InvokeMethodResponse) WithRawData(data []byte, contentType string) *InvokeMethodResponse

WithRawData sets Message using byte data and content type

func (*InvokeMethodResponse) WithTrailers

func (imr *InvokeMethodResponse) WithTrailers(trailer metadata.MD) *InvokeMethodResponse

WithTrailers sets Trailer in internal InvokeMethodResponse

Jump to

Keyboard shortcuts

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