Esempio n. 1
0
        public RegistrationEngineGrpc()
        {
            var serilog            = ServiceLocator.Current.GetInstance <ILogger>();
            var registrationEngine = ServiceLocator.Current.GetInstance <IRegistrationEngine>();

            _Impl = LogProxy.Create <IRegistrationEngine>(registrationEngine, serilog, LogType.All);
        }
        public MembershipManagerGrpc()
        {
            var serilog           = ServiceLocator.Current.GetInstance <ILogger>();
            var membershipManager = ServiceLocator.Current.GetInstance <IMembershipManager>();

            _Impl = LogProxy.Create <IMembershipManager>(membershipManager, serilog, LogType.All);
        }
Esempio n. 3
0
        private static void Register()
        {
            Serilog.ILogger serilog = new LoggerConfiguration()
                                      .Enrich.FromLogProxy()
                                      .Destructure.UsingAttributes()
                                      .WriteTo.Seq(EnvVars.SeqAddress())
                                      .CreateLogger();
            Log.Logger = serilog;

            var builder = new ContainerBuilder();

            // SSL gRPC
            var caCrt          = File.ReadAllText(EnvVars.CaCrtPath());
            var sslCredentials = new SslCredentials(caCrt);

            var registrationEngineGrpcChannel = new Channel(
                EnvVars.Target(@"RegistrationEngineHost", @"RegistrationEnginePort"),
                sslCredentials);

            // Create MagicOnion dynamic client proxy
            var registrationEngineGrpcClient = TrackingProxy.Create <IRegistrationEngineGrpc>(registrationEngineGrpcChannel);

            var registrationEngine = LogProxy.Create <IRegistrationEngine>(new RegistrationEngineClient(registrationEngineGrpcClient), serilog, LogType.All);

            builder.RegisterInstance <Serilog.ILogger>(serilog);
            builder.RegisterInstance <IRegistrationEngine>(registrationEngine);
            builder.RegisterType <MembershipManager>().As <IMembershipManager>();
            IContainer container = builder.Build();

            // Set up the service locator
            ServiceLocator.SetLocatorProvider(() => new AutofacServiceLocator(container));

            GrpcEnvironment.SetLogger(new ConsoleLogger());
        }
Esempio n. 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Use FromLoggingProxy to enrich the serilog output with diagnostic, tracking, error and performance logging.
            ILogger serilog = new LoggerConfiguration()
                              .Enrich.FromLogProxy()
                              .Destructure.ByIgnoringProperties <ResponseDto>(x => x.Password)
                              .WriteTo.Seq("http://localhost:5341")
                              .CreateLogger();

            Log.Logger = serilog;

            //LogProxy.FilterTheseParameters.Add("requestDto");

            // Wrapping a class in a LogProxy automatically enriches the serilog output.
            var valueAccess = LogProxy.Create <IValueAccess>(new ValueAccess(serilog), serilog, LogType.All);

            services.AddSingleton(valueAccess);
            services.AddSingleton(serilog);

            services.AddRouting(options => options.LowercaseUrls = true);

            services.AddMvc();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "My API", Version = "v1"
                });
            });


            services.AddControllers();
        }
Esempio n. 5
0
        public UserAccessGrpc()
        {
            var serilog    = ServiceLocator.Current.GetInstance <ILogger>();
            var userAccess = ServiceLocator.Current.GetInstance <IUserAccess>();

            _Impl = LogProxy.Create(userAccess, serilog, LogType.All);
        }
Esempio n. 6
0
        public static IWebHost BuildWebHost(ILogger serilog)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            Configuration = builder.Build();

            string appointmentsQueueConnectionString = Configuration[@"AppointmentManager:QueueConnectionString"];

            LogType logType = LogType.Tracking | LogType.Performance | LogType.Error | LogType.Diagnostic;

            var userAccess         = LogProxy.Create <IUserAccess>(new UserAccess(serilog), serilog, logType);
            var organisationAccess = LogProxy.Create <IOrganisationAccess>(new OrganisationAccess(serilog), serilog, logType);
            var appointmentAccess  = LogProxy.Create <IAppointmentAccess>(new AppointmentAccess(serilog), serilog, logType);

            var userManager         = LogProxy.Create <IUserManager>(new UserManager(userAccess, serilog), serilog, logType);
            var organisationManager = LogProxy.Create <IOrganisationManager>(new OrganisationManager(organisationAccess, serilog), serilog, logType);
            var appointmentManager  = LogProxy.Create <IAppointmentManager>(new AppointmentManager(appointmentAccess, serilog, appointmentsQueueConnectionString), serilog, logType);

            var restApiLogger = serilog;

            return(new WebHostBuilder()
                   .UseKestrel()
                   .ConfigureServices(
                       services => services
                       .AddSingleton(userManager)
                       .AddSingleton(organisationManager)
                       .AddSingleton(appointmentManager)
                       .AddSingleton(restApiLogger))
                   .UseContentRoot(Directory.GetCurrentDirectory())
                   .UseStartup <Startup>()
                   .Build());
        }
Esempio n. 7
0
        public static IWebHost BuildWebHost(ILogger serilog)
        {
            // SSL gRPC
            var caCrt          = File.ReadAllText(EnvVars.CaCrtPath());
            var sslCredentials = new SslCredentials(caCrt);

            var membershipManagerGrpcChannel = new Channel(
                EnvVars.Target(@"MembershipManagerHost", @"MembershipManagerPort"),
                sslCredentials);

            // Create MagicOnion dynamic client proxy
            var membershipManagerGrpcClient = TrackingProxy.Create <IMembershipManagerGrpc>(membershipManagerGrpcChannel);

            var membershipManager = LogProxy.Create <IMembershipManager>(new MembershipManagerClient(membershipManagerGrpcClient), serilog, LogType.All);

            var restApiLogger = serilog;

            return(new WebHostBuilder()
                   .UseKestrel(options =>
            {
                options.Listen(
                    IPAddress.Any,
                    EnvVars.LocalPort(@"RestApiPort"),
                    listenOptions => listenOptions.UseHttps(EnvVars.ServerPfxPath(), EnvVars.CrtPassword()));
            })
                   .ConfigureServices(
                       services => services
                       .AddSingleton <IMembershipManager>(membershipManager)
                       .AddSingleton <ILogger>(serilog))
                   .UseContentRoot(Directory.GetCurrentDirectory())
                   .UseStartup <Startup>()
                   .Build());
        }
        public static IMembershipManager GetProxy(ILogger serilog)
        {
            var userAccess         = LogProxy.Create <IUserAccess>(new UserAccess(serilog), serilog, LogType.All);
            var registrationEngine = LogProxy.Create <IRegistrationEngine>(new RegistrationEngine(userAccess, serilog), serilog, LogType.All);
            var membershipManager  = LogProxy.Create <IMembershipManager>(new MembershipManager(registrationEngine, serilog), serilog, LogType.All);

            return(membershipManager);
        }
Esempio n. 9
0
 public UserAccess(
     StatelessServiceContext context,
     ILogger logger)
     : base(context)
 {
     _Logger = logger ?? throw new ArgumentNullException(nameof(logger));
     _Impl   = LogProxy.Create <IUserAccess>(new Impl.UserAccess(logger), logger, LogType.All);
     _Logger.Information("Constructed");
 }
Esempio n. 10
0
        public MembershipManager(
            StatelessServiceContext context,
            ILogger logger)
            : base(context)
        {
            _Logger = logger ?? throw new ArgumentNullException(nameof(logger));
            var registrationEngine = TrackingProxy.ForComponent <IRegistrationEngine>(this);

            _Impl = LogProxy.Create <IMembershipManager>(new Impl.MembershipManager(registrationEngine, logger), logger, LogType.All);
            _Logger.Information("Constructed");
        }
        public RegistrationEngine(
            StatelessServiceContext context,
            ILogger logger)
            : base(context)
        {
            _Logger = logger ?? throw new ArgumentNullException(nameof(logger));
            var userAccess = TrackingProxy.ForComponent <IUserAccess>(this);

            _Impl = LogProxy.Create <IRegistrationEngine>(new Impl.RegistrationEngine(userAccess, logger), logger, LogType.All);
            _Logger.Information("Constructed");
        }
Esempio n. 12
0
        public static IWebHost BuildWebHost(ILogger serilog)
        {
            var userAccess         = LogProxy.Create <IUserAccess>(new UserAccess(serilog), serilog, LogType.All);
            var registrationEngine = LogProxy.Create <IRegistrationEngine>(new RegistrationEngine(userAccess, serilog), serilog, LogType.All);
            var membershipManager  = LogProxy.Create <IMembershipManager>(new MembershipManager(registrationEngine, serilog), serilog, LogType.All);

            var restApiLogger = serilog;

            return(new WebHostBuilder()
                   .UseKestrel()
                   .ConfigureServices(
                       services => services
                       .AddSingleton(membershipManager)
                       .AddSingleton(restApiLogger))
                   .UseContentRoot(Directory.GetCurrentDirectory())
                   .UseStartup <Startup>()
                   .Build());
        }