Skip to content

FabricObserver 3.1.0 [Obsolete]

Compare
Choose a tag to compare
@GitTorre GitTorre released this 11 Dec 22:31
9ac52a6

FabricObserver 3.1.0 sfpkgs and nupkgs with Microsoft-signed binaries.

FabricObserver 3.1.0 introduces a refactored public API implementation (housed in a .NET Standard 2.0 library) that will BREAK existing plugins and forked default observer impls. The changes required to fix the breakage are trivial, however. Please see the SampleObserver project for a complete sample observer plugin implementation with code comments and readme with examples of the new ObserverBase and observer constructor format. If you did not fork the codebase or write a plugin, then the changes will have no impact on you.

This was done to support .NET Standard 2.0 observer plug-ins. All shared observer APIs now live in FabricObserver.Extensibility.dll. Observer plugin impls no longer reference FabricObserver.dll.

ObserverBase, utilities, interfaces reside in the new library.

Namespaces have not been changed in the new library so the impact will be minimal. Essentially, this will only break plugins or forks of the codebase that have observer impls that do not have the now required constructor signature, which is shared by ObserverBase. Please read the updated documentation for more information.

In a nutshell:

Observers must have a public constructor that takes two parameters, a FabricClient instance and a StatelessServiceContext instance:

using System.Threading;
using System.Threading.Tasks;
using FabricObserver.Observers.Utilities;
using FabricObserver.Observers.Utilities.Telemetry;

namespace FabricObserver.Observers
{
    public class SampleNewObserver : ObserverBase
    {
        // FabricObserver will inject the FabricClient and StatelessServiceContext instances at runtime.        
        public SampleNewObserver(FabricClient fabricClient, StatelessServiceContext context)
          : base(fabricClient, context)
        {
            //... Your impl.
        }

        public override async Task ObserveAsync(CancellationToken token)
        {
            //... Your impl.
        }

        public override async Task ReportAsync(CancellationToken token)
        {
            //... Your impl.
        }
    }
 }

Observer plugin startup class has a new ConfigureServices design:

using Microsoft.Extensions.DependencyInjection;
using FabricObserver.Observers;
using System.Fabric;

[assembly: FabricObserver.FabricObserverStartup(typeof(SampleNewObserverStartup))]
namespace FabricObserver.Observers
{
    public class SampleNewObserverStartup : IFabricObserverStartup
    {
        // FabricObserver will inject the FabricClient and StatelessServiceContext instances at runtime.
        public void ConfigureServices(IServiceCollection services, FabricClient fabricClient, StatelessServiceContext context)
        {
            services.AddScoped(typeof(ObserverBase), s => new SampleNewObserver(fabricClient, context));
        }
    }
}

If you are using ObserverHealthReporter in your current plugin, you will need to modify how you construct it:

// FabricClientInstance is a built-in object in ObserverBase. 
var healthReporter = new ObserverHealthReporter(ObserverLogger, FabricClientInstance);