public void RegisterOnMemberUp() { Console.WriteLine(cluster.SelfAddress + "上线....."); var sharding = ClusterSharding.Get(actorSystem); var shardRegion = sharding.Start( typeName: "fzf003", entityProps: ProductMasterActor.PropsFor(), settings: ClusterShardingSettings.Create(actorSystem), messageExtractor: new MessageExtractor(10)); }
public void ConfigureServices(IServiceCollection services) { services.AddAkkaService("app.conf", false) .AddHostedService <Worker>() .AddHostedService <AkkaHostedService>() .AddActorReference <ResponseActor>(ResponseActor.PropsFor()) .AddActorReference <ProductMasterActor>(ProductMasterActor.PropsFor()); /* services.AddHealthChecksUI().AddInMemoryStorage(); * services.AddHealthChecks() * .AddSqlServer(connectionString: Configuration["ConnectionStrings:Default"]); * //.AddRedis($"{Configuration["Redis:Host"]},password={Configuration["Redis:Password"]}"); */ services.AddTransient <IProductRepository, ProductRepository>(); services.AddTransient <IProductService, ProductService>(); services.AddControllers(); services.AddDbContext <ProductContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("Defalut"), b => { b.EnableRetryOnFailure(); }); }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Product API", Version = "v1" }); c.SwaggerDoc("v2", new OpenApiInfo { Title = "Product API-V2", Version = "v2" }); }); services.AddLogging(cfg => cfg.AddConsole()); }