public static void AddDefaultServices(IClientBuilder builder, IServiceCollection services) { services.TryAddSingleton <ILifecycleParticipant <IClusterClientLifecycle>, ClientOptionsLogger>(); services.TryAddSingleton <TelemetryManager>(); services.TryAddFromExisting <ITelemetryProducer, TelemetryManager>(); services.TryAddSingleton <IHostEnvironmentStatistics, NoOpHostEnvironmentStatistics>(); services.TryAddSingleton <IAppEnvironmentStatistics, AppEnvironmentStatistics>(); services.AddLogging(); services.TryAddSingleton <ExecutorService>(); services.TryAddSingleton <TypeMetadataCache>(); services.TryAddSingleton <OutsideRuntimeClient>(); services.TryAddFromExisting <IRuntimeClient, OutsideRuntimeClient>(); services.TryAddFromExisting <IClusterConnectionStatusListener, OutsideRuntimeClient>(); services.TryAddSingleton <GrainFactory>(); services.TryAddSingleton <IGrainReferenceRuntime, GrainReferenceRuntime>(); services.TryAddSingleton <IGrainCancellationTokenRuntime, GrainCancellationTokenRuntime>(); services.TryAddFromExisting <IGrainFactory, GrainFactory>(); services.TryAddFromExisting <IInternalGrainFactory, GrainFactory>(); services.TryAddFromExisting <IGrainReferenceConverter, GrainFactory>(); services.TryAddSingleton <ClientProviderRuntime>(); services.TryAddSingleton <MessageFactory>(); services.TryAddSingleton <ClientStatisticsManager>(); services.TryAddFromExisting <IStreamProviderRuntime, ClientProviderRuntime>(); services.TryAddFromExisting <IProviderRuntime, ClientProviderRuntime>(); services.TryAddSingleton <IStreamSubscriptionManagerAdmin, StreamSubscriptionManagerAdmin>(); services.TryAddSingleton <IInternalClusterClient, ClusterClient>(); services.TryAddFromExisting <IClusterClient, IInternalClusterClient>(); // Serialization services.TryAddSingleton <SerializationManager>(); services.TryAddSingleton <ITypeResolver, CachedTypeResolver>(); services.TryAddSingleton <IFieldUtils, FieldUtils>(); services.AddSingleton <BinaryFormatterSerializer>(); services.AddSingleton <BinaryFormatterISerializableSerializer>(); services.AddFromExisting <IKeyedSerializer, BinaryFormatterISerializableSerializer>(); services.TryAddSingleton <ILBasedSerializer>(); services.AddFromExisting <IKeyedSerializer, ILBasedSerializer>(); // Application parts var parts = builder.GetApplicationPartManager(); services.TryAddSingleton <IApplicationPartManager>(parts); parts.AddApplicationPart(new AssemblyPart(typeof(RuntimeVersion).Assembly) { IsFrameworkAssembly = true }); parts.AddFeatureProvider(new BuiltInTypesSerializationFeaturePopulator()); parts.AddFeatureProvider(new AssemblyAttributeFeatureProvider <GrainInterfaceFeature>()); parts.AddFeatureProvider(new AssemblyAttributeFeatureProvider <SerializerFeature>()); services.AddTransient <IConfigurationValidator, ApplicationPartValidator>(); services.TryAddSingleton(typeof(IKeyedServiceCollection <,>), typeof(KeyedServiceCollection <,>)); //Add default option formatter if none is configured, for options which are requied to be configured services.TryConfigureFormatter <ClusterClientOptions, ClusterClientOptionsFormatter>(); services.TryConfigureFormatter <ClientMessagingOptions, ClientMessagingOptionFormatter>(); services.TryConfigureFormatter <NetworkingOptions, NetworkingOptionsFormatter>(); services.TryConfigureFormatter <ClientStatisticsOptions, ClientStatisticsOptionsFormatter>(); }
internal void Configure(IClientBuilder builder, IServiceCollection services) { var assemblies = builder.GetApplicationPartManager().ApplicationParts .OfType<AssemblyPart>().Select(x => x.Assembly) .ToArray(); services.AddSingleton<IActorSystem>(sp => sp.GetService<ClientActorSystem>()); services.AddSingleton<IClientActorSystem>(sp => sp.GetService<ClientActorSystem>()); services.AddSingleton(sp => new ClientActorSystem(assemblies, sp, middleware)); }
public static void AddDefaultServices(IClientBuilder builder, IServiceCollection services) { services.TryAddSingleton <TelemetryManager>(); services.TryAddFromExisting <ITelemetryProducer, TelemetryManager>(); services.AddLogging(); //temporary change until runtime moved away from Logger services.TryAddSingleton(typeof(LoggerWrapper <>)); services.TryAddSingleton <ExecutorService>(); services.TryAddSingleton <LoadedProviderTypeLoaders>(); services.TryAddSingleton <StatisticsProviderManager>(); services.TryAddSingleton <TypeMetadataCache>(); services.TryAddSingleton <OutsideRuntimeClient>(); services.TryAddFromExisting <IRuntimeClient, OutsideRuntimeClient>(); services.TryAddFromExisting <IClusterConnectionStatusListener, OutsideRuntimeClient>(); services.TryAddSingleton <GrainFactory>(); services.TryAddSingleton <IGrainReferenceRuntime, GrainReferenceRuntime>(); services.TryAddSingleton <IGrainCancellationTokenRuntime, GrainCancellationTokenRuntime>(); services.TryAddFromExisting <IGrainFactory, GrainFactory>(); services.TryAddFromExisting <IInternalGrainFactory, GrainFactory>(); services.TryAddFromExisting <IGrainReferenceConverter, GrainFactory>(); services.TryAddSingleton <ClientProviderRuntime>(); services.TryAddSingleton <MessageFactory>(); services.TryAddSingleton <StreamProviderManager>(); services.TryAddSingleton <ClientStatisticsManager>(); services.TryAddFromExisting <IStreamProviderManager, StreamProviderManager>(); services.TryAddFromExisting <IStreamProviderRuntime, ClientProviderRuntime>(); services.TryAddFromExisting <IProviderRuntime, ClientProviderRuntime>(); services.TryAddSingleton <IStreamSubscriptionManagerAdmin, StreamSubscriptionManagerAdmin>(); services.TryAddSingleton <IInternalClusterClient, ClusterClient>(); services.TryAddFromExisting <IClusterClient, IInternalClusterClient>(); // Serialization services.TryAddSingleton <SerializationManager>(); services.TryAddSingleton <ITypeResolver, CachedTypeResolver>(); services.TryAddSingleton <IFieldUtils, FieldUtils>(); services.AddSingleton <BinaryFormatterSerializer>(); services.AddSingleton <BinaryFormatterISerializableSerializer>(); services.AddFromExisting <IKeyedSerializer, BinaryFormatterISerializableSerializer>(); services.TryAddSingleton <ILBasedSerializer>(); services.AddFromExisting <IKeyedSerializer, ILBasedSerializer>(); // Application parts var parts = builder.GetApplicationPartManager(); services.TryAddSingleton <ApplicationPartManager>(parts); parts.AddApplicationPart(new AssemblyPart(typeof(RuntimeVersion).Assembly) { IsFrameworkAssembly = true }); parts.AddFeatureProvider(new BuiltInTypesSerializationFeaturePopulator()); parts.AddFeatureProvider(new AssemblyAttributeFeatureProvider <GrainInterfaceFeature>()); parts.AddFeatureProvider(new AssemblyAttributeFeatureProvider <SerializerFeature>()); services.AddTransient <IConfigurationValidator, ApplicationPartValidator>(); }
static void Configure(IClientBuilder builder, IServiceCollection services) { var assemblies = builder.GetApplicationPartManager().ApplicationParts .OfType <AssemblyPart>().Select(x => x.Assembly) .ToArray(); services.TryAddSingleton <IActorRefMiddleware>(DefaultActorRefMiddleware.Instance); services.TryAddSingleton <IStreamRefMiddleware>(DefaultStreamRefMiddleware.Instance); services.AddSingleton <IActorSystem>(sp => sp.GetService <ClientActorSystem>()); services.AddSingleton <IClientActorSystem>(sp => sp.GetService <ClientActorSystem>()); services.AddSingleton(sp => new ClientActorSystem(assemblies, sp)); }
/// <summary> /// Configures the <see cref="ApplicationPartManager"/> for this builder. /// </summary> /// <param name="builder">The builder.</param> /// <param name="configure">The configuration delegate.</param> /// <returns>The builder.</returns> public static IClientBuilder ConfigureApplicationParts(this IClientBuilder builder, Action <IApplicationPartManager> configure) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (configure == null) { throw new ArgumentNullException(nameof(configure)); } configure(builder.GetApplicationPartManager()); return(builder); }
/// <summary> /// Adds an application part. /// </summary> /// <param name="builder">The builder.</param> /// <param name="part">The application part.</param> public static IClientBuilder AddApplicationPart(this IClientBuilder builder, Assembly assembly) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } var manager = builder.GetApplicationPartManager(); manager.AddApplicationPart(new AssemblyPart(assembly)); return(builder); }
public static void AddDefaultServices(IClientBuilder builder, IServiceCollection services) { // Options logging services.TryAddSingleton(typeof(IOptionFormatter <>), typeof(DefaultOptionsFormatter <>)); services.TryAddSingleton(typeof(IOptionFormatterResolver <>), typeof(DefaultOptionsFormatterResolver <>)); services.AddSingleton <ClientOptionsLogger>(); services.AddFromExisting <ILifecycleParticipant <IClusterClientLifecycle>, ClientOptionsLogger>(); services.TryAddSingleton <TelemetryManager>(); services.TryAddFromExisting <ITelemetryProducer, TelemetryManager>(); services.TryAddSingleton <IHostEnvironmentStatistics, NoOpHostEnvironmentStatistics>(); services.TryAddSingleton <IAppEnvironmentStatistics, AppEnvironmentStatistics>(); services.TryAddSingleton <ClientStatisticsManager>(); services.TryAddSingleton <ApplicationRequestsStatisticsGroup>(); services.TryAddSingleton <StageAnalysisStatisticsGroup>(); services.TryAddSingleton <SchedulerStatisticsGroup>(); services.TryAddSingleton <SerializationStatisticsGroup>(); services.AddLogging(); services.TryAddSingleton <ExecutorService>(); services.TryAddSingleton <TypeMetadataCache>(); services.TryAddSingleton <OutsideRuntimeClient>(); services.TryAddFromExisting <IRuntimeClient, OutsideRuntimeClient>(); services.TryAddFromExisting <IClusterConnectionStatusListener, OutsideRuntimeClient>(); services.TryAddSingleton <GrainFactory>(); services.TryAddSingleton <IGrainReferenceRuntime, GrainReferenceRuntime>(); services.TryAddSingleton <IGrainCancellationTokenRuntime, GrainCancellationTokenRuntime>(); services.TryAddFromExisting <IGrainFactory, GrainFactory>(); services.TryAddFromExisting <IInternalGrainFactory, GrainFactory>(); services.TryAddFromExisting <IGrainReferenceConverter, GrainFactory>(); services.TryAddSingleton <ClientProviderRuntime>(); services.TryAddSingleton <MessageFactory>(); services.TryAddFromExisting <IStreamProviderRuntime, ClientProviderRuntime>(); services.TryAddFromExisting <IProviderRuntime, ClientProviderRuntime>(); services.TryAddSingleton <IStreamSubscriptionManagerAdmin, StreamSubscriptionManagerAdmin>(); services.TryAddSingleton <IInternalClusterClient, ClusterClient>(); services.TryAddFromExisting <IClusterClient, IInternalClusterClient>(); // Serialization services.TryAddSingleton <SerializationManager>(sp => ActivatorUtilities.CreateInstance <SerializationManager>(sp, sp.GetRequiredService <IOptions <ClientMessagingOptions> >().Value.LargeMessageWarningThreshold)); services.TryAddSingleton <ITypeResolver, CachedTypeResolver>(); services.TryAddSingleton <IFieldUtils, FieldUtils>(); services.AddSingleton <BinaryFormatterSerializer>(); services.AddSingleton <BinaryFormatterISerializableSerializer>(); services.AddFromExisting <IKeyedSerializer, BinaryFormatterISerializableSerializer>(); // Application parts var parts = builder.GetApplicationPartManager(); services.TryAddSingleton <IApplicationPartManager>(parts); parts.AddApplicationPart(new AssemblyPart(typeof(RuntimeVersion).Assembly) { IsFrameworkAssembly = true }); parts.AddFeatureProvider(new BuiltInTypesSerializationFeaturePopulator()); parts.AddFeatureProvider(new AssemblyAttributeFeatureProvider <GrainInterfaceFeature>()); parts.AddFeatureProvider(new AssemblyAttributeFeatureProvider <SerializerFeature>()); services.AddTransient <IConfigurationValidator, ApplicationPartValidator>(); services.TryAddSingleton(typeof(IKeyedServiceCollection <,>), typeof(KeyedServiceCollection <,>)); // Add default option formatter if none is configured, for options which are requied to be configured services.ConfigureFormatter <ClusterOptions>(); services.ConfigureFormatter <ClientMessagingOptions>(); services.ConfigureFormatter <ConnectionOptions>(); services.ConfigureFormatter <StatisticsOptions>(); services.AddTransient <IConfigurationValidator, ClusterOptionsValidator>(); services.AddTransient <IConfigurationValidator, ClientClusteringValidator>(); // TODO: abstract or move into some options. services.AddSingleton <SocketSchedulers>(); services.AddSingleton <SharedMemoryPool>(); // Networking services.TryAddSingleton <ConnectionManager>(); services.AddSingleton <ILifecycleParticipant <IClusterClientLifecycle>, ConnectionManagerLifecycleAdapter <IClusterClientLifecycle> >(); services.TryAddSingleton <IConnectionFactory, SocketConnectionFactory>(); services.TryAddTransient <IMessageSerializer>(sp => ActivatorUtilities.CreateInstance <MessageSerializer>(sp, sp.GetRequiredService <IOptions <ClientMessagingOptions> >().Value.MaxMessageHeaderSize, sp.GetRequiredService <IOptions <ClientMessagingOptions> >().Value.MaxMessageBodySize)); services.TryAddSingleton <ConnectionFactory, ClientOutboundConnectionFactory>(); services.TryAddSingleton <ClientMessageCenter>(sp => sp.GetRequiredService <OutsideRuntimeClient>().MessageCenter); services.TryAddFromExisting <IMessageCenter, ClientMessageCenter>(); services.AddSingleton <GatewayManager>(); services.TryAddSingleton <INetworkingTrace, NetworkingTrace>(); }
/// <summary> /// Adds all assemblies referenced by the provided <paramref name="assembly"/> as application parts. /// </summary> /// <param name="builder">The builder.</param> /// <param name="assembly">The assembly</param> public static IClientBuilder AddApplicationPartsFromReferences(this IClientBuilder builder, Assembly assembly) { builder.GetApplicationPartManager().AddApplicationPartsFromReferences(assembly); return(builder); }
public static void AddDefaultServices(IClientBuilder builder, IServiceCollection services) { // Options logging services.TryAddSingleton(typeof(IOptionFormatter <>), typeof(DefaultOptionsFormatter <>)); services.TryAddSingleton(typeof(IOptionFormatterResolver <>), typeof(DefaultOptionsFormatterResolver <>)); services.AddSingleton <ClientOptionsLogger>(); services.AddFromExisting <ILifecycleParticipant <IClusterClientLifecycle>, ClientOptionsLogger>(); services.TryAddSingleton <TelemetryManager>(); services.TryAddFromExisting <ITelemetryProducer, TelemetryManager>(); services.TryAddSingleton <IHostEnvironmentStatistics, NoOpHostEnvironmentStatistics>(); services.TryAddSingleton <IAppEnvironmentStatistics, AppEnvironmentStatistics>(); services.TryAddSingleton <ClientStatisticsManager>(); services.TryAddFromExisting <IStatisticsManager, ClientStatisticsManager>(); services.TryAddSingleton <ApplicationRequestsStatisticsGroup>(); services.TryAddSingleton <StageAnalysisStatisticsGroup>(); services.TryAddSingleton <SchedulerStatisticsGroup>(); services.TryAddSingleton <SerializationStatisticsGroup>(); services.AddLogging(); services.TryAddSingleton <TypeMetadataCache>(); services.TryAddSingleton <GrainBindingsResolver>(); services.TryAddSingleton <OutsideRuntimeClient>(); services.TryAddSingleton <ClientGrainContext>(); services.AddFromExisting <IGrainContextAccessor, ClientGrainContext>(); services.TryAddFromExisting <IRuntimeClient, OutsideRuntimeClient>(); services.TryAddFromExisting <IClusterConnectionStatusListener, OutsideRuntimeClient>(); services.TryAddSingleton <GrainFactory>(); services.TryAddSingleton <GrainInterfaceTypeToGrainTypeResolver>(); services.TryAddSingleton <GrainReferenceActivator>(); services.AddSingleton <IGrainReferenceActivatorProvider, ImrGrainReferenceActivatorProvider>(); services.AddSingleton <IGrainReferenceActivatorProvider, UntypedGrainReferenceActivatorProvider>(); services.TryAddSingleton <ImrRpcProvider>(); services.TryAddSingleton <ImrGrainMethodInvokerProvider>(); services.TryAddSingleton <GrainReferenceSerializer>(); services.TryAddSingleton <GrainReferenceKeyStringConverter>(); services.TryAddSingleton <IGrainReferenceRuntime, GrainReferenceRuntime>(); services.TryAddSingleton <GrainInterfaceTypeResolver>(); services.TryAddSingleton <GrainPropertiesResolver>(); services.TryAddSingleton <TypeConverter>(); services.TryAddSingleton <IGrainCancellationTokenRuntime, GrainCancellationTokenRuntime>(); services.TryAddFromExisting <IGrainFactory, GrainFactory>(); services.TryAddFromExisting <IInternalGrainFactory, GrainFactory>(); services.TryAddSingleton <ClientProviderRuntime>(); services.TryAddSingleton <MessageFactory>(); services.TryAddFromExisting <IStreamProviderRuntime, ClientProviderRuntime>(); services.TryAddFromExisting <IProviderRuntime, ClientProviderRuntime>(); services.TryAddSingleton <IStreamSubscriptionManagerAdmin, StreamSubscriptionManagerAdmin>(); services.TryAddSingleton <ImplicitStreamSubscriberTable>(); services.AddSingleton <IStreamNamespacePredicateProvider, DefaultStreamNamespacePredicateProvider>(); services.AddSingleton <IStreamNamespacePredicateProvider, ConstructorStreamNamespacePredicateProvider>(); services.AddSingletonKeyedService <string, IStreamIdMapper, DefaultStreamIdMapper>(DefaultStreamIdMapper.Name); services.TryAddSingleton <IInternalClusterClient, ClusterClient>(); services.TryAddFromExisting <IClusterClient, IInternalClusterClient>(); // Serialization services.TryAddSingleton <SerializationManager>(sp => ActivatorUtilities.CreateInstance <SerializationManager>(sp, sp.GetRequiredService <IOptions <ClientMessagingOptions> >().Value.LargeMessageWarningThreshold)); services.TryAddSingleton <ITypeResolver, CachedTypeResolver>(); services.TryAddSingleton <IFieldUtils, FieldUtils>(); // Register the ISerializable serializer first, so that it takes precedence services.AddSingleton <DotNetSerializableSerializer>(); services.AddFromExisting <IKeyedSerializer, DotNetSerializableSerializer>(); services.TryAddSingleton <ILBasedSerializer>(); services.AddFromExisting <IKeyedSerializer, ILBasedSerializer>(); // Application parts var parts = builder.GetApplicationPartManager(); services.TryAddSingleton <IApplicationPartManager>(parts); parts.AddApplicationPart(new AssemblyPart(typeof(RuntimeVersion).Assembly) { IsFrameworkAssembly = true }); parts.AddFeatureProvider(new BuiltInTypesSerializationFeaturePopulator()); parts.AddFeatureProvider(new AssemblyAttributeFeatureProvider <GrainInterfaceFeature>()); parts.AddFeatureProvider(new AssemblyAttributeFeatureProvider <SerializerFeature>()); services.AddTransient <IConfigurationValidator, ApplicationPartValidator>(); services.TryAddSingleton(typeof(IKeyedServiceCollection <,>), typeof(KeyedServiceCollection <,>)); // Add default option formatter if none is configured, for options which are required to be configured services.ConfigureFormatter <ClusterOptions>(); services.ConfigureFormatter <ClientMessagingOptions>(); services.ConfigureFormatter <ConnectionOptions>(); services.ConfigureFormatter <StatisticsOptions>(); services.AddTransient <IConfigurationValidator, ClusterOptionsValidator>(); services.AddTransient <IConfigurationValidator, ClientClusteringValidator>(); // TODO: abstract or move into some options. services.AddSingleton <SocketSchedulers>(); services.AddSingleton <SharedMemoryPool>(); // Networking services.TryAddSingleton <ConnectionCommon>(); services.TryAddSingleton <ConnectionManager>(); services.AddSingleton <ILifecycleParticipant <IClusterClientLifecycle>, ConnectionManagerLifecycleAdapter <IClusterClientLifecycle> >(); services.AddSingletonKeyedService <object, IConnectionFactory>( ClientOutboundConnectionFactory.ServicesKey, (sp, key) => ActivatorUtilities.CreateInstance <SocketConnectionFactory>(sp)); services.TryAddTransient <IMessageSerializer>(sp => ActivatorUtilities.CreateInstance <MessageSerializer>(sp, sp.GetRequiredService <IOptions <ClientMessagingOptions> >().Value.MaxMessageHeaderSize, sp.GetRequiredService <IOptions <ClientMessagingOptions> >().Value.MaxMessageBodySize)); services.TryAddSingleton <ConnectionFactory, ClientOutboundConnectionFactory>(); services.TryAddSingleton <ClientMessageCenter>(sp => sp.GetRequiredService <OutsideRuntimeClient>().MessageCenter); services.TryAddFromExisting <IMessageCenter, ClientMessageCenter>(); services.AddSingleton <GatewayManager>(); services.AddSingleton <NetworkingTrace>(); services.AddSingleton <MessagingTrace>(); // Type metadata services.AddSingleton <ClientClusterManifestProvider>(); services.AddFromExisting <IClusterManifestProvider, ClientClusterManifestProvider>(); services.AddSingleton <ClientManifestProvider>(); services.AddSingleton <IGrainInterfaceTypeProvider, AttributeGrainInterfaceTypeProvider>(); services.AddSingleton <GrainTypeResolver>(); services.AddSingleton <IGrainTypeProvider, AttributeGrainTypeProvider>(); services.AddSingleton <IGrainTypeProvider, LegacyGrainTypeResolver>(); services.AddSingleton <GrainPropertiesResolver>(); services.AddSingleton <GrainInterfaceTypeResolver>(); services.AddSingleton <IGrainInterfacePropertiesProvider, AttributeGrainInterfacePropertiesProvider>(); services.AddSingleton <IGrainPropertiesProvider, AttributeGrainPropertiesProvider>(); services.AddSingleton <IGrainInterfacePropertiesProvider, TypeNameGrainPropertiesProvider>(); services.AddSingleton <IGrainPropertiesProvider, TypeNameGrainPropertiesProvider>(); services.AddSingleton <IGrainPropertiesProvider, ImplementedInterfaceProvider>(); // Logging helpers services.AddSingleton <ClientLoggingHelper>(); services.AddFromExisting <ILifecycleParticipant <IClusterClientLifecycle>, ClientLoggingHelper>(); services.AddFromExisting <IGrainIdLoggingHelper, ClientLoggingHelper>(); services.AddFromExisting <IInvokeMethodRequestLoggingHelper, ClientLoggingHelper>(); }
/// <summary> /// Attempts to load all assemblies in the application base path and add them as application parts. /// </summary> /// <param name="builder">The builder.</param> public static IClientBuilder AddApplicationPartsFromBasePath(this IClientBuilder builder) { builder.GetApplicationPartManager().AddApplicationPartsFromBasePath(); return(builder); }
/// <summary> /// Adds all assemblies in the current <see cref="AppDomain"/> as application parts. /// </summary> /// <param name="builder">The builder.</param> /// <param name="loadReferencedAssemblies">Whether or not try to load all referenced assemblies before </param> public static IClientBuilder AddApplicationPartsFromAppDomain(this IClientBuilder builder, bool loadReferencedAssemblies = true) { builder.GetApplicationPartManager().AddApplicationPartsFromAppDomain(loadReferencedAssemblies); return(builder); }