예제 #1
0
        public static void Main(string[] args)
        {
            if (args.Length != 10)
            {
                Console.WriteLine("usage --host <host> --port <port> --workerId <workerId> --requestId <requestId> --grpcMaxMessageLength <length>");
                return;
            }

            int grpcMaxMessageLength = 0;

            for (int i = 1; i < 10; i += 2)
            {
                string currentArg = args[i];
                switch (i)
                {
                case 1: s_host = currentArg; break;

                case 3: s_port = int.Parse(currentArg); break;

                case 5: s_workerId = currentArg; break;

                case 7: s_requestId = currentArg; break;

                case 9: grpcMaxMessageLength = int.Parse(currentArg); break;

                default: throw new InvalidOperationException();
                }
            }

            Console.WriteLine($"host: {s_host}");
            Console.WriteLine($"port: {s_port}");
            Console.WriteLine($"workerId: {s_workerId}");
            Console.WriteLine($"requestId: {s_requestId}");
            Console.WriteLine($"grpcMaxMessageLength: {grpcMaxMessageLength}");

            Channel channel = new Channel(s_host, s_port, ChannelCredentials.Insecure);

            s_client = new FunctionRpc.FunctionRpcClient(channel);
            s_call   = s_client.EventStream();
            InitPowerShell();

            var streamingMessage = new StreamingMessage()
            {
                RequestId   = s_requestId,
                StartStream = new StartStream()
                {
                    WorkerId = s_workerId
                }
            };

            s_call.RequestStream.WriteAsync(streamingMessage);

            ProcessEvent().Wait();
        }
예제 #2
0
        public FunctionRpcClient(FunctionRpc.FunctionRpcClient client, string workerId)
        {
            this.client          = client;
            _workerId            = workerId;
            _eventManager        = new ScriptEventManager();
            _inboundWorkerEvents = _eventManager.OfType <InboundEvent>()
                                   .ObserveOn(new NewThreadScheduler())
                                   .Where(msg => msg.WorkerId == _workerId);

            _eventSubscriptions.Add(_inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.InvocationRequest)
                                    .ObserveOn(new NewThreadScheduler())
                                    .Subscribe((msg) => InvocationRequest(msg.Message)));
        }
예제 #3
0
        public FunctionRpcClient(FunctionRpc.FunctionRpcClient client, string workerId)
        {
            this.client          = client;
            _call                = client.EventStream();
            _workerId            = workerId;
            _eventManager        = new ScriptEventManager();
            _inboundWorkerEvents = _eventManager.OfType <InboundEvent>()
                                   .Where(msg => msg.WorkerId == _workerId);

            _eventSubscriptions.Add(_inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.InvocationRequest)
                                    .Subscribe((msg) => InvocationRequestHandler(msg.Message)));

            _eventSubscriptions.Add(_inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.WorkerInitRequest)
                                    .Subscribe((msg) => WorkerInitRequestHandler(msg.Message)));

            _eventSubscriptions.Add(_inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.WorkerTerminate)
                                    .Subscribe((msg) => WorkerTerminateRequest(msg.Message)));

            _eventSubscriptions.Add(_inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.FunctionLoadRequest)
                                    .Subscribe((msg) => FunctionLoadRequestHandler(msg.Message)));

            _eventSubscriptions.Add(_inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.FunctionEnvironmentReloadRequest)
                                    .Subscribe((msg) => FunctionEnvironmentReloadRequestHandler(msg.Message)));
        }