You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The below code examples loosely describe the scenario of a Parking Garage Spot Monitoring System, which can be explained in detail by Mark Russinovich in [this video](https://www.youtube.com/watch?v=eJCu6a-x9uo&t=3785). The parking garage consists of hundreds of parking spots, where each parking spot includes a sensor that provides updates to a centralized monitoring system. The parking space sensors (our actors) detect if a parking space is occupied, or available.
19
+
## Scenario
20
+
The below code examples loosely describe the scenario of a Parking Garage Spot Monitoring System, which can be seen in this [video by Mark Russinovich](https://www.youtube.com/watch?v=eJCu6a-x9uo&t=3785).
21
21
22
-
To run this example, source code can be found [here](https://github.com/XavierGeerinck/js-sdk/tree/23e1f0ee2bd4c60a4906e38427547c4b3840f89e/examples/http/actor-parking-sensor).
22
+
A parking garage consists of hundreds of parking spots, where each parking spot includes a sensor that provides updates to a centralized monitoring system. The parking space sensors (our actors) detect if a parking space is occupied, or available.
23
+
24
+
To jump in and run this example for yourself, the source code can be found in the [JavaScript SDK examples directory](https://github.com/dapr/js-sdk/tree/master/examples/http/actor-parking-sensor).
23
25
24
26
## Actor Interface
25
-
The actor interface defines the contract that is shared between the actor implementation and the clients calling the actor. In the example below, we have created an interace for a parking garage sensor. Each sensor has 2 methods: carEnter and carLeave, which defines the state of the sensor:
27
+
The actor interface defines the contract that is shared between the actor implementation and the clients calling the actor. In the example below, we have created an interace for a parking garage sensor. Each sensor has 2 methods: carEnter and carLeave, which defines the state of the parking space:
An actor implementation defines a class by extending the base type `AbstractActor` and implements the interfaces defined in the actor interface. The example below implements the methods defined in the `ParkingSensorInterface`, but also adds extra helper methods:
37
+
An actor implementation defines a class by extending the base type `AbstractActor` and implements the interfaces defined in the actor interface. The following code describes what an actor implmentation consists of by implementing the methods defined in the `ParkingSensorInterface`. It also defines a few extra helper methods:
36
38
37
39
```javascript
38
40
import { AbstractActor } from"dapr-client";
@@ -75,45 +77,48 @@ async function start() {
75
77
awaitserver.actor.init(); // Let the server know we need actors
76
78
server.actor.registerActor(ParkingSensorImpl); // Register the actor
77
79
awaitserver.startServer(); // Start the server
80
+
}
78
81
```
79
82
80
83
## Invoking Actors
81
84
After Actors are registered, use the DaprClient to invoke methods on an actor. The client will call the actor methods defined in the actor interface.
0 commit comments