-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue #227 #267
Fix issue #227 #267
Conversation
@@ -80,7 +80,24 @@ public abstract class APIGatewayProxyFunction | |||
/// <summary> | |||
/// Default constructor that AWS Lambda will invoke. | |||
/// </summary> | |||
protected APIGatewayProxyFunction() | |||
protected APIGatewayProxyFunction(bool delayStart = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change this to autoStart, and set default to true. That way, you can check using the affirmative case.
if(autoStart)
{
Start();
}
protected APIGatewayProxyFunction(bool delayStart = false) | ||
{ | ||
if (!delayStart) | ||
Start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap if bodies with {}, unless it is an exception or a return
} | ||
|
||
/// <summary> | ||
/// Should be called in the derrived constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling - derived
@@ -173,6 +190,9 @@ protected virtual IWebHostBuilder CreateWebHostBuilder() | |||
{ | |||
lambdaContext.Logger.LogLine($"Incoming {request.HttpMethod} requests to {request.Path}"); | |||
|
|||
if (!IsStarted) | |||
Start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if statement body needs { }
@@ -173,6 +190,9 @@ protected virtual IWebHostBuilder CreateWebHostBuilder() | |||
{ | |||
lambdaContext.Logger.LogLine($"Incoming {request.HttpMethod} requests to {request.Path}"); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing an invocation to a new virtual method that you could override to set the environment variables.
-
You need a new virtual PreStart method that takes in the ILambdaContext. I wouldn't pass in the request since this method would only be invoked the on the first request, and we want to prevent misuse of this method.
-
You need to call this method in the !IsStarted if statement. Since this method will only be useful for altering the properties of the environment before the service starts, we should isolate this call so it doesn't cause inadvertent side effects.
For what you need a new virtual PreStart method, for me it makes no sense. I use this fix with the following class:
Now I can set the environment. @costleya: Or should I add this modifications to the base class? And than I use this such as (I know it's only a workaround):
The concrete LambdaEntryPoint looks like the following:
|
Is the main point of this pull request to get the environment name in so you can find the SSM parameter store variables for the environment? If so that seems like an important use case for us to handle and I'm wondering if we have made it too hard to do that. Also I just discovered you can find the lambda function name during the constructor phase by checking the environment variable |
Thats the problem, but I need the aliase name (e.g. |
Status update. I have merged this into the dev branch to go out with the next release. |
Version 2.0.4 was released with this pull request. I made a slight tweak to use an enum instead of a boolean in the constructor to make it more clear and give us room to make changes in the future. |
Issue #227
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.