public void ConfigureServices(IServiceCollection services) { ConventionRegistry.Register("IgnoreIfNullConvention", new ConventionPack { new IgnoreIfNullConvention(true) }, t => true); services.AddControllers(); services.AddSingleton(new CancellationTokenSource()); services.AddSingleton <IBotSettings, BotSettings>(); IGrpcSettings grpcSettings = new GrpcSettings(); services.AddSingleton(GrpcChannel.ForAddress(grpcSettings.Url)); services.AddHostedService <BotsEntryPoint <SearchBot> >(); services.AddSingleton <ISenderSettings, SenderSettings>(); services.AddSingleton <IMessagesSender, MessagesSender>(); services.AddSingleton <MongoWriter>(); services.AddSingleton <IDataStorage <SearchBot>, DataStorage <SearchBot> >(); services.AddSingleton(new MongoClient(Options.MongoConnectionString)); services.AddTransient <SearchClient>(); services.AddTransient <SearchReciever <SearchBot> >(); services.AddTransient <IFSMFactory <SearchBot>, SubFSMFactory>(); services.AddTransient <IReadyProcessor <SearchBot>, SearchReadyProcessor>(); services.AddTransient <IBusyProcessor, BusyProcessor>(); services.AddTransient <IRightChecker, PrivateRightChecker>(); services.AddTransient <SearchState <SearchBot> >(); services.AddSingleton <AsyncTaskExecutor>(); services.AddTransient <ISearchResultReciever, StreamSearchResiever>(); services.AddTransient <Bot.Core.Services.Bot>(); AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddTransient <ISearchResultReciever, SearchResultsTestReciever>(); services.AddTransient <SearchClient>(); AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); IGrpcSettings grpcSettings = new GrpcSettings(); services.AddSingleton(GrpcChannel.ForAddress(grpcSettings.Url)); }
private (string, string) InterceptCallContext(ServerCallContext context) { string method = context.Method; GrpcSettings.ParseHeader(context.RequestHeaders, out string sender, out string senderBuildId, out string traceId); if (!string.IsNullOrEmpty(senderBuildId) && senderBuildId != m_buildId) { string failureMessage = $"The receiver and sender build ids do not match. Receiver build id: {m_buildId}. Sender build id: {senderBuildId}."; Logger.Log.GrpcTrace(m_loggingContext, failureMessage); throw new RpcException( new Status( StatusCode.InvalidArgument, failureMessage)); } // example: [MW1AAP45DD9145A::89 -> SELF] 740adbf7-ae68-4a94-b6c1-578b4a2ecb67 Received: /BuildXL.Distribution.Grpc.Orchestrator/Notify. Logger.Log.GrpcTrace(m_loggingContext, string.Format(ReceivedLogFormat, sender, traceId, method)); return(sender, traceId); }
private (string Sender, string TraceId) InterceptCallContext(ServerCallContext context) { string method = context.Method; GrpcSettings.ParseHeader(context.RequestHeaders, out string sender, out var senderInvocationId, out string traceId, out string token); if (m_invocationId != senderInvocationId) { string failureMessage = $"The receiver and sender distributed invocation ids do not match. Receiver invocation id: {m_invocationId}. Sender invocation id: {senderInvocationId}."; Logger.Log.GrpcTrace(m_loggingContext, failureMessage); var trailers = new Metadata { { GrpcMetadata.InvocationIdMismatch, GrpcMetadata.True }, { GrpcMetadata.IsUnrecoverableError, IsUnrecoverableMismatch(senderInvocationId) ? GrpcMetadata.True : GrpcMetadata.False } }; throw new RpcException( new Status( StatusCode.InvalidArgument, failureMessage), trailers); } if (m_encryptionEnabled && token != m_token) { Logger.Log.GrpcAuthTrace(m_loggingContext, $"Authentication tokens do not match:\r\nReceived:{token}\r\nExpected:{m_token}"); var trailers = new Metadata { { GrpcMetadata.IsUnrecoverableError, GrpcMetadata.True } }; throw new RpcException(new Status(StatusCode.Unauthenticated, "Call could not be authenticated."), trailers); } // example: [MW1AAP45DD9145A::89 -> SELF] 740adbf7-ae68-4a94-b6c1-578b4a2ecb67 Received: /BuildXL.Distribution.Grpc.Orchestrator/Notify. Logger.Log.GrpcTrace(m_loggingContext, string.Format(ReceivedLogFormat, sender, traceId, method)); return(sender, traceId); }
public GameManagerSettings() { Grpc = new GrpcSettings(); }