Initial check-in for the PowerShell language worker
This commit is contained in:
Родитель
b01a685490
Коммит
e2678889eb
|
@ -0,0 +1,3 @@
|
|||
[submodule "src/protocol/protobuf"]
|
||||
path = src/protocol/protobuf
|
||||
url = https://github.com/Azure/azure-functions-language-worker-protobuf.git
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
|
||||
using CommandLine;
|
||||
using Grpc.Core;
|
||||
using Microsoft.Azure.WebJobs.Script.Grpc.Messages;
|
||||
|
||||
namespace Microsoft.Azure.PowerShell.Worker
|
||||
{
|
||||
public class WorkerEntry
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
LanguageWorker worker;
|
||||
Parser.Default.ParseArguments<ArgumentOptions>(args)
|
||||
.WithParsed(ops => worker = new LanguageWorker(ops))
|
||||
.WithNotParsed(err => Environment.Exit(1));
|
||||
}
|
||||
}
|
||||
|
||||
public class ArgumentOptions
|
||||
{
|
||||
[Option("host", Required = true, HelpText = "IP Address used to connect to the Host via gRPC.")]
|
||||
public string Host { get; set; }
|
||||
|
||||
[Option("port", Required = true, HelpText = "Port used to connect to the Host via gRPC.")]
|
||||
public int Port { get; set; }
|
||||
|
||||
[Option("workerId", Required = true, HelpText = "Worker ID assigned to this language worker.")]
|
||||
public string WorkerId { get; set; }
|
||||
|
||||
[Option("requestId", Required = true, HelpText = "Request ID used for gRPC communication with the Host.")]
|
||||
public string RequestId { get; set; }
|
||||
|
||||
[Option("grpcMaxMessageLength", Required = true, HelpText = "gRPC Maximum message size.")]
|
||||
public int MaxMessageLength { get; set; }
|
||||
}
|
||||
|
||||
internal class LanguageWorker
|
||||
{
|
||||
private ArgumentOptions _options;
|
||||
private FunctionRpc.FunctionRpcClient _client;
|
||||
private AsyncDuplexStreamingCall<StreamingMessage, StreamingMessage> _streamingCall;
|
||||
|
||||
internal LanguageWorker(ArgumentOptions options)
|
||||
{
|
||||
var channel = new Channel(options.Host, options.Port, ChannelCredentials.Insecure);
|
||||
_client = new FunctionRpc.FunctionRpcClient(channel);
|
||||
_streamingCall = _client.EventStream();
|
||||
_options = options;
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,91 @@
|
|||
// <auto-generated>
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: FunctionRpc.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 0414, 1591
|
||||
#region Designer generated code
|
||||
|
||||
using grpc = global::Grpc.Core;
|
||||
|
||||
namespace Microsoft.Azure.WebJobs.Script.Grpc.Messages {
|
||||
/// <summary>
|
||||
/// Interface exported by the server.
|
||||
/// </summary>
|
||||
public static partial class FunctionRpc
|
||||
{
|
||||
static readonly string __ServiceName = "AzureFunctionsRpcMessages.FunctionRpc";
|
||||
|
||||
static readonly grpc::Marshaller<global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage> __Marshaller_StreamingMessage = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage.Parser.ParseFrom);
|
||||
|
||||
static readonly grpc::Method<global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage, global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage> __Method_EventStream = new grpc::Method<global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage, global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage>(
|
||||
grpc::MethodType.DuplexStreaming,
|
||||
__ServiceName,
|
||||
"EventStream",
|
||||
__Marshaller_StreamingMessage,
|
||||
__Marshaller_StreamingMessage);
|
||||
|
||||
/// <summary>Service descriptor</summary>
|
||||
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
|
||||
{
|
||||
get { return global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.FunctionRpcReflection.Descriptor.Services[0]; }
|
||||
}
|
||||
|
||||
/// <summary>Base class for server-side implementations of FunctionRpc</summary>
|
||||
public abstract partial class FunctionRpcBase
|
||||
{
|
||||
public virtual global::System.Threading.Tasks.Task EventStream(grpc::IAsyncStreamReader<global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage> requestStream, grpc::IServerStreamWriter<global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage> responseStream, grpc::ServerCallContext context)
|
||||
{
|
||||
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>Client for FunctionRpc</summary>
|
||||
public partial class FunctionRpcClient : grpc::ClientBase<FunctionRpcClient>
|
||||
{
|
||||
/// <summary>Creates a new client for FunctionRpc</summary>
|
||||
/// <param name="channel">The channel to use to make remote calls.</param>
|
||||
public FunctionRpcClient(grpc::Channel channel) : base(channel)
|
||||
{
|
||||
}
|
||||
/// <summary>Creates a new client for FunctionRpc that uses a custom <c>CallInvoker</c>.</summary>
|
||||
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
|
||||
public FunctionRpcClient(grpc::CallInvoker callInvoker) : base(callInvoker)
|
||||
{
|
||||
}
|
||||
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
|
||||
protected FunctionRpcClient() : base()
|
||||
{
|
||||
}
|
||||
/// <summary>Protected constructor to allow creation of configured clients.</summary>
|
||||
/// <param name="configuration">The client configuration.</param>
|
||||
protected FunctionRpcClient(ClientBaseConfiguration configuration) : base(configuration)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual grpc::AsyncDuplexStreamingCall<global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage, global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage> EventStream(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
|
||||
{
|
||||
return EventStream(new grpc::CallOptions(headers, deadline, cancellationToken));
|
||||
}
|
||||
public virtual grpc::AsyncDuplexStreamingCall<global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage, global::Microsoft.Azure.WebJobs.Script.Grpc.Messages.StreamingMessage> EventStream(grpc::CallOptions options)
|
||||
{
|
||||
return CallInvoker.AsyncDuplexStreamingCall(__Method_EventStream, null, options);
|
||||
}
|
||||
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
|
||||
protected override FunctionRpcClient NewInstance(ClientBaseConfiguration configuration)
|
||||
{
|
||||
return new FunctionRpcClient(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates service definition that can be registered with a server</summary>
|
||||
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
|
||||
public static grpc::ServerServiceDefinition BindService(FunctionRpcBase serviceImpl)
|
||||
{
|
||||
return grpc::ServerServiceDefinition.CreateBuilder()
|
||||
.AddMethod(__Method_EventStream, serviceImpl.EventStream).Build();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 58b3dc0dbde065b15bd979bd2e27f36b7ee6273e
|
|
@ -0,0 +1,23 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<RootNamespace>Microsoft.Azure.PowerShell.Worker</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Grpc" Version="1.13.1" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.6.0" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.2.1" />
|
||||
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.0-beta5" />
|
||||
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.1.0-preview.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\worker.config.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"Description":{
|
||||
"Language":"powershell",
|
||||
"Extension":".ps1",
|
||||
"DefaultExecutablePath":"C:\\Users\\dongbow\\AppData\\Local\\Microsoft\\dotnet\\dotnet.exe",
|
||||
"DefaultWorkerPath":"psworker.dll"
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче