grpc

package
v0.6.16 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIllegalHeaderWrite = status.Errorf(codes.Internal, "transport: SetHeader/SetTrailer called after headers were sent")
View Source
var ErrIllegalSendHeader = status.Errorf(codes.Internal, "transport: SendHeader called multiple times")

Functions

func Convert

func Convert[T any, R any](slice []T, f func(in T) R) []R

Convert accepts a list of T and returns a list of R based on the input func.

func MarshalMetadata

func MarshalMetadata(md metadata.MD) (*structpb.Struct, error)

func MetadataForRequest

func MetadataForRequest(req *Request) metadata.MD

func NewClientConn added in v0.2.76

func NewClientConn(transport ClientTransport) grpc.ClientConnInterface

func PeerForRequest

func PeerForRequest(req *Request) *peer.Peer

TODO(morgabra): The transport impl has to give this to us I suppose.

func TimeoutForRequest

func TimeoutForRequest(req *Request) (time.Duration, bool, error)

func UnmarshalMetadata

func UnmarshalMetadata(s *structpb.Struct) metadata.MD

UnmarshalMetadata converts a *structpb.Struct to a metadata.MD. Only keys with []string values are converted. Empty string values are ignored.

Types

type ClientTransport

type ClientTransport interface {
	RoundTrip(context.Context, *Request) (*Response, error)
}

func NewLambdaClientTransport added in v0.2.76

func NewLambdaClientTransport(ctx context.Context, client *lambda.Client, functionName string) (ClientTransport, error)

NewLambdaClientTransport returns a new client transport that invokes a lambda function.

type Request

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

func NewRequest

func NewRequest(method string, req proto.Message, headers metadata.MD) (*Request, error)

func (*Request) Headers

func (f *Request) Headers() metadata.MD

func (*Request) MarshalJSON

func (f *Request) MarshalJSON() ([]byte, error)

func (*Request) Method

func (f *Request) Method() string

func (*Request) UnmarshalJSON

func (f *Request) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON into a Request, discarding any unknown fields.

It also filters out any annotations that are not known to the global registry which happens frequently for new features and would otherwise require rolling every lambda function.

Our requests are small in size, dwarfed by the work of the connector, so the performance impact is negligible.

func (*Request) UnmarshalRequest

func (f *Request) UnmarshalRequest(req any) error

type Response

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

func ErrorResponse

func ErrorResponse(err error) *Response

ErrorResponse converts a given error to a status.Status and returns a *pbtransport.Response. status.FromError(err) must unwrap a status.Status for this to work - all other errors are converted to grpc codes.Unknown errors.

func (*Response) Headers

func (f *Response) Headers() metadata.MD

func (*Response) MarshalJSON

func (f *Response) MarshalJSON() ([]byte, error)

func (*Response) Status

func (f *Response) Status() (*status.Status, error)

func (*Response) Trailers

func (f *Response) Trailers() metadata.MD

func (*Response) UnmarshalJSON

func (f *Response) UnmarshalJSON(b []byte) error

func (*Response) UnmarshalResponse

func (f *Response) UnmarshalResponse(resp any) error

type Server

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

func NewServer

func NewServer(unaryInterceptor grpc.UnaryServerInterceptor,
) *Server

func (*Server) Handler

func (s *Server) Handler(ctx context.Context, req *Request) (*Response, error)

func (*Server) RegisterService

func (s *Server) RegisterService(sd *grpc.ServiceDesc, ss any)

RegisterService registers a service and its implementation to the gRPC server. This is lifted from grpc.Server.

type TransportStream

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

func NewTransportStream

func NewTransportStream(method *grpc.MethodDesc) *TransportStream

func (*TransportStream) Method

func (r *TransportStream) Method() string

func (*TransportStream) Response

func (r *TransportStream) Response() (*Response, error)

func (*TransportStream) SendHeader

func (r *TransportStream) SendHeader(md metadata.MD) error

func (*TransportStream) SetHeader

func (r *TransportStream) SetHeader(md metadata.MD) error

func (*TransportStream) SetResponse

func (r *TransportStream) SetResponse(resp any) error

func (*TransportStream) SetStatus

func (r *TransportStream) SetStatus(st *status.Status)

func (*TransportStream) SetTrailer

func (r *TransportStream) SetTrailer(md metadata.MD) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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