中 | EN
Dapr Starter Core Library
Responsibilities:
Provide core support for Masa.Utils.Development.Dapr.AspNetCore
The start, stop, refresh, and dapr daemon of the dapr process are provided by such libraries
- Install Masa.Utils.Development.Dapr.AspNetCore
Install-Package Masa.Utils.Development.Dapr.AspNetCore
- Add DaprStarter to assist in managing the dapr process (recommended to be used in the development environment)
builder.Services.AddDaprStarterCore();
- Inject IDaprProcess at the specified location as needed, and then call the Start method to start the dapr process or hand it over to Masa.Utils.Development.Dapr.AspNetCore to manage the dapr process. Related documents can be found at View
Example:
New DaprController
public class DaprController : ControllerBase
{
private readonly IDaprProcess _daprProcess;
private readonly DaprOptions _options;
public DaprController(IDaprProcess daprProcess, IOptions<DaprOptions> options)
{
_daprProcess = daprProcess;
_options = options.Value;
}
[HttpGet(Name = "Start")]
public string Start()
{
_daprProcess.Start(_options);
return "start success";
}
[HttpGet(Name = "Stop")]
public string Stop()
{
_daprProcess.Stop();
return "stop success";
}
}
- The netstat command is used in the library, please make sure the netstat command is available
Windows system supports netstat command by default without special installation
Linux and OSX need to confirm by themselves whether netstat is installed on the computer
Open a terminal and enter the following command to confirm that the computer supports the netstat command:
netstat -h
Example: ubuntu:
apt-get install net-tools
- AppId, AppIdSuffix strongly recommend not to enter a string containing ., otherwise it will cause problems with the dapr call. It is recommended to use -
- Dapr AppID follows the FQDN format, which includes the target namespace
- FQDN is spliced with the symbol .
dapr AppId naming rules default:
AppId + "-" + AppIdSuffix
AppId default: Appid.Replace(".","-")
AppIdSuffix default: network card address
When AppIdSuffix is empty, the appid of dapr is equal to AppId