Giter Site home page Giter Site logo

dnc-dshop.common's People

Contributors

goorion avatar spetz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dnc-dshop.common's Issues

Replace Task.Result With Task.GetAwaiter().GetResult()

There are several places where Task.Result is used. But my suggestion is to use Task.GetAwaiter().GetResult() instead of Task.Result, Please refer quotes from one of the Microsoft's repo

you should avoid using Task.Result and Task.Wait as much as possible as they always encapsulate the inner exception in an AggregateException and replace the message by a generic one (One or more errors occurred), which makes debugging harder. Even if the synchronous version shouldn't be used that often, you should strongly consider using Task.GetAwaiter().GetResult() instead

Help me migration from Autofac DI to .NET Core DI.

I want to migrate my registration to native DI of .NET Core.

There a some variation (delegate).

Is this correctl?

public static void AddRabbitMq(this ContainerBuilder builder)
        {
            builder.Register(context =>
            {
                var configuration = context.Resolve<IConfiguration>();
                var options = configuration.GetOptions<RabbitMqOptions>("rabbitMq");

                return options;
            }).SingleInstance();

            builder.Register(context =>
            {
                var configuration = context.Resolve<IConfiguration>();
                var options = configuration.GetOptions<RawRabbitConfiguration>("rabbitMq");

                return options;
            }).SingleInstance();

            var assembly = Assembly.GetCallingAssembly();
            builder.RegisterAssemblyTypes(assembly)
                .AsClosedTypesOf(typeof(IEventHandlerRabbitMq<>))
                .InstancePerDependency();

            builder.RegisterType<BusPublisher>().As<IBusPublisher>()
                                    .InstancePerDependency();

            builder.RegisterInstance(DefaultJaeger.Create())
                   .As<ITracer>()
                   .SingleInstance()
                   .PreserveExistingDefaults();

            ConfigureBus(builder);
        }
private static void ConfigureBus(ContainerBuilder builder)
        {
            builder.Register<IInstanceFactory>(context =>
            {
                var options = context.Resolve<RabbitMqOptions>();
                var configuration = context.Resolve<RawRabbitConfiguration>();
                var namingConventions = new CustomNamingConventions(options.Namespace);
                var tracer = context.Resolve<ITracer>();

                return RawRabbitFactory.CreateInstanceFactory(new RawRabbitOptions
                {
                    DependencyInjection = ioc =>
                    {
                        ioc.AddSingleton(options);
                        ioc.AddSingleton(configuration);
                        ioc.AddSingleton<INamingConventions>(namingConventions);
                        ioc.AddSingleton(tracer);
                    },
                    Plugins = p => p
                        .UseAttributeRouting()
                        .UseRetryLater()
                        .UpdateRetryInfo()
                        .UseMessageContext<CorrelationContext>()
                        .UseContextForwarding()
                });
            }).SingleInstance();

            builder.Register(context => context.Resolve<IInstanceFactory>().Create());
        }

The new version:

public static void AddRabbitMq(this IServiceCollection services, IConfiguration configuration)
        {
            var optionsMq = configuration.GetOptions<RabbitMqOptions>("rabbitMq");

            var optionsRawRabbit = configuration.GetOptions<RawRabbitConfiguration>("rabbitMq");

            services.AddSingleton(optionsMq);

            services.AddSingleton(optionsRawRabbit);

            services.AddScoped(typeof(IBusPublisher), typeof(BusPublisher));

            services.RegisterAllImplementedInterface(Assembly.GetEntryAssembly(), typeof(IEventHandlerRabbitMq<>));

            var namingConventions = new CustomNamingConventions(optionsMq.Namespace);

            var tracer = DefaultJaeger.Create();

            services.AddSingleton(tracer);

           var rawFactory = RawRabbitFactory.CreateInstanceFactory(new RawRabbitOptions
            {
                DependencyInjection = ioc =>
                {
                    ioc.AddSingleton(optionsMq);
                    ioc.AddSingleton(optionsRawRabbit);
                    ioc.AddSingleton<INamingConventions>(namingConventions);
                    ioc.AddSingleton(tracer);
                },
                Plugins = p => p
                    .UseAttributeRouting()
                    .UseRetryLater()
                    .UpdateRetryInfo()
                    .UseMessageContext<CorrelationContext>()
                    .UseContextForwarding()
            });

            services.AddSingleton<IInstanceFactory>(rawFactory);

            services.AddSingleton<IBusClient>(rawFactory.Create());
        }

The publish message work very well but I have an error when SubscribeEvent, It doesn;t work in Local:

docker run --name rabbitmq -d -p 5672:5672 -p 15672:15672 --hostname rabbitmq rabbitmq:3-management

This is my setting:

"rabbitMq": {
    "namespace": "common",
    "retries": 3,
    "retryInterval": 2,
    "username": "guest",
    "password": "guest",
    "virtualHost": "/",
    "port": 5672,
    "hostnames": [
      "localhost"
    ],
    "requestTimeout": "00:00:30",
    "publishConfirmTimeout": "00:00:30",
    "recoveryInterval": "00:00:05",
    "persistentDeliveryMode": true,
    "autoCloseConnection": false,
    "automaticRecovery": true,
    "topologyRecovery": true,
    "exchange": {
      "durable": true,
      "autoDelete": false,
      "type": "Topic"
    },
    "queue": {
      "autoDelete": false,
      "durable": true,
      "exclusive": false
    }
  },

https://i.imgur.com/rScrRNt.png

How to reload Vault updates without restarting app

Hi @GooRiOn you mentioned that to reload vault version update without restarting the application is pretty simple. Since it uses MemoryConfigurationSource to replace appsettings.json values , it does not support reloadOnChanges. In that case what should be the approach? should we implement IHostedService with Timer?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.