INetNode CreateNetNode(StatefulServiceContext initParams) { var logger = new LoggerConfiguration() .ConfigureMOUSETypesDestructure() .MinimumLevel.Verbose() .WriteTo.Seq("http://localhost:5341/") .CreateLogger(); var coreEventsLogger = new SerilogCoreEvents(logger); var lidgrenEventsLogger = new SerilogLidgrenEvents(logger); var messageSerializer = new ProtobufMessageSerializer(typeof(Message).Assembly, typeof(Say).Assembly); var endPoint = initParams .CodePackageActivationContext .GetEndpoint("ServiceEndPoint"); var nodeContext = FabricRuntime.GetNodeContext(); string nodeName = $"{nodeContext.NodeName}:{nodeContext.NodeId}"; var transport = new LidgrenNetProvider( new NetPeerConfiguration("Public") { MaximumConnections = 10, AcceptIncomingConnections = true, Port = endPoint.Port, LocalAddress = Dns.GetHostAddresses(nodeContext.IPAddressOrFQDN).First(x => x.AddressFamily == AddressFamily.InterNetwork) }, lidgrenEventsLogger); var netConfig = new NetNodeConfig() { ConnectTimeoutSec = 30, SendTimeoutSec = 30 }; var bufferPool = new WcfBufferPool(); var node = new NetNode<NetChannel>(nodeName, transport, coreEventsLogger, messageSerializer, config: netConfig, channelFactory: (owner, transportChannel) => new AsyncProcessingNetChannel(builder => builder .UseFiber(Fiber, config => config .Lock<Say>(LockType.Read) .Lock<JoinRoom>(LockType.Write) .Lock<PeerDisconnected>(LockType.Write)) .UseConfigurableDispatcher(config => config .HandleMessageAsync<Say>(OnSay) .HandleMessageAsync<JoinRoom>(OnRoomJoin) .HandleMessageAsync<PeerDisconnected>((msg, o) => OnRoomLeave(o.ReplyChannel))), owner, transportChannel, messageSerializer, coreEventsLogger, netConfig, bufferPool)); return node; }
public DeviceActorService(StatefulServiceContext context, ActorTypeInformation typeInfo, Func<ActorBase> actorFactory = null, IActorStateProvider stateProvider = null, ActorServiceSettings settings = null) : base(context, typeInfo, actorFactory, stateProvider, settings) { // Read settings from the DeviceActorServiceConfig section in the Settings.xml file var activationContext = Context.CodePackageActivationContext; var config = activationContext.GetConfigurationPackageObject(ConfigurationPackage); var section = config.Settings.Sections[ConfigurationSection]; // Read the ServiceBusConnectionString setting from the Settings.xml file var parameter = section.Parameters[ServiceBusConnectionStringParameter]; if (!string.IsNullOrWhiteSpace(parameter?.Value)) { ServiceBusConnectionString = parameter.Value; } else { throw new ArgumentException( string.Format(ParameterCannotBeNullFormat, ServiceBusConnectionStringParameter), ServiceBusConnectionStringParameter); } // Read the EventHubName setting from the Settings.xml file parameter = section.Parameters[EventHubNameParameter]; if (!string.IsNullOrWhiteSpace(parameter?.Value)) { EventHubName = parameter.Value; } else { throw new ArgumentException(string.Format(ParameterCannotBeNullFormat, EventHubNameParameter), EventHubNameParameter); } // Read the QueueLength setting from the Settings.xml file parameter = section.Parameters[QueueLengthParameter]; if (!string.IsNullOrWhiteSpace(parameter?.Value)) { QueueLength = DefaultQueueLength; int queueLength; if (int.TryParse(parameter.Value, out queueLength)) { QueueLength = queueLength; } } else { throw new ArgumentException(string.Format(ParameterCannotBeNullFormat, QueueLengthParameter), QueueLengthParameter); } }
public SendGridMailer(StatefulServiceContext serviceContext) { ConfigurationPackage configPackage = serviceContext.CodePackageActivationContext.GetConfigurationPackageObject("Config"); DataPackage dataPackage = serviceContext.CodePackageActivationContext.GetDataPackageObject("Data"); this.UpdateSendMailSettings(configPackage.Settings); this.UpdateJoinMailTemplateContent(dataPackage.Path); serviceContext.CodePackageActivationContext.ConfigurationPackageModifiedEvent += this.CodePackageActivationContext_ConfigurationPackageModifiedEvent; serviceContext.CodePackageActivationContext.DataPackageModifiedEvent += this.CodePackageActivationContext_DataPackageModifiedEvent; }
/// <summary> /// Creates a new instance of the service class. /// </summary> /// <param name="clusterOperator"></param> /// <param name="mailer"></param> /// <param name="stateManager"></param> /// <param name="serviceContext"></param> /// <param name="config"></param> public ClusterService( IClusterOperator clusterOperator, ISendMail mailer, IApplicationDeployService applicationDeployService, IReliableStateManager stateManager, StatefulServiceContext serviceContext, ClusterConfig config) : base(serviceContext, stateManager as IReliableStateManagerReplica) { this.config = config; this.clusterOperator = clusterOperator; this.applicationDeployService = applicationDeployService; this.mailer = mailer; }
public ArmClusterOperator(StatefulServiceContext serviceContext) { ConfigurationPackage configPackage = serviceContext.CodePackageActivationContext.GetConfigurationPackageObject("Config"); DataPackage dataPackage = serviceContext.CodePackageActivationContext.GetDataPackageObject("Data"); this.UpdateClusterOperatorSettings(configPackage.Settings); this.UpdateArmTemplateContent(dataPackage.Path); this.UpdateArmParameterContent(dataPackage.Path); serviceContext.CodePackageActivationContext.ConfigurationPackageModifiedEvent += this.CodePackageActivationContext_ConfigurationPackageModifiedEvent; serviceContext.CodePackageActivationContext.DataPackageModifiedEvent += this.CodePackageActivationContext_DataPackageModifiedEvent; }
public StatefulSessionService(StatefulServiceContext context) : base(context) { }
public ValidationService(StatefulServiceContext serviceContext, IReliableStateManagerReplica reliableStateManagerReplica) : base(serviceContext, reliableStateManagerReplica) { }
protected KeyValueStatefulService(StatefulServiceContext serviceContext, KeyValueStateProvider stateProviderReplica) : base(serviceContext, stateProviderReplica) { store = new Lazy <KeyValueStoreReplica>(() => stateProviderReplica.StoreReplica); }
public TenantUpdateOrchestratorFE(StatefulServiceContext context) : base(context) { }
public OrderActorService(StatefulServiceContext context, ActorTypeInformation actorTypeInfo, IFileStore fileStore, IServiceEventSource serviceEventSource, Func <ActorService, ActorId, ActorBase> actorFactory = null, Func <ActorBase, IActorStateProvider, IActorStateManager> stateManagerFactory = null, IActorStateProvider stateProvider = null, ActorServiceSettings settings = null) : base(context, actorTypeInfo, fileStore, serviceEventSource, actorFactory, stateManagerFactory, stateProvider, settings) { }
public DataService(StatefulServiceContext context) : base(context) { }
public EventsController(IReliableStateManager stateManager, StatefulServiceContext context, ServiceCancellation serviceCancellation) { this.stateManager = stateManager; this.context = context; this.serviceCancellationToken = serviceCancellation.Token; }
public SampleQueueListeningStatefulService(StatefulServiceContext serviceContext) : base(serviceContext) { }
public BasicChatServer(StatefulServiceContext serviceContext) : base(serviceContext){}
public RouterService(StatefulServiceContext context) : base(context) { }
public FabricClientApplicationOperator(StatefulServiceContext serviceContext) { this.serviceContext = serviceContext; }
public InventoryService(StatefulServiceContext context, IReliableStateManagerReplica stateManagerReplica) : base(context, stateManagerReplica) { }
public CpuBurner(StatefulServiceContext context) : base(context) { }
public TelemetryEnabledActorService(StatefulServiceContext context, ActorTypeInformation actorTypeInfo, Func<ActorBase> actorFactory = null, IActorStateProvider stateProvider = null, ActorServiceSettings settings = null) : base(context, actorTypeInfo, actorFactory, stateProvider, settings) {}
public StatefulService Create(StatefulServiceContext context) { _addServiceContextToLogging?.Invoke(context); return(_serviceFactory(context)); }
public StockAggregatorService(StatefulServiceContext context) : base(context) { }
public Tracker(StatefulServiceContext serviceContext) : base(serviceContext) { }
public RoomActorService(StatefulServiceContext context) : base(context) { float timeoutDebugMultiplier = 10; var builder = new ContainerBuilder(); builder.Register(c => new ProtobufMessageSerializer(typeof(Message).Assembly, typeof(JoinRoom).Assembly, typeof(JoinRoomS2S).Assembly)).As<IMessageSerializer>(); var logger = new LoggerConfiguration() .ConfigureMOUSETypesDestructure() .MinimumLevel.Verbose() .Enrich.With(new AzureServiceFabricSerilogEnricher(Context)) .Enrich.With<ExceptionEnricher>() .WriteTo.Trace() .CreateLogger(); builder.RegisterInstance(logger).As<ILogger>(); builder.RegisterType<SerilogCoreEvents>().As<ICoreEvents>(); builder.RegisterType<SerilogActorCoreEvents>().As<IActorCoreEvents>(); builder.RegisterType<SerilogLidgrenEvents>().As<ILidgrenEvents>(); var roomActorsEndpoint = FabricRuntime.GetActivationContext().GetEndpoint("RoomActors"); var nodeIP = Dns.GetHostAddresses(FabricRuntime.GetNodeContext().IPAddressOrFQDN).First(x => x.AddressFamily == AddressFamily.InterNetwork); var roomActorsNetConfig = new NetPeerConfiguration("RoomActors") { LocalAddress = nodeIP, MaximumConnections = 10000, AcceptIncomingConnections = true, Port = roomActorsEndpoint.Port, ConnectionTimeout = 10 * timeoutDebugMultiplier }; var callbacksNetConfig = new NetPeerConfiguration("Callbacks") { AcceptIncomingConnections = false, ConnectionTimeout = 10 * timeoutDebugMultiplier }; builder.RegisterType<WcfBufferPool>().As<IBufferPool>(); builder.Register(c => new CallbacksGatewayNode("Callbacks", new LidgrenNetProvider(callbacksNetConfig, c.Resolve<ILidgrenEvents>()), c.Resolve<ICoreEvents>(), c.Resolve<IMessageSerializer>(), c.Resolve<INetNodeConfig>(), c.Resolve<IBufferPool>())) .As<ICallbacksGatewayNode>() .As<INetNode>() .SingleInstance(); builder.Register(c => new NetNodeConfig() { SendTimeoutSec = (int)(10.0 * timeoutDebugMultiplier), ConnectTimeoutSec = (int)(10 * timeoutDebugMultiplier) }).As<INetNodeConfig>(); builder.Register(c => new RoomActor(c.Resolve<ICallbacksGatewayNode>(), StateManager)).As<IRoomActor>(); builder.Register(c => new ServiceFabricActorSystemNetNode<IRoomActor>("RoomActors", new Uri("fabric:/ActorChat.ServiceFabric/RoomActorService"), new LidgrenNetProvider(roomActorsNetConfig, c.Resolve<ILidgrenEvents>()), c.Resolve<IActorCoreEvents>(), c.Resolve<ICoreEvents>(), c.Resolve<IMessageSerializer>(), c.Resolve<INetNodeConfig>(), c.Resolve<IBufferPool>(), actorFactory: c.Resolve<Func<IRoomActor>>())) .As<INetNode>() .Named<INetNode>("RoomActors") .As<IActorSystem<IRoomActor>>() .SingleInstance(); var container = builder.Build(); _netNodes = container.Resolve<IEnumerable<INetNode>>(); }
/// <summary> /// Configures to the current context. /// </summary> /// <param name="context"></param> public ConfigSettings(StatefulServiceContext context) { context.CodePackageActivationContext.ConfigurationPackageModifiedEvent += this.CodePackageActivationContext_ConfigurationPackageModifiedEvent; this.UpdateConfigSettings(context.CodePackageActivationContext.GetConfigurationPackageObject("Config").Settings); }
public RestockRequestManagerService(StatefulServiceContext serviceContext) : base(serviceContext) { }
public RunAsyncCancellationTestService(StatefulServiceContext context) : base(context) { }
public RestockRequestManagerService(StatefulServiceContext serviceContext, IReliableStateManagerReplica reliableStateManagerReplica) : base(serviceContext, reliableStateManagerReplica) { }
public SampleSubscriptionListeningStatefulService(StatefulServiceContext serviceContext) : base(serviceContext) { }
public ChaosService(StatefulServiceContext context) : base(context) { }
/// <summary> /// This constructor is used in unit tests to inject a different state manager for unit testing. /// </summary> /// <param name="stateManager"></param> public InventoryService(StatefulServiceContext serviceContext) : this(serviceContext, (new ReliableStateManager(serviceContext))) { }
public StockService(StatefulServiceContext context) : base(context) { }
public MessageHistoryService(StatefulServiceContext context) : base(context) { }
public SmsService(StatefulServiceContext serviceContext, AspNetCoreCommunicationContext communicationContext) : base(serviceContext) { _communicationContext = communicationContext; _semaphore = new SemaphoreSlim(1, 1); }
public EquipmentCatalog(StatefulServiceContext context) : base(context) { }
public RestockRequestManagerService(StatefulServiceContext serviceContext, IReliableStateManagerReplica2 reliableStateManagerReplica) : base(serviceContext, reliableStateManagerReplica) { }
public ProductCatalog(StatefulServiceContext context) : base(context) { }
public ModelManagerService(StatefulServiceContext context) : base(context) { this.logger = CloudLoggerFactory.GetLogger(ServiceEventSource.Current, context); }
public SharedService(StatefulServiceContext context) : base(context) { }
public DBHandlerService(StatefulServiceContext context) : base(context) { }
public static TransportExtensions ApplyCommonConfiguration(this EndpointConfiguration endpointConfiguration, IReliableStateManager stateManager, ServicePartitionInformation partitionInformation, StatefulServiceContext context) { endpointConfiguration.SendFailedMessagesTo("error"); endpointConfiguration.AuditProcessedMessagesTo("audit"); endpointConfiguration.UseSerialization <JsonSerializer>(); endpointConfiguration.EnableInstallers(); var instance = partitionInformation as NamedPartitionInformation; if (instance != null) { endpointConfiguration.RegisterComponents(c => c.RegisterSingleton(instance)); } var information = partitionInformation as Int64RangePartitionInformation; if (information != null) { endpointConfiguration.RegisterComponents(c => c.RegisterSingleton(information)); } var persistence = endpointConfiguration.UsePersistence <ServiceFabricPersistence>(); persistence.StateManager(stateManager); var recoverability = endpointConfiguration.Recoverability(); recoverability.DisableLegacyRetriesSatellite(); // for demo purposes recoverability.Immediate(d => d.NumberOfRetries(0)); recoverability.Delayed(d => d.NumberOfRetries(0)); var configurationPackage = context.CodePackageActivationContext.GetConfigurationPackageObject("Config"); var connectionString = configurationPackage.Settings.Sections["NServiceBus"].Parameters["ConnectionString"]; var transport = endpointConfiguration.UseTransport <AzureServiceBusTransport>(); if (string.IsNullOrWhiteSpace(connectionString.Value)) { throw new Exception("Could not read the 'NServiceBus.ConnectionString'. Check the sample prerequisites."); } transport.ConnectionString(connectionString.Value); transport.UseForwardingTopology(); return(transport); }
public BackEnd(StatefulServiceContext context) : base(context) { }
public Tracker(StatefulServiceContext serviceContext, IReliableStateManagerReplica reliableStateManagerReplica) : base(serviceContext, reliableStateManagerReplica) { }
public UserAuthentication(StatefulServiceContext context) : base(context) { }
public ProductService(StatefulServiceContext context) : base(context) { }
public EarningEventsService(StatefulServiceContext context, IPaymentLogger logger, ILifetimeScope lifetimeScope, IPaymentsEventModelBatchService <EarningEventModel> batchService) : base(context, logger, lifetimeScope, batchService) { }
protected KeyValueStatefulService(StatefulServiceContext serviceContext) : this(serviceContext, new KeyValueStateProvider()) { }
public MockStatefulServiceReplica(Func <StatefulServiceContext, IReliableStateManagerReplica2, TStatefulService> serviceFactory, StatefulServiceContext context, IReliableStateManagerReplica2 stateManager) { _context = context; _stateManager = stateManager; _serviceInstance = serviceFactory.Invoke(context, _stateManager); }
public CheckoutService(StatefulServiceContext context) : base(context) { }
public BadStateful(StatefulServiceContext context) : base(context) { }
public Catalog(StatefulServiceContext context) : base(context) { }
public Processing(StatefulServiceContext context): base(context) { }
/// <summary> /// Creates a new service class instance with the given state manager and service parameters. /// </summary> /// <param name="stateManager"></param> /// <param name="serviceContext"></param> public ApplicationDeployService( IReliableStateManager stateManager, IApplicationOperator applicationOperator, StatefulServiceContext serviceContext) : base(serviceContext, stateManager as IReliableStateManagerReplica) { this.applicationOperator = applicationOperator; }
public MessageBoxService(StatefulServiceContext serviceContext, IReliableStateManagerReplica reliableStateManagerReplica) : base(serviceContext, reliableStateManagerReplica) { }
public SampleSubscriptionListeningStatefulService(StatefulServiceContext serviceContext, IReliableStateManagerReplica reliableStateManagerReplica) : base(serviceContext, reliableStateManagerReplica) { }
public ValidationService(StatefulServiceContext context) : base(context) { }
public MessageBoxService(StatefulServiceContext serviceContext) : base(serviceContext) { }
/// <summary> /// Initializes a new instance of the <see cref="WordCountService"/> class. /// </summary> public WordCountService(StatefulServiceContext context) : base(context) { ServiceEventSource.Current.ServiceInstanceConstructed(ServiceEventSourceName); }