Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a77abb1
Fixed typo for UNHANDLED error constant
sapessi Dec 2, 2018
36bcc8f
Removed RuntimeApiError trait form the client and changed it to recei…
sapessi Dec 3, 2018
f53bd30
Changed HandlerError type to alias Box<dyn Error> to allow the runtim…
sapessi Dec 3, 2018
8b6d8fc
Added custom error examples and updated existing examples
sapessi Dec 3, 2018
2e034d2
Fixed failure example
sapessi Dec 3, 2018
4f20464
Updated comment on HandlerError type
sapessi Dec 3, 2018
d17b7c8
Exported HandlerError in root of the crate
sapessi Dec 3, 2018
08772e9
Added error code to response structure and centralized backtrace gene…
sapessi Dec 3, 2018
a6d2c5b
Updated example in lib docs
sapessi Dec 3, 2018
fee02e8
Temporary fix for failure example
sapessi Dec 3, 2018
4969624
Switched to HandlerError struct that can be created from any Display …
sapessi Dec 4, 2018
0bce533
Addressed code review changes
sapessi Dec 4, 2018
bd3cb34
Changed error handling codes according to latest specs clarified in #23
sapessi Dec 4, 2018
5b9bad9
Removed custom_attribute feature to fix build
sapessi Dec 4, 2018
9ed9a43
Cleaned up lifetimes/borrows
sapessi Dec 27, 2018
7fa1167
New runtime core crate that implements the runtime main loop and defi…
sapessi Dec 27, 2018
5165242
Slimmed down runtime crate that only wraps the runtime core crate
sapessi Dec 27, 2018
3bcb150
Rebased on master
sapessi Dec 27, 2018
ab54a2e
Moved HandlerError to error module for backward compatibility
sapessi Dec 27, 2018
99b1328
Fixed error package in examples
sapessi Dec 28, 2018
3844b43
Addressing CR on newline at the end of file and import grouping
sapessi Dec 28, 2018
fa2a5b1
More style changes from code review
sapessi Dec 28, 2018
b6423f7
Fixed tests, including http crate
sapessi Dec 28, 2018
77459b5
First refactor of errors in the client crate and new errors crate
sapessi Dec 28, 2018
ecbae1c
Bump dependencies
sapessi Jan 4, 2019
6896b1b
New derive crate (experimental) for LambdaErrorExt and new HandlerErr…
sapessi Jan 4, 2019
3f79fcb
Switched back to ApiError and added new is_recoverable() method
sapessi Jan 4, 2019
1b1e624
Parametrized error type and updated examples
sapessi Jan 4, 2019
7de9169
Switched to more descriptive generic names
sapessi Jan 4, 2019
b991438
Added a new LambdaResultExt to simplify error handling in handlers
sapessi Jan 4, 2019
bedbf92
Added build script to generate the metadata file
sapessi Jan 4, 2019
e3f6b34
Changed the runtime client SDK to receive a user-agent as init param.…
sapessi Jan 5, 2019
253a481
Fixed format of build.rs
sapessi Jan 7, 2019
db7f994
Fixed critical issue in runtime client - request URIs were not genera…
sapessi Jan 10, 2019
f0de223
Fixed code issue - committed to fast earlier
sapessi Jan 10, 2019
d705def
New error tests and failure featurs in Cargo. Still cannot get a back…
sapessi Jan 21, 2019
a3aaedb
failure features import
sapessi Jan 21, 2019
fd35180
Added doc comment on lambda! macro
sapessi Jan 21, 2019
8827cdb
merge latest master changes
sapessi Jan 21, 2019
32cd6e0
Fixed failure dep in Cargo (CR feedback)
sapessi Jan 21, 2019
0f54490
Removed unnecesary test (CR feedback)
sapessi Jan 21, 2019
bb61d71
Another round of CR feedback
sapessi Jan 22, 2019
6891eaa
Added comment to error header as per CR
sapessi Jan 24, 2019
ee12d37
Changed order of deps while cleaning up
sapessi Jan 24, 2019
315c979
Removed commented code as per CR
sapessi Jan 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed critical issue in runtime client - request URIs were not genera…
…ted correctly
  • Loading branch information
sapessi committed Jan 10, 2019
commit db7f9943ca482c9421afbf82e4e2b71820ece6dd
31 changes: 25 additions & 6 deletions lambda-runtime-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ pub struct EventContext {
pub struct RuntimeClient {
_runtime: Runtime,
http_client: Client<HttpConnector, Body>,
endpoint: Uri,
next_endpoint: Uri,
runtime_agent: String,
host: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the addition of host and change from endpoint to next_endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next_endpoint is the pre-parsed uri for the /next endpoint, which remains stable throughout the lifetime of the client. The host is used to re-generate the Uri for the response endpoints for each request. I'm caching the next_endpoint Uri value to avoid parsing it each time.

}

impl<'ev> RuntimeClient {
Expand All @@ -150,15 +151,17 @@ impl<'ev> RuntimeClient {
};

let http_client = Client::builder().executor(runtime.executor()).build_http();
let endpoint = format!("http://{}/{}/runtime/invocation/next", host, RUNTIME_API_VERSION)
// we cached the parsed Uri since this never changes.
let next_endpoint = format!("http://{}/{}/runtime/invocation/next", host, RUNTIME_API_VERSION)
.parse::<Uri>()
.context(ApiErrorKind::Unrecoverable("Could not parse API uri".to_string()))?;

Ok(RuntimeClient {
_runtime: runtime,
http_client,
endpoint,
next_endpoint,
runtime_agent,
host: host.to_owned(),
})
}
}
Expand All @@ -173,7 +176,7 @@ impl<'ev> RuntimeClient {
// the additional complexity.
let resp = self
.http_client
.get(self.endpoint.clone())
.get(self.next_endpoint.clone())
.wait()
.context(ApiErrorKind::Unrecoverable("Could not fetch next event".to_string()))?;

Expand Down Expand Up @@ -230,7 +233,15 @@ impl<'ev> RuntimeClient {
request_id,
output.len()
);
let req = self.get_runtime_post_request(&self.endpoint, output);
let uri = format!(
"http://{}/{}/runtime/invocation/{}/response",
self.host, RUNTIME_API_VERSION, request_id
)
.parse::<Uri>()
.context(ApiErrorKind::Unrecoverable(
"Could not generate response uri".to_owned(),
))?;
let req = self.get_runtime_post_request(&uri, output);

let resp = self
.http_client
Expand Down Expand Up @@ -270,7 +281,15 @@ impl<'ev> RuntimeClient {
request_id,
e.error_message
);
let req = self.get_runtime_error_request(&self.endpoint, &e);
let uri = format!(
"http://{}/{}/runtime/invocation/{}/error",
self.host, RUNTIME_API_VERSION, request_id
)
.parse::<Uri>()
.context(ApiErrorKind::Unrecoverable(
"Could not generate response uri".to_owned(),
))?;
let req = self.get_runtime_error_request(&uri, &e);

let resp = self.http_client.request(req).wait().context(ApiErrorKind::Recoverable(
"Could not post event error response".to_string(),
Expand Down