Skip to content

Allow a per-registration configurationAction on service and actor registrations #70

Open

Description

@tillig

Follow-up to #57, which is closed now that the global hook it asked for has shipped.

RegisterServiceFabricSupport accepts a configurationAction that runs while each service or actor lifetime scope is being built. It's the only place a component that needs ServiceContext at construction time can be registered, and it works — but it's global: the same action runs for every service and actor in the host.

That's awkward when registrations differ per service. The original issue ran into it directly: registering IReliableStateManager only makes sense for a stateful service, so with a single global action you end up branching inside the callback on what kind of service is being constructed.

Proposal

Accept an optional Action<ContainerBuilder> on the individual registration methods, running after the global action:

builder.RegisterStatefulService<MyService>(
    "MyServiceType",
    configurationAction: b => b.Register(c => /* stateful-only registrations */));

Applies to RegisterStatelessService, RegisterStatefulService, and RegisterActor. The plumbing already exists — IStatelessServiceFactoryRegistration and friends thread a configurationAction through to BeginLifetimeScope, so this is mostly a matter of composing a second action alongside the global one.

The global hook stays as-is, so this is additive for callers who don't need per-service registrations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions