Skip to content

Refactor code base to remove dependency on 'Microsoft.Extensions.Logging' and merge 'Function' with 'FunctionInfo' #22

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

Merged
merged 3 commits into from
Aug 31, 2018

Conversation

daxian-dbw
Copy link
Contributor

@daxian-dbw daxian-dbw commented Aug 31, 2018

Refactor the code base to remove the dependency on Microsoft.Extensions.Logging and merge Function with FunctionInfo.

  • Since we don't pass the logger to the user, it doesn't need to implement ILogger. Removing this dependency reduce 8 assemblies from the publish folder.
  • The type Function is not really needed, so merge it to FunctionInfo.
  • Make Params, Headers and Query in HttpRequestContext case insensitive. So $req.Query.Name works for ?name=Joe.

Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

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

Looks good. Just one small suggestion.

}

var scriptPath = functionInfo.ScriptPath;
var entryPoint = functionInfo.EntryPoint;
Copy link
Member

Choose a reason for hiding this comment

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

nit: scriptPath and entryPoint are only used once. Maybe just change the InvokeFunction call to:

                 result = _powerShellManager.InvokeFunction(
                        functionInfo.ScriptPath,
                        functionInfo.EntryPoint,
                        triggerMetadata,
                        invocationRequest.InputData);

@@ -150,12 +136,38 @@ internal StreamingMessage ProcessInvocationRequest(StreamingMessage request)
}
};

// Load information about the function
var functionInfo = _functionLoader.GetFunctionInfo(invocationRequest.FunctionId);
if (functionInfo == null)
Copy link
Member

Choose a reason for hiding this comment

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

I think it would make more sense if this would throw an exception rather than returning null if it couldn't find the function.

Then we can include the exception in the status that is sent back.

@@ -165,21 +177,22 @@ internal StreamingMessage ProcessInvocationRequest(StreamingMessage request)
}

// Set out binding data and return response to be sent back to host
foreach (KeyValuePair<string, BindingInfo> binding in functionInfo.OutputBindings)
foreach (KeyValuePair<string, BindingInfo> binding in functionInfo.OutBindings)
Copy link
Member

Choose a reason for hiding this comment

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

this change reminds me that we should be consistent in our wording. I've seen the use of out bindings and output bindings. Our code should be consistent.

Anyway, you don't need to address this in your PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I searched the code base, the generated protocol code has mixed uses of out binding and output binding. In our code, we uses outputbinding in the helper module, while outbinding in worker. I guess outbinding is the offcial AzF term. Maybe we change the function name to push-outbinding?

Copy link
Member

Choose a reason for hiding this comment

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

@asavaritayal can you comment on this?

Would it make more sense in the AzF world to call everything:

outputbinding or outbinding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AzF documents use input and output bindings.

Copy link
Member

Choose a reason for hiding this comment

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

I see. We should change funnctionInfo.OutBinding tofunctionInfo.OutputBinding then, I think.

Copy link
Contributor Author

@daxian-dbw daxian-dbw Aug 31, 2018

Choose a reason for hiding this comment

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

Will make the change. Done.

@daxian-dbw
Copy link
Contributor Author

I have tested the worker locally. All xunit tests passed.

Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

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

LGTM just one small nit

@@ -4,15 +4,26 @@
//

using System;
using System.Collections.Generic;
using Google.Protobuf.Collections;
Copy link
Member

Choose a reason for hiding this comment

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

nit: we shouldn't need this using anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need it for the use of Dictionary<string, string> in HttpRequestContext. MapField<string, string> is case sensitive, we need case insensitive for powershell, so $req.Query.Name works for ?name=Joe.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I know. I meant remove Google.Protobuf.Collections since you removed the references to MapField

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Will submit another PR to remove it.

@daxian-dbw daxian-dbw merged commit 4af878f into Azure:dev Aug 31, 2018
@daxian-dbw daxian-dbw deleted the mywork branch August 31, 2018 21:28
davidmrdavid added a commit that referenced this pull request Apr 7, 2022
# This is the 1st commit message:

separate DF SDK classes from DF worker classes

# This is the commit message #2:

fix typo

# This is the commit message #3:

DurableSDK now compiles by itself

# This is the commit message #4:

Allow ExternalSDK to handle orchestration

# This is the commit message #5:

document next steps

# This is the commit message #6:

allow external SDK to set the user-code's input. Still need to refactor this logic for the worker to continue working with old SDK

# This is the commit message #7:

add import module

# This is the commit message #8:

supress traces

# This is the commit message #9:

avoid nullptr

# This is the commit message #10:

pass tests

# This is the commit message #11:

fix E2E tests

# This is the commit message #12:

develop E2E tests

# This is the commit message #13:

Enabled external durable client (#765)

Co-authored-by: Michael Peng <[email protected]>
# This is the commit message #14:

bindings work

# This is the commit message #15:

conditional binding intialization

# This is the commit message #16:

conditional import

# This is the commit message #17:

Added exception handling logic

# This is the commit message #18:

Revert durableController name to durableFunctionsUtils

# This is the commit message #19:

Ensure unit tests are functioning properly

# This is the commit message #20:

Corrected unit test names

# This is the commit message #21:

Turned repeated variables in unit tests into static members

# This is the commit message #22:

Fixed issue with building the worker

# This is the commit message #23:

Fix E2E test

# This is the commit message #24:

Fixed unit test setup

# This is the commit message #25:

Fixed another unit test setup

# This is the commit message #26:

Remove string representation of booleans

# This is the commit message #27:

patch e2e test
# This is the commit message #28:

remove typo in toString
# This is the commit message #29:

Update PowerShell language worker pipelines (#750)

* Install .Net to a global location

* Remove .Net installation tasks

* Update install .Net 6 task

* Update Windows image to use windows-latest
# This is the commit message #30:

Make throughput warning message visible for tooling diagnosis (#757)


# This is the commit message #31:

Update grpc.tools to version 2.43.0

# This is the commit message #32:

Update Google.Protobuf.Tools to version 3.19.4

# This is the commit message #33:

Revert "Update Google.Protobuf.Tools to version 3.19.4"

This reverts commit bcbd022.

# This is the commit message #34:

Revert "Update grpc.tools to version 2.43.0"

This reverts commit ccb323a.

# This is the commit message #35:

Update Google.Protobuf to 3.19.4 and grpc.tools to  2.43.0 (#762)

* Update grpc.tools to version 2.43.0

* Update Google.Protobuf.Tools to version 3.19.4
# This is the commit message #36:

Switch from Grpc.Core to Grpc.Net.Client (#758)

* Upgraded protobuf versions and removed Grpc.Core dependency

* Updated channel and option types used

* Change channel credentials

* Added http prefix to url

* Add valid URL check and explicitly include credentials
# This is the commit message #37:

Update pipeline logic to generate the SBOM for release builds (#767)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants