Giter VIP home page Giter VIP logo

azure-functions-language-worker-protobuf's Introduction

Azure Functions Language Worker Protobuf

This repository contains the protobuf definition file which defines the gRPC service which is used between the Azure Functions Host and the Azure Functions language workers. This repo is shared across many repos in many languages (for each worker) by using git commands.

To use this repo in Azure Functions language workers, follow steps below to add this repo as a subtree (Adding This Repo). If this repo is already embedded in a language worker repo, follow the steps to update the consumed file (Pulling Updates).

Learn more about Azure Function's projects on the meta repo.

Adding This Repo

From within the Azure Functions language worker repo:

  1. Define remote branch for cleaner git commands
    • git remote add proto-file https://github.com/azure/azure-functions-language-worker-protobuf.git
    • git fetch proto-file
  2. Index contents of azure-functions-worker-protobuf to language worker repo
    • git read-tree --prefix=<path in language worker repo> -u proto-file/<version branch>
  3. Add new path in language worker repo to .gitignore file
    • In .gitignore, add path in language worker repo
  4. Finalize with commit
    • git commit -m "Added subtree from https://github.com/azure/azure-functions-language-worker-protobuf. Branch: <version branch>. Commit: <latest protobuf commit hash>"
    • git push

Pulling Updates

From within the Azure Functions language worker repo:

  1. Define remote branch for cleaner git commands
    • git remote add proto-file https://github.com/azure/azure-functions-language-worker-protobuf.git
    • git fetch proto-file
  2. Pull a specific release tag
    • git fetch proto-file refs/tags/<tag-name>
      • Example: git fetch proto-file refs/tags/v1.1.0-protofile
  3. Merge updates
    • Merge with an explicit path to subtree: git merge -X subtree=<path in language worker repo> --squash <tag-name> --allow-unrelated-histories --strategy-option theirs
      • Example: git merge -X subtree=src/WebJobs.Script.Grpc/azure-functions-language-worker-protobuf --squash v1.1.0-protofile --allow-unrelated-histories --strategy-option theirs
  4. Finalize with commit
    • git commit -m "Updated subtree from https://github.com/azure/azure-functions-language-worker-protobuf. Tag: <tag-name>. Commit: <commit hash>"
    • git push

Consuming FunctionRPC.proto

Note: Update versionNumber before running following commands

CSharp

set NUGET_PATH="%UserProfile%\.nuget\packages"
set GRPC_TOOLS_PATH=%NUGET_PATH%\grpc.tools\<versionNumber>\tools\windows_x86
set PROTO_PATH=.\azure-functions-language-worker-protobuf\src\proto
set PROTO=.\azure-functions-language-worker-protobuf\src\proto\FunctionRpc.proto
set PROTOBUF_TOOLS=%NUGET_PATH%\google.protobuf.tools\<versionNumber>\tools
set MSGDIR=.\Messages

if exist %MSGDIR% rmdir /s /q %MSGDIR%
mkdir %MSGDIR%

set OUTDIR=%MSGDIR%\DotNet
mkdir %OUTDIR%
%GRPC_TOOLS_PATH%\protoc.exe %PROTO% --csharp_out %OUTDIR% --grpc_out=%OUTDIR% --plugin=protoc-gen-grpc=%GRPC_TOOLS_PATH%\grpc_csharp_plugin.exe --proto_path=%PROTO_PATH% --proto_path=%PROTOBUF_TOOLS%

JavaScript

In package.json, add to the build script the following commands to build .js files and to build .ts files. Use and install npm package protobufjs.

Generate JavaScript files:

pbjs -t json-module -w commonjs -o azure-functions-language-worker-protobuf/src/rpc.js azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto

Generate TypeScript files:

pbjs -t static-module azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto -o azure-functions-language-worker-protobuf/src/rpc_static.js && pbts -o azure-functions-language-worker-protobuf/src/rpc.d.ts azure-functions-language-worker-protobuf/src/rpc_static.js

Java

Maven plugin : protobuf-maven-plugin In pom.xml add following under configuration for this plugin ${basedir}//azure-functions-language-worker-protobuf/src/proto

Python

python -m pip install -e .[dev] -U
python setup.py build

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

azure-functions-language-worker-protobuf's People

Contributors

alrod avatar amamounelsayed avatar anandagopal6 avatar andreasbotsikas avatar brandonh-msft avatar ejizba avatar gavin-aguiar avatar gohar94 avatar kashimiz avatar kshyju avatar liliankasem avatar madelinegordon avatar maiqbal11 avatar matkinson328 avatar mhoeger avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar pragnagopa avatar satishranjan avatar satvu avatar shreyas-gopalakrishna avatar soninaren avatar surgupta-msft avatar tmasternak avatar vrdmr avatar yojagad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-functions-language-worker-protobuf's Issues

Remove hard copy of google/protobuf/duration.proto

We currently have a hard copied version of the official protobuf duration.proto file so that we can reference it in our custom FunctionRpc.proto file. This causes errors with the java language worker, as it tries to compile duration.proto, which is already defined.

This file was included because it is necessary for compilation in the nodejs and python language workers. However, this shouldn't be necessary. For the python and nodejs, we should see if the language-specific libraries we are using for compilation have updated ways of handling this dependency.

Document versioning

git fetch proto-file refs/tags/v1.1.0-protofile

git merge -X subtree=src/WebJobs.Script.Grpc/azure-functions-language-worker-protobuf --squash v1.1.0-protofile --allow-unrelated-histories

Non-string header values on http response throws error

From @ahmelsayed on April 30, 2018 21:7

From @graham-sportsmgmt on February 17, 2018 3:49

[email protected]
JavaScript HttpTrigger
Local function emulator on Windows 10 x64

I am trying to set a response header in order to flag the length of the result set to our front end code.

This method throws an error:

context.res = {
  "headers" : { "length": response.length },
  "body": response
};

invocationResponse.outputData.data.http.headers: string{k:string} expected

This method doesn't throw an error, but adds no header to the response:

context.res.setHeader('length', response.length);

Copied from original issue: Azure/azure-functions-core-tools#386

Copied from original issue: Azure/azure-functions-host#2768

V3 breaking change: Remove managed_dependency_enabled property from FunctionLoadRequest

We are creating a new message for the Host to tell the worker to Initialize the function app.
For now, it will include two properties: function app root, and managed dependency enable option.

As a result, we will no longer need the managed_dependency_enabled property in FunctionLoadRequest--we need to remove this property once all workers start using this new message.

[FeatureRequest] Add RPC command to send output bindings in advance of InvocationResponse

Issue

If a worker function wants to, say, write to a table output binding, and there is a problem with that binding, there is no way to inform the worker function that the table binding is incorrect during execution so that it can take appropriate action, therefore CreateIfNotExists and other patterns are not possible without leveraging direct SDKs, which kind of defeats the point of using outputbinding in the first place.

Recommended Resolution

Allow workers to submit Output Bindings ahead of final InvocationResponse, and the host can return an immediate result to the worker so that the worker can inform the function if required so it can take appropriate action if there is a problem.

This would be an RPC function definition like SubmitOutputBinding or something.

References

Azure/azure-functions-powershell-worker#284

Bindings in protobuf definition

Right now, when receiving an invocation request, you need to check the binding type and construct the typed binding yourself...

(See here and here)

The point of having a protobuf definition should include having the typed bindings.

Null values for "map" type causes Buffer overrun on some languages

Causes buffer overrun, first reported here: Azure/azure-functions-nodejs-worker#142

The root cause of this issue is that we use a "map" in our protobuf file.

From the protocol buffers docs:

If you provide a key but no value for a map field, the behavior when the field is serialized is language-dependent. In C++, Java, and Python the default value for the type is serialized, while in other languages nothing is serialized.

In combination with protobuf.js, this results in generated code that overflows.

                    case 15:
                        reader.skip().pos++;
                        if (message.query === $util.emptyObject)
                            message.query = {};
                        key = reader.string();
                        reader.pos++;
                        message.query[key] = reader.string();
                        break;

Git "refusing to merge" updates from consuming repo

There's a bug with git where merge subtree causes a fatal: refusing to merge unrelated histories error.

Change update instruction (2.) to be:
git merge -s subtree proto-file/dev --squash --allow-unrelated-histories

with backup command: git merge -X subtree=<path in language worker repo> --squash proto-file/<version branch> --allow-unrelated-histories

Add "cookies" property to HttpRpc

We need to allow users to set multiple cookies on the HttpResponse, since we can't fold multiple cookie values into one header and the HttpRequest object does not support duplicated headers.

When you add multiple Set-Cookie headers to the response, actually they are combined and only one header is sent with comma-separated cookies. According to RFC2109 it is a valid syntax. But it is not according to RFC6265, which deprecates RFC2109

Proposal:

// Http cookie type. Note that only name and value are used for Http requests
message RpcHttpCookie {
    // Enum that lets servers require that a cookie shouoldn't be sent with cross-site requests
    enum SameSite {
        Undefined = 0;
        Strict = 1;
        Lax = 2;
    }
    
    // Cookie name
    name: string,
    
    // Cookie value
    value: string,

    // Specifies allowed hosts to receive the cookie
    domain: NullableString,

    // Specifies URL path that must exist in the requested URL
    path: NullableString,

    // Sets the cookie to expire at a specific date instead of when the client closes
    expires: NullableString // becomes Nullable<DateTimeOffset> in C#, maybe use google.protobuf.Timestamp?

    // Sets the cookie to only be sent with an encrypted request
    secure: bool, 

    // Sets the cookie to be inaccessible to JavaScript's Document.cookie API
    http_only: bool,

    // Can restrict the cookie to not be sent with cross-site requests
    same_site: SameSite,

    // Sets the cookie to expire after a specific length of time instead of when the client closes
    max_age: NullableString // becomes Nullable<TimeSpan> in C#, maybe use google.protobuf.Duration?
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.