Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocav committed Apr 30, 2018
2 parents 6508d00 + d7aa989 commit abac483
Show file tree
Hide file tree
Showing 28 changed files with 142 additions and 763 deletions.
14 changes: 0 additions & 14 deletions schemas/json/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,6 @@
}
},

"languageWorker": {
"description": "Configuration settings for Language Workers.",
"type": "object",

"properties": {
"maxMessageLength": {
"description": "Defines maximum message size in MegaBytes (MB) for the streaming messages between the functions host and a language worker",
"type": "integer",
"minimum": 4,
"default": 32
}
}
},

"applicationInsights": {
"description": "Configuration settings for Application Insights logging.",
"type": "object",
Expand Down
3 changes: 1 addition & 2 deletions src/WebJobs.Script.Grpc/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Messages
node_modules
azure-functions-language-worker-protobuf
node_modules
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ service FunctionRpc {
}

message StreamingMessage {
// Used to identify message between host and worker
string request_id = 1;

// Payload of the message
oneof content {

// Worker initiates stream
StartStream start_stream = 20;

// Host sends capabilities/init data to worker
Expand Down Expand Up @@ -53,17 +48,12 @@ message StreamingMessage {
// Worker responds after loading with the load result
FunctionLoadResponse function_load_response = 9;

// Host requests a given invocation
InvocationRequest invocation_request = 4;

// Worker responds to a given invocation
InvocationResponse invocation_response = 5;

// Host sends cancel message to attempt to cancel an invocation.
// If an invocation is cancelled, host will receive an invocation response with status cancelled.
InvocationCancel invocation_cancel = 21;

// Worker logs a message back to the host
RpcLog rpc_log = 2;
}
}
Expand All @@ -73,15 +63,11 @@ message StreamingMessage {
// protocol type
// protocol version

// Worker sends the host information identifying itself
message StartStream {
// id of the worker
string worker_id = 2;
}

// Host requests the worker to initialize itself
message WorkerInitRequest {
// version of the host sending init request
string host_version = 1;

// A map of host supported features/capabilities
Expand All @@ -92,40 +78,27 @@ message WorkerInitRequest {
map<string, RpcLog.Level> log_categories = 3;
}

// Worker responds with the result of initializing itself
message WorkerInitResponse {
// Version of worker
string worker_version = 1;
// A map of worker supported features/capabilities
map<string, string> capabilities = 2;

// Status of the response
StatusResult result = 3;
}

// Used by the host to determine success/failure/cancellation
message StatusResult {
// Indicates Failure/Success/Cancelled
enum Status {
Failure = 0;
Success = 1;
Cancelled = 2;
}
// Status for the given result
Status status = 4;

// Specific message about the result
string result = 1;

// Exception message (if exists) for the status
RpcException exception = 2;

// Captured logs or relevant details can use the logs property
repeated RpcLog logs = 3;
}

// TODO: investigate grpc heartbeat - don't limit to grpc implemention

// Message is empty by design - Will add more fields in future if needed
message WorkerHeartbeat {}

Expand All @@ -135,170 +108,113 @@ message WorkerTerminate {
google.protobuf.Duration grace_period = 1;
}

// Host notifies worker of file content change
message FileChangeEventRequest {
// Types of File change operations (See link for more info: https://msdn.microsoft.com/en-us/library/t6xf43e0(v=vs.110).aspx)
// https://msdn.microsoft.com/en-us/library/t6xf43e0(v=vs.110).aspx
enum Type {
Unknown = 0;
Unknown = 0;
Created = 1;
Deleted = 2;
Changed = 4;
Renamed = 8;
All = 15;
}

// type for this event
Type type = 1;

// full file path for the file change notification
string full_path = 2;

// Name of the function affected
string name = 3;
}

// Indicates whether worker reloaded successfully or needs a restart
message WorkerActionResponse {
// indicates whether a restart is needed, or reload succesfully
enum Action {
Restart = 0;
Reload = 1;
}

// action for this response
Action action = 1;

// text reason for the response
string reason = 2;
}

// NOT USED
message WorkerStatusRequest{
}

// NOT USED
message WorkerStatusResponse {
}

// Host tells the worker to load a Function
message FunctionLoadRequest {
// unique function identifier (avoid name collisions, facilitate reload case)
string function_id = 1;

// Metadata for the request
RpcFunctionMetadata metadata = 2;
}

// Worker tells host result of reload
message FunctionLoadResponse {
// unique function identifier
string function_id = 1;

// Result of load operation
StatusResult result = 2;
// TODO: return type expected?
}

// Information on how a Function should be loaded and its bindings
message RpcFunctionMetadata {
// TODO: do we want the host's name - the language worker might do a better job of assignment than the host
string name = 4;

// base directory for the Function
string directory = 1;

// Script file specified
string script_file = 2;

// Entry point specified
string entry_point = 3;

// Bindings info
map<string, BindingInfo> bindings = 6;

// not adding disabled or excluded as those (currently) are only relevant to host
}

// Host requests worker to invoke a Function
message InvocationRequest {
// Unique id for each invocation
string invocation_id = 1;

// Unique id for each Function
string function_id = 2;

// Input bindings (include trigger)
repeated ParameterBinding input_data = 3;

// binding metadata from trigger
map<string, TypedData> trigger_metadata = 4;
}

// Host requests worker to cancel invocation
message InvocationCancel {
// Unique id for invocation
string invocation_id = 2;

// Time period before force shutdown
google.protobuf.Duration grace_period = 1; // could also use absolute time
}

// Worker responds with status of Invocation
message InvocationResponse {
// Unique id for invocation
string invocation_id = 1;

// Output binding data
repeated ParameterBinding output_data = 2;

// data returned from Function (for $return and triggers with return support)
TypedData return_value = 4;

// Status of the invocation (success/failure/canceled)
StatusResult result = 3;
}

// Used to encapsulate data which could be a variety of types
message TypedData {
oneof data {
string string = 1;
string json = 2;
bytes bytes = 3;
bytes stream = 4;
RpcHttp http = 5;
sint64 int = 6;
sint64 int = 6;
double double = 7;
}
}

// Used to describe a given binding on invocation
message ParameterBinding {
// Name for the binding
string name = 1;

// Data for the binding
TypedData data = 2;
}

// Used to describe a given binding on load
message BindingInfo {
// Indicates whether it is an input or output binding (or a fancy inout binding)
enum Direction {
in = 0;
out = 1;
inout = 2;
}

// Type of binding (e.g. HttpTrigger)
string type = 2;

// Direction of the given binding
Direction direction = 3;

enum Direction {
in = 0;
out = 1;
inout = 2;
}
}

// Used to send logs back to the Host
message RpcLog {
// Matching ILogger semantics
// https://github.com/aspnet/Logging/blob/9506ccc3f3491488fe88010ef8b9eb64594abf95/src/Microsoft.Extensions.Logging/Logger.cs
// Level for the Log
enum Level {
Trace = 0;
Debug = 1;
Expand All @@ -309,42 +225,24 @@ message RpcLog {
None = 6;
}

// Unique id for invocation (if exists)
string invocation_id = 1;

// TOD: This should be an enum
// Category for the log (startup, load, invocation, etc.)
string category = 2;

// Level for the given log message
Level level = 3;

// Message for the given log
string message = 4;

// Id for the even associated with this log (if exists)
string event_id = 5;

// Exception (if exists)
RpcException exception = 6;

// json serialized property bag, or could use a type scheme like map<string, TypedData>
string properties = 7;
}

// Encapsulates an Exception
message RpcException {
// Source of the exception
string source = 3;

// Stack trace for the exception
string stack_trace = 1;

// Textual message describing hte exception
string message = 2;
}

// TODO - solidify this or remove it
// TODO - solidify this
message RpcHttp {
string method = 1;
string url = 2;
Expand All @@ -353,6 +251,6 @@ message RpcHttp {
map<string,string> params = 10;
string status_code = 12;
map<string,string> query = 15;
bool enable_content_negotiation= 16;
bool is_raw = 16;
TypedData rawBody = 17;
}
9 changes: 2 additions & 7 deletions src/WebJobs.Script.Grpc/Server/GrpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Grpc.Core;
Expand All @@ -16,13 +15,9 @@ public class GrpcServer : IRpcServer, IDisposable
private Server _server;
private bool _disposed = false;

public GrpcServer(FunctionRpc.FunctionRpcBase serviceImpl, int grpcMaxMessageLength)
public GrpcServer(FunctionRpc.FunctionRpcBase serviceImpl)
{
ChannelOption maxReceiveMessageLength = new ChannelOption(ChannelOptions.MaxReceiveMessageLength, grpcMaxMessageLength);
ChannelOption maxSendMessageLength = new ChannelOption(ChannelOptions.MaxSendMessageLength, grpcMaxMessageLength);
ChannelOption[] grpcChannelOptions = { maxReceiveMessageLength, maxSendMessageLength };

_server = new Server(grpcChannelOptions)
_server = new Server
{
Services = { FunctionRpc.BindService(serviceImpl) },
Ports = { new ServerPort("127.0.0.1", ServerPort.PickUnused, ServerCredentials.Insecure) }
Expand Down
2 changes: 1 addition & 1 deletion src/WebJobs.Script.Grpc/WebJobs.Script.Grpc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Folder Include="Messages\DotNet\" />
</ItemGroup>

<Target Name="GenerateProtoFiles" BeforeTargets="BeforeBuild" Inputs="azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto" Outputs="Messages/DotNet/FunctionRpc.cs;Messages/DotNet/FunctionRpcGrpc.cs">
<Target Name="GenerateProtoFiles" BeforeTargets="BeforeBuild" Inputs="Proto/FunctionRpc.proto" Outputs="Messages/DotNet/FunctionRpc.cs;Messages/DotNet/FunctionRpcGrpc.cs">
<Exec Command="./generate_protos.$(Ext)" />
<ItemGroup>
<Compile Include="**/*$(DefaultLanguageSourceExtension)" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(BaseIntermediateOutputPath)**;$(BaseOutputPath)**;@(Compile)" />
Expand Down
Loading

0 comments on commit abac483

Please sign in to comment.