Skip to content

Commit f8b98ef

Browse files
authored
Merge branch 'master' into master
2 parents be3029e + 37ed498 commit f8b98ef

File tree

22 files changed

+329
-227
lines changed

22 files changed

+329
-227
lines changed

.github/workflows/dapr-bot.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: dapr-bot
2+
3+
on:
4+
issue_comment: {types: created}
5+
6+
jobs:
7+
daprbot:
8+
name: bot-processor
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Comment analyzer
12+
uses: actions/github-script@v1
13+
with:
14+
github-token: ${{secrets.DAPR_BOT_TOKEN}}
15+
script: |
16+
// list of owner who can control dapr-bot workflow
17+
const owners = [
18+
"yaron2",
19+
"berndverst",
20+
"artursouza",
21+
"mukundansundar",
22+
"halspang",
23+
"tanvigour",
24+
"pkedy",
25+
"amulyavarote",
26+
"daixiang0",
27+
"ItalyPaleAle",
28+
"jjcollinge",
29+
"pravinpushkar",
30+
"shivamkm07",
31+
"shubham1172",
32+
"skyao",
33+
"msfussell",
34+
"Taction",
35+
"RyanLettieri",
36+
"DeepanshuA",
37+
"yash-nisar",
38+
"addjuarez",
39+
"tmacam",
40+
];
41+
const payload = context.payload;
42+
const issue = context.issue;
43+
const isFromPulls = !!payload.issue.pull_request;
44+
const commentBody = payload.comment.body;
45+
if (!isFromPulls && commentBody && commentBody.indexOf("/assign") == 0) {
46+
if (!issue.assignees || issue.assignees.length === 0) {
47+
await github.issues.addAssignees({
48+
owner: issue.owner,
49+
repo: issue.repo,
50+
issue_number: issue.number,
51+
assignees: [context.actor],
52+
})
53+
}
54+
return;
55+
}
56+
57+
// actions above this check are enabled for everyone.
58+
if (owners.indexOf(context.actor) < 0) {
59+
return;
60+
}
61+
62+
if (commentBody && commentBody.indexOf("/make-me-laugh") == 0) {
63+
const result = await github.request("https://official-joke-api.appspot.com/random_joke");
64+
jokedata = result.data;
65+
joke = "I have a bad feeling about this.";
66+
if (jokedata && jokedata.setup && jokedata.punchline) {
67+
joke = `${jokedata.setup} - ${jokedata.punchline}`;
68+
}
69+
await github.issues.createComment({
70+
owner: issue.owner,
71+
repo: issue.repo,
72+
issue_number: issue.number,
73+
body: joke,
74+
});
75+
return;
76+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
type: docs
3-
title: "Getting started with the Dapr actors .NET SDK"
3+
title: "Dapr actors .NET SDK"
44
linkTitle: "Actors"
55
weight: 40000
6-
description: How to get up and running with the Dapr .NET SDK
6+
description: Get up and running with the Dapr .NET SDK
77
---
88

9-
The Dapr actor package allows you to interact with Dapr virtual actors from a .NET application.
9+
With the Dapr actor package, you can interact with Dapr virtual actors from a .NET application.
1010

11-
See [How to use Dapr actors]({{< ref dotnet-actors-howto.md >}}) for getting started instructions.
11+
To get started, walk through the [Dapr actors]({{< ref dotnet-actors-howto.md >}}) how-to guide.
Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
---
22
type: docs
3-
title: "Dapr actor .NET usage guide"
3+
title: "The IActorProxyFactory interface"
44
linkTitle: "Actors client"
55
weight: 100000
6-
description: Learn all about using the actor client with the .NET SDK
6+
description: Learn how to create actor clients with the IActorProxyFactory interface
77
---
88

9-
## Using the IActorProxyFactory
9+
Inside of an `Actor` class or an ASP.NET Core project, the `IActorProxyFactory` interface is recommended to create actor clients.
1010

11-
Inside of an `Actor` class or otherwise inside of an ASP.NET Core project you should use the `IActorProxyFactory` interface to create actor clients.
11+
The `AddActors(...)` method will register actor services with ASP.NET Core dependency injection.
1212

13-
The `AddActors(...)` method will register actor services with ASP.NET Core dependency injection.
14-
15-
- Outside of an actor instance, the `IActorProxyFactory` instance is available through dependency injection as a singleton service.
16-
- Inside an actor instance, the `IActorProxyFactory` instance is available as a property (`this.ProxyFactory`).
13+
- **Outside of an actor instance:** The `IActorProxyFactory` instance is available through dependency injection as a singleton service.
14+
- **Inside an actor instance:** The `IActorProxyFactory` instance is available as a property (`this.ProxyFactory`).
1715

1816
The following is an example of creating a proxy inside an actor:
1917

@@ -27,30 +25,35 @@ public Task<MyData> GetDataAsync()
2725
}
2826
```
2927

30-
> 💡 For a non-dependency-injected application you can use the static methods on `ActorProxy`. These methods are error prone when you need to configure custom settings, and should be avoided when possible.
28+
In this guide, you will learn how to use `IActorProxyFactory`.
3129

32-
The guidance in this document will focus on `IActorProxyFactory`. `ActorProxy`'s static method functionality is identical except for the ability to manage configuration centrally.
30+
{{% alert title="Tip" color="primary" %}}
31+
For a non-dependency-injected application, you can use the static methods on `ActorProxy`. Since the `ActorProxy` methods are error prone, try to avoid using them when configuring custom settings.
32+
{{% /alert %}}
3333

3434
## Identifying an actor
3535

36-
In order to communicate with an actor, you will need to know its type and id, and for a strongly-typed client one of its interfaces. All of the APIs on `IActorProxyFactory` will require an actor type and actor id.
36+
All of the APIs on `IActorProxyFactory` will require an actor _type_ and actor _id_ to communicate with an actor. For strongly-typed clients, you also need one of its interfaces.
3737

38-
- The actor type uniquely identifies the actor implementation across the whole application.
39-
- The actor id uniquely identifies an instance of that type.
38+
- **Actor type** uniquely identifies the actor implementation across the whole application.
39+
- **Actor id** uniquely identifies an instance of that type.
4040

41-
If you do not have an actor id and want to communicate with a new instance, you can use `ActorId.CreateRandom()` to create a randomized id. Since the random id is a cryptographically strong identifier, the runtime will create a new actor instance when you interact with it.
41+
If you don't have an actor `id` and want to communicate with a new instance, create a random id with `ActorId.CreateRandom()`. Since the random id is a cryptographically strong identifier, the runtime will create a new actor instance when you interact with it.
4242

43-
You can use the type `ActorReference` to exchange an actor type and actor id with other actors as part of messages.
43+
You can use the type `ActorReference` to exchange an actor type and actor id with other actors as part of messages.
4444

4545
## Two styles of actor client
4646

47-
The actor client supports two different styles of invocation: *strongly-typed* clients that use .NET interfaces and *weakly-typed* clients that use the `ActorProxy` class.
47+
The actor client supports two different styles of invocation:
4848

49-
Since *strongly-typed* clients are based on .NET interfaces provide the typical benefits of strong-typing, however they do not work with non-.NET actors. You should use the *weakly-typed* client only when required for interop or other advanced reasons.
49+
| Actor client style | Description |
50+
| ------------------ | ----------- |
51+
| Strongly-typed | Strongly-typed clients are based on .NET interfaces and provide the typical benefits of strong-typing. They don't work with non-.NET actors. |
52+
| Weakly-typed | Weakly-typed clients use the `ActorProxy` class. It is recommended to use these only when required for interop or other advanced reasons. |
5053

5154
### Using a strongly-typed client
5255

53-
Use the `CreateActorProxy<>` method to create a strongly-typed client like the following example. `CreateActorProxy<>` requires an actor interface type, and will return an instance of that interface.
56+
The following example uses the `CreateActorProxy<>` method to create a strongly-typed client. `CreateActorProxy<>` requires an actor interface type, and will return an instance of that interface.
5457

5558
```csharp
5659
// Create a proxy for IOtherActor to type OtherActor with a random id
@@ -64,7 +67,7 @@ await proxy.DoSomethingGreat();
6467

6568
### Using a weakly-typed client
6669

67-
Use the `Create` method to create a weakly-typed client like the following example. `Create` returns an instance of `ActorProxy`.
70+
The following example uses the `Create` method to create a weakly-typed client. `Create` returns an instance of `ActorProxy`.
6871

6972
```csharp
7073
// Create a proxy for type OtherActor with a random id
@@ -76,9 +79,9 @@ var proxy = this.ProxyFactory.Create(ActorId.CreateRandom(), "OtherActor");
7679
await proxy.InvokeMethodAsync("DoSomethingGreat");
7780
```
7881

79-
Since `ActorProxy` is a weakly-typed proxy you need to pass in the actor method name as a string.
82+
Since `ActorProxy` is a weakly-typed proxy, you need to pass in the actor method name as a string.
8083

81-
You can also use `ActorProxy` to invoke methods with a request message and response message. Request and response messages will be serialized using the `System.Text.Json` serializer.
84+
You can also use `ActorProxy` to invoke methods with both a request and a response message. Request and response messages will be serialized using the `System.Text.Json` serializer.
8285

8386
```csharp
8487
// Create a proxy for type OtherActor with a random id
@@ -91,4 +94,21 @@ var request = new MyRequest() { Message = "Hi, it's me.", };
9194
var response = await proxy.InvokeMethodAsync<MyRequest, MyResponse>("DoSomethingGreat", request);
9295
```
9396

94-
When using a weakly-typed proxy, it is your responsibility to define the correct actor method names and message types. This is done for you when using a strongly-typed proxy since the names and types are part of the interface definition.
97+
When using a weakly-typed proxy, you _must_ proactively define the correct actor method names and message types. When using a strongly-typed proxy, these names and types are defined for you as part of the interface definition.
98+
99+
### Actor method invocation exception details
100+
101+
The actor method invocation exception details are surfaced to the caller and the callee, providing an entry point to track down the issue. Exception details include:
102+
- Method name
103+
- Line number
104+
- Exception type
105+
- UUID
106+
107+
You use the UUID to match the exception on the caller and callee side. Below is an example of exception details:
108+
```
109+
Dapr.Actors.ActorMethodInvocationException: Remote Actor Method Exception, DETAILS: Exception: NotImplementedException, Method Name: ExceptionExample, Line Number: 14, Exception uuid: d291a006-84d5-42c4-b39e-d6300e9ac38b
110+
```
111+
112+
## Next steps
113+
114+
[Learn how to author and run actors with `ActorHost`]({{< ref dotnet-actors-usage.md >}}).

daprdocs/content/en/dotnet-sdk-docs/dotnet-actors/dotnet-actors-howto.md

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
---
22
type: docs
3-
title: "Example of running and using virtual actors in the .NET SDK"
4-
linkTitle: "Example"
3+
title: "How to: Run and use virtual actors in the .NET SDK"
4+
linkTitle: "How to: Run & use virtual actors"
55
weight: 300000
66
description: Try out .NET Dapr virtual actors with this example
77
---
88

9-
The Dapr actor package allows you to interact with Dapr virtual actors from a .NET application.
9+
The Dapr actor package allows you to interact with Dapr virtual actors from a .NET application. In this guide, you learn how to:
1010

11-
## Prerequisites
12-
13-
- [Dapr CLI]({{< ref install-dapr-cli.md >}}) installed
14-
- Initialized [Dapr environment]({{< ref install-dapr-selfhost.md >}})
15-
- [.NET Core 3.1 or .NET 5+](https://dotnet.microsoft.com/download) installed
16-
17-
## Overview
18-
19-
This document describes how to create an Actor (`MyActor`) and invoke its methods on the client application.
11+
- Create an Actor (`MyActor`).
12+
- Invoke its methods on the client application.
2013

2114
```
2215
MyActor --- MyActor.Interfaces
@@ -26,11 +19,33 @@ MyActor --- MyActor.Interfaces
2619
+- MyActorClient
2720
```
2821

29-
* **The interface project(\MyActor\MyActor.Interfaces).** This project contains the interface definition for the actor. Actor interfaces can be defined in any project with any name. The interface defines the actor contract that is shared by the actor implementation and the clients calling the actor. Because client projects may depend on it, it typically makes sense to define it in an assembly that is separate from the actor implementation.
22+
**The interface project (\MyActor\MyActor.Interfaces)**
23+
24+
This project contains the interface definition for the actor. Actor interfaces can be defined in any project with any name. The interface defines the actor contract shared by:
25+
26+
- The actor implementation
27+
- The clients calling the actor
28+
29+
Because client projects may depend on it, it's better to define it in an assembly separate from the actor implementation.
3030

31-
* **The actor service project(\MyActor\MyActorService).** This project implements ASP.Net Core web service that is going to host the actor. It contains the implementation of the actor, MyActor.cs. An actor implementation is a class that derives from the base type Actor and implements the interfaces defined in the MyActor.Interfaces project. An actor class must also implement a constructor that accepts an ActorService instance and an ActorId and passes them to the base Actor class.
31+
**The actor service project (\MyActor\MyActorService)**
32+
33+
This project implements the ASP.Net Core web service that hosts the actor. It contains the implementation of the actor, `MyActor.cs`. An actor implementation is a class that:
34+
35+
- Derives from the base type Actor
36+
- Implements the interfaces defined in the `MyActor.Interfaces` project.
37+
38+
An actor class must also implement a constructor that accepts an `ActorService` instance and an `ActorId`, and passes them to the base Actor class.
39+
40+
**The actor client project (\MyActor\MyActorClient)**
41+
42+
This project contains the implementation of the actor client which calls MyActor's method defined in Actor Interfaces.
43+
44+
## Prerequisites
3245

33-
* **The actor client project(\MyActor\MyActorClient)** This project contains the implementation of the actor client which calls MyActor's method defined in Actor Interfaces.
46+
- [Dapr CLI]({{< ref install-dapr-cli.md >}}) installed.
47+
- Initialized [Dapr environment]({{< ref install-dapr-selfhost.md >}}).
48+
- [.NET Core 3.1 or .NET 6+](https://dotnet.microsoft.com/download) installed. Dapr .NET SDK uses [ASP.NET Core](https://docs.microsoft.com/aspnet/core/introduction-to-aspnet-core?view=aspnetcore-6.0).
3449

3550
## Step 0: Prepare
3651

@@ -42,9 +57,9 @@ Actor interface defines the actor contract that is shared by the actor implement
4257

4358
Actor interface is defined with the below requirements:
4459

45-
* Actor interface must inherit `Dapr.Actors.IActor` interface
46-
* The return type of Actor method must be `Task` or `Task<object>`
47-
* Actor method can have one argument at a maximum
60+
- Actor interface must inherit `Dapr.Actors.IActor` interface
61+
- The return type of Actor method must be `Task` or `Task<object>`
62+
- Actor method can have one argument at a maximum
4863

4964
### Create interface project and add dependencies
5065

0 commit comments

Comments
 (0)