Updating get started and samples readme (#70)

* Updating actors get started.

* Updating .netcore version in prereq

* REmoving specific versions of nugets from doc

* Updating samples readme.md to use dapr

* Updating sample docs

* Updating samples readme.

* renaming action to dapr
This commit is contained in:
Aman Bhardwaj 2019-10-07 19:14:29 +00:00 committed by GitHub
parent 61f6e7d681
commit a0e1b3963c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 23 deletions

View File

@ -1,7 +1,7 @@
# Getting started with Actors
## Prerequistes
* [.Net Core SDK 2.2](https://dotnet.microsoft.com/download)
* [.Net Core SDK 3.0](https://dotnet.microsoft.com/download)
* [Dapr CLI](https://github.com/dapr/cli)
* [Dapr DotNet SDK](https://github.com/dapr/dotnet-sdk)
@ -41,7 +41,7 @@ Actor interface is defined with the below requirements:
dotnet new classlib -o MyActor.Interfaces
# Add Microsoft.Dapr.Actors nuget package
dotnet add package Microsoft.Dapr.Actors -v 0.3.0-preview01 -s ~/tmp/nugets/
dotnet add package Microsoft.Dapr.Actors
```
### Implement IMyActor Interface
@ -55,11 +55,9 @@ using System.Threading.Tasks;
namespace MyActor.Interfaces
{
public interface IMyActor : IActor
{
// Return Type must be `Task` or Task<T>.
// Arguments and return type must be Datacontract serializable when making actor method calls using Remoting.
Task<string> SetMyDataAsync(MyData data);
Task<MyData> GetMyDataAsync();
{
Task<string> SetDataAsync(MyData data);
Task<MyData> GetDataAsync();
Task RegisterReminder();
Task UnregisterReminder();
Task RegisterTimer();
@ -94,10 +92,10 @@ dotnet new webapi -o MyActor
cd MyActor
# Add Microsoft.Dapr.Actors nuget package
dotnet add package Microsoft.Dapr.Actors -v 0.3.0-preview01 -s ~/tmp/nugets/
dotnet add package Microsoft.Dapr.Actors
# Add Microsoft.Dapr.Actors.AspNetCore nuget package
dotnet add package Microsoft.Dapr.Actors.AspNetCore -v 0.3.0-preview01 -s ~/tmp/nugets/
dotnet add package Microsoft.Dapr.Actors.AspNetCore
# Add Actor Interface reference
dotnet add reference ../MyActor.Interfaces/MyActor.Interfaces.csproj
@ -153,7 +151,7 @@ namespace MyActorService
/// Set MyData into actor's private state store
/// </summary>
/// <param name="data">the user-defined MyData which will be stored into state store as "my_data" state</param>
public async Task<string> SetMyDataAsync(MyData data)
public async Task<string> SetDataAsync(MyData data)
{
// Data is saved to configured state store implicitly after each method execution by Actor's runtime.
// Data can also be saved explicitly by calling this.StateManager.SaveStateAsync();
@ -169,7 +167,7 @@ namespace MyActorService
/// Get MyData from actor's private state store
/// </summary>
/// <return>the user-defined MyData which is stored into state store as "my_data" state</return>
public Task<MyData> GetMyDataAsync()
public Task<MyData> GetDataAsync()
{
// Gets state from the state store.
return this.StateManager.GetStateAsync<MyData>("my_data");
@ -271,7 +269,7 @@ dotnet new console -o MyActorClient
cd MyActorClient
# Add Microsoft.Dapr.Actors nuget package
dotnet add package Microsoft.Dapr.Actors -v 0.3.0-preview01 -s ~/tmp/nugets/
dotnet add package Microsoft.Dapr.Actors
# Add Actor Interface reference
dotnet add reference ../MyActor.Interfaces/MyActor.Interfaces.csproj
@ -299,14 +297,14 @@ namespace MyActorClient
// Create the local proxy by using the same interface that the service implements
// By using this proxy, you can call strongly typed methods on the interface using Remoting.
var proxy = ActorProxy.Create<IMyActor>(actorID, actorType);
var response = await proxy.SetMyDataAsync(new MyData()
var response = await proxy.SetDataAsync(new MyData()
{
PropertyA = "ValueA",
PropertyB = "ValueB",
});
Console.WriteLine(response);
var savedData = await proxy.GetMyDataAsync();
var savedData = await proxy.GetDataAsync();
Console.WriteLine(savedData);
}
...
@ -367,7 +365,7 @@ In order to validate and debug actor service and client, we need to run actor se
INFO[0000] starting Dapr Runtime -- version -- commit
INFO[0000] log level set to: info
INFO[0000] standalone mode configured
INFO[0000] action id: myapp
INFO[0000] dapr id: myapp
INFO[0000] loaded component statestore (state.redis)
INFO[0000] application protocol: http. waiting on port 3000
INFO[0000] application discovered on port 3000

View File

@ -13,7 +13,7 @@ The application also registers for pub-sub with the `deposit` and `withdraw` top
To run the sample locally run this comment in this directory:
```sh
actions run --app-id routing --app-port 5000 dotnet run
dapr run --app-id routing --app-port 5000 dotnet run
```
The application will listen on port 5000 for HTTP.
@ -48,7 +48,7 @@ curl -X POST http://localhost:5000/withdraw \
---
**Deposit Money**
**Get Balance**
```sh
curl http://localhost:5000/17
@ -63,7 +63,7 @@ curl http://localhost:5000/17
**Withdraw Money (pubsub)**
```sh
actions publish -t withdraw -p '{"id": "17", "amount": 15 }'
dapr publish -t withdraw -p '{"id": "17", "amount": 15 }'
```
---
@ -71,7 +71,7 @@ actions publish -t withdraw -p '{"id": "17", "amount": 15 }'
**Deposit Money (pubsub)**
```sh
actions publish -t deposit -p '{"id": "17", "amount": 15 }'
dapr publish -t deposit -p '{"id": "17", "amount": 15 }'
```
---

View File

@ -13,7 +13,7 @@ The application also registers for pub-sub with the `deposit` and `withdraw` top
To run the sample locally run this comment in this directory:
```sh
actions run --app-id routing --app-port 5000 dotnet run
dapr run --app-id routing --app-port 5000 dotnet run
```
The application will listen on port 5000 for HTTP.
@ -48,7 +48,7 @@ curl -X POST http://localhost:5000/withdraw \
---
**Deposit Money**
**Get Balance**
```sh
curl http://localhost:5000/17
@ -63,7 +63,7 @@ curl http://localhost:5000/17
**Withdraw Money (pubsub)**
```sh
actions publish -t withdraw -p '{"id": "17", "amount": 15 }'
dapr publish -t withdraw -p '{"id": "17", "amount": 15 }'
```
---
@ -71,7 +71,7 @@ actions publish -t withdraw -p '{"id": "17", "amount": 15 }'
**Deposit Money (pubsub)**
```sh
actions publish -t deposit -p '{"id": "17", "amount": 15 }'
dapr publish -t deposit -p '{"id": "17", "amount": 15 }'
```
---