Giter VIP home page Giter VIP logo

Comments (4)

alistairjevans avatar alistairjevans commented on August 24, 2024

Hey; we're a big bogged down getting the Autofac v6 release out right now.

To be honest, I'm not 100% clear what is being asked here; @alexmg, can you offer any insight?

from autofac.servicefabric.

alexmg avatar alexmg commented on August 24, 2024

Thanks for reporting this issue @n3gwave.

I have added a global hook that allows registrations to be added to the lifetime scope created for the service instance. This is provided to the RegisterServiceFabricSupport method the same as the global constructor exception callback.

The registration should look something like the example below. The ServiceContext is resolved from the IComponentContext because the instance is registered just prior to the callback being invoked while the lifetime scope is being created.

builder.RegisterServiceFabricSupport(
    configurationAction: b =>
        b.Register(c => FabricTelemetryInitializerExtension.CreateFabricTelemetryInitializer(
                c.Resolve<ServiceContext>()))
            .As<ITelemetryInitializer>()
            .SingleInstance());

I'm not sure if the timing of this will be adequate for the WebHostBuilder scenario because the ITelemetryInitializer will not be registered in the root lifetime scope and will not be added until the initial container build. It would be great if you could test this out from the MyGet package feed and let us know if it covers the required scenarios.

Install-Package Autofac.ServiceFabric -Version 4.0.0-develop-00076 -Source https://www.myget.org/F/autofac/api/v3/index.json

If there are issues it would be great to have an example application that could be used for testing. I was not able to test this with the Service Fabric demo application because it has not been updated to include .NET Core examples. It would also be good to have the demo application include the configuration of Application Insights telemetry, but I don't have time to get to this now.

@alistairjevans @alsami @tillig Please hold off releasing the 4.0.0 package until this has been resolved. I have reopened this issue even though there is a commit in play because I'm not convinced it will be enough.

from autofac.servicefabric.

n3gwave avatar n3gwave commented on August 24, 2024

Hey, I think that should be fine at least for things I'm doing. You are right that for case with WebHostBuilder and default template this would still be problem, but I use a combination of generic host with Autofac DI and then for services that needs http I create my own http communication listener (forked from kestrel) but has very important detail:
UseServiceProviderFactory(new AutofacChildLifetimeScopeServiceProviderFactory(this.rootScope.BeginLifetimeScope(endpointName)))
So the listener http web host has child container. That's why it's fine for me to register FabricTelemetryInitializer in the root. It will be passed down to inner hosts as well. But I doubt it people are using SF in the same way.
Anyway, it would be also good to support IReliableStateManager by default as well. Currently I'm doing some workarounds and it works but still it's not obvious. Nonetheless, I think your solution could be used with this case as well but with some 'if's' because we need to make sure we are in stateful service and this callback is added globally.
I wish I could help with testing it, but unfortunately I've no time for that right now. Basically i'm quite good with workaround I've, at least for now.

from autofac.servicefabric.

alexmg avatar alexmg commented on August 24, 2024

Hi @n3gwave. It would be great if you could use the package from MyGet to confirm that this does address your issue. If everything looks good, we can release the package with the changes.

from autofac.servicefabric.

Related Issues (20)

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.