Exemplo n.º 1
0
        internal RequestProcessor(MessagingStream msgStream)
        {
            _msgStream      = msgStream;
            _powershellPool = new PowerShellManagerPool(msgStream);

            // Host sends capabilities/init data to worker
            _requestHandlers.Add(StreamingMessage.ContentOneofCase.WorkerInitRequest, ProcessWorkerInitRequest);

            // Host sends terminate message to worker.
            // Worker terminates if it can, otherwise host terminates after a grace period
            _requestHandlers.Add(StreamingMessage.ContentOneofCase.WorkerTerminate, ProcessWorkerTerminateRequest);

            // Add any worker relevant status to response
            _requestHandlers.Add(StreamingMessage.ContentOneofCase.WorkerStatusRequest, ProcessWorkerStatusRequest);

            // On file change event, host sends notification to worker
            _requestHandlers.Add(StreamingMessage.ContentOneofCase.FileChangeEventRequest, ProcessFileChangeEventRequest);

            // Host sends required metadata to worker to load function
            _requestHandlers.Add(StreamingMessage.ContentOneofCase.FunctionLoadRequest, ProcessFunctionLoadRequest);

            // Host requests a given invocation
            _requestHandlers.Add(StreamingMessage.ContentOneofCase.InvocationRequest, ProcessInvocationRequest);

            // Host sends cancel message to attempt to cancel an invocation.
            // If an invocation is cancelled, host will receive an invocation response with status cancelled.
            _requestHandlers.Add(StreamingMessage.ContentOneofCase.InvocationCancel, ProcessInvocationCancelRequest);

            _requestHandlers.Add(StreamingMessage.ContentOneofCase.FunctionEnvironmentReloadRequest, ProcessFunctionEnvironmentReloadRequest);
        }
        public void LoggerContextIsSet()
        {
            var dummyBindingInfo = new Dictionary <string, ReadOnlyBindingInfo>();
            var outputBindings   = new ReadOnlyDictionary <string, ReadOnlyBindingInfo>(dummyBindingInfo);

            var powerShellManagerPool = new PowerShellManagerPool(() => new ContextValidatingLogger());
            var pwsh = Utils.NewPwshInstance();

            powerShellManagerPool.Initialize(pwsh);

            var worker = powerShellManagerPool.CheckoutIdleWorker("requestId", "invocationId", "FuncName", outputBindings);

            powerShellManagerPool.ReclaimUsedWorker(worker);
        }
 internal RequestProcessor(MessagingStream msgStream)
 {
     _msgStream      = msgStream;
     _powershellPool = new PowerShellManagerPool(msgStream);
     _functionLoader = new FunctionLoader();
 }