简体   繁体   English

使用 DataPackages 初始化 Service Fabric Actor

[英]Initializing Service Fabric Actors using DataPackages

I am building a proof of concept application using Azure Service Fabric and would like to initialize a few 'demo' user actors in my cluster when it starts up.我正在使用 Azure Service Fabric 构建概念验证应用程序,并希望在我的集群启动时初始化一些“演示”用户角色。 I've found a few brief articles that talk about loading data from a DataPackage , which shows how to load the data itself, but nothing about how to create actors from this data.我找到了一些关于从DataPackage加载数据的简短文章,其中展示了如何加载数据本身,但没有涉及如何从这些数据创建角色。

Can this be done with DataPackages or is there a better way to accomplish this?这可以通过 DataPackages 完成还是有更好的方法来完成?

Data packages are just opaque directories with whatever files you want in there for each deployment.数据包只是不透明的目录,在每个部署中包含您想要的任何文件。 It doesn't load or process the data itself, you have to do all the heavy lifting as only your code knows what the data means.它本身不加载或处理数据,您必须完成所有繁重的工作,因为只有您的代码知道数据的含义。 For example, if you had a data package named "SvcData", it would deploy the files in that package during deployment.例如,如果您有一个名为“SvcData”的数据包,它会在部署期间部署该包中的文件。 If you had a file StaticDataMaster.json in that directory, you'd be able to access it when you service ran (either in your actor, or somewhere else).如果您在该目录中有一个文件 StaticDataMaster.json,那么您将能够在服务运行时(在您的 actor 中或其他地方)访问它。 For example:例如:

// get the data package
var DataPkg = ServiceInitializationParameters.CodePackageActivationContext.
    GetDataPackageObject("SvcData");

// fabric doesn't load data it is just manages for you. data is opaque to Fabric
var customDataFilePath = DataPkg.Path + @"\StaticDataMaster.json";   

// TODO: read customDatafilePath, etc.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM