Documentation
¶
Index ¶
- Variables
- func Convert[T any, R any](slice []T, f func(in T) R) []R
- func MarshalMetadata(md metadata.MD) (*structpb.Struct, error)
- func MetadataForRequest(req *Request) metadata.MD
- func NewClientConn(transport ClientTransport) grpc.ClientConnInterface
- func PeerForRequest(req *Request) *peer.Peer
- func TimeoutForRequest(req *Request) (time.Duration, bool, error)
- func UnmarshalMetadata(s *structpb.Struct) metadata.MD
- type ClientTransport
- type Request
- type Response
- type Server
- type TransportStream
- func (r *TransportStream) Method() string
- func (r *TransportStream) Response() (*Response, error)
- func (r *TransportStream) SendHeader(md metadata.MD) error
- func (r *TransportStream) SetHeader(md metadata.MD) error
- func (r *TransportStream) SetResponse(resp any) error
- func (r *TransportStream) SetStatus(st *status.Status)
- func (r *TransportStream) SetTrailer(md metadata.MD) error
Constants ¶
This section is empty.
Variables ¶
var ErrIllegalHeaderWrite = status.Errorf(codes.Internal, "transport: SetHeader/SetTrailer called after headers were sent")
var ErrIllegalSendHeader = status.Errorf(codes.Internal, "transport: SendHeader called multiple times")
Functions ¶
func MetadataForRequest ¶
func NewClientConn ¶ added in v0.2.76
func NewClientConn(transport ClientTransport) grpc.ClientConnInterface
func PeerForRequest ¶
TODO(morgabra): The transport impl has to give this to us I suppose.
Types ¶
type ClientTransport ¶
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 (*Request) MarshalJSON ¶
MarshalJSON dual-encodes the request: the legacy protojson fields and the v2 wire frame share one JSON object, so legacy connectors keep working (they discard the unknown frame fields) while v2 connectors decode the frame and see annotations whose types this process cannot resolve. When no legacy view can be produced — protojson cannot represent an Any whose type is not linked into this process — the frame is sent alone: a legacy connector would have failed on that payload anyway. Oversized dual payloads fall back to legacy-only to stay under the Lambda invoke limit; v2 connectors accept those too.
func (*Request) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON into a Request. v2 wire frames decode losslessly; legacy payloads are protojson, discarding unknown fields and filtering annotations with unresolvable types. See unmarshalTransportJSON.
func (*Request) UnmarshalRequest ¶
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func ErrorResponse ¶
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. Non-status errors are mapped through Baton lambda's application error classification before falling back to codes.Unknown.
func (*Response) MarshalJSON ¶
MarshalJSON encodes a v2 wire frame when the invoker proved it reads them (see wireV2), preserving annotations whose types this process cannot resolve. Legacy invokers get plain protojson, which fails on an Any whose type is not linked into this process — deliberately: the sender's registry is no authority on what the receiver understands or needs, so degrading the payload by silently dropping data is worse than failing loudly.
func (*Response) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON into a Response. v2 wire frames decode losslessly with no type resolution. Legacy payloads are protojson, discarding unknown fields and filtering annotations with unresolvable types: responses carry annotations at the response level and nested inside rows (grants embed resources, etc.), so this protects an invoker from annotation types it does not know about — for example an older invoker receiving annotations from a connector built with a newer SDK. See unmarshalTransportJSON.
func (*Response) UnmarshalResponse ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(unaryInterceptor grpc.UnaryServerInterceptor, ) *Server
func (*Server) Handler ¶
Handler serves one transport request. The response echoes the request's wire version so v2 invokers get lossless frames and legacy invokers get protojson (see Response.MarshalJSON).
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.
func (*Server) ReplaceServiceImplementation ¶ added in v0.8.30
func (s *Server) ReplaceServiceImplementation(oldImpl any, newImpl any) (int, <-chan struct{}, error)
ReplaceServiceImplementation swaps all services currently registered with oldImpl to newImpl and returns a channel that closes when requests using oldImpl have drained. It is intended for lambda connector generation reloads where the service descriptors stay fixed but connector-owned state must be discarded wholesale.
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) 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