@@ -28,37 +28,39 @@ enum ControlPlaneResponse: Hashable {
2828 case error( ErrorResponse )
2929}
3030
31- package struct InvocationMetadata : Hashable {
32- package let requestID : String
33- package let deadlineInMillisSinceEpoch : Int64
34- package let invokedFunctionARN : String
35- package let traceID : String
36- package let clientContext : String ?
37- package let cognitoIdentity : String ?
31+ package
32+ struct InvocationMetadata : Hashable {
33+ package let requestID : String
34+ package let deadlineInMillisSinceEpoch : Int64
35+ package let invokedFunctionARN : String
36+ package let traceID : String
37+ package let clientContext : String ?
38+ package let cognitoIdentity : String ?
3839
39- package init ( headers: HTTPHeaders ) throws ( LambdaRuntimeError) {
40- guard let requestID = headers. first ( name: AmazonHeaders . requestID) , !requestID. isEmpty else {
41- throw LambdaRuntimeError ( code: . nextInvocationMissingHeaderRequestID)
42- }
43-
44- guard let deadline = headers. first ( name: AmazonHeaders . deadline) ,
45- let unixTimeInMilliseconds = Int64 ( deadline)
46- else {
47- throw LambdaRuntimeError ( code: . nextInvocationMissingHeaderDeadline)
48- }
40+ package init ( headers: HTTPHeaders ) throws
41+ ( LambdaRuntimeError) {
42+ guard let requestID = headers. first ( name: AmazonHeaders . requestID) , !requestID. isEmpty else {
43+ throw LambdaRuntimeError ( code: . nextInvocationMissingHeaderRequestID)
44+ }
4945
50- guard let invokedFunctionARN = headers. first ( name: AmazonHeaders . invokedFunctionARN) else {
51- throw LambdaRuntimeError ( code: . nextInvocationMissingHeaderInvokeFuctionARN)
52- }
46+ guard let deadline = headers. first ( name: AmazonHeaders . deadline) ,
47+ let unixTimeInMilliseconds = Int64 ( deadline)
48+ else {
49+ throw LambdaRuntimeError ( code: . nextInvocationMissingHeaderDeadline)
50+ }
5351
54- self . requestID = requestID
55- self . deadlineInMillisSinceEpoch = unixTimeInMilliseconds
56- self . invokedFunctionARN = invokedFunctionARN
57- self . traceID =
58- headers. first ( name: AmazonHeaders . traceID) ?? " Root= \( AmazonHeaders . generateXRayTraceID ( ) ) ;Sampled=0 "
59- self . clientContext = headers [ " Lambda-Runtime-Client-Context " ] . first
60- self . cognitoIdentity = headers [ " Lambda-Runtime-Cognito-Identity " ] . first
52+ guard let invokedFunctionARN = headers. first ( name: AmazonHeaders . invokedFunctionARN) else {
53+ throw LambdaRuntimeError ( code: . nextInvocationMissingHeaderInvokeFuctionARN)
6154 }
55+
56+ self . requestID = requestID
57+ self . deadlineInMillisSinceEpoch = unixTimeInMilliseconds
58+ self . invokedFunctionARN = invokedFunctionARN
59+ self . traceID =
60+ headers. first ( name: AmazonHeaders . traceID) ?? " Root= \( AmazonHeaders . generateXRayTraceID ( ) ) ;Sampled=0 "
61+ self . clientContext = headers [ " Lambda-Runtime-Client-Context " ] . first
62+ self . cognitoIdentity = headers [ " Lambda-Runtime-Cognito-Identity " ] . first
63+ }
6264}
6365
6466struct ErrorResponse : Hashable , Codable {
0 commit comments