@@ -37,43 +37,45 @@ async function start() {
37
37
console . log ( "EXECUTING CLIENT - ACTORS" ) ;
38
38
console . log ( "Note: we create new client for now since Actors are not supported internally!" )
39
39
console . log ( "===============================================================" ) ;
40
+ const actorId = "MyActorId1" ;
40
41
41
42
42
43
const resRegisteredActors = await server . actor . getRegisteredActors ( ) ;
43
44
console . log ( `Registered Actor Types: ${ JSON . stringify ( resRegisteredActors ) } ` ) ;
44
-
45
- // console.log("[Dapr-JS][Example][Actors] Trying to invoke method 'say' with msg 'hello world'");
46
- // const resActorInvokeSay = await client.actor.invoke("PUT", DemoActorSayImpl.name, "MyActorId1", "say", "Hello World");
47
- // console.log(`[Dapr-JS][Example][Actors] Invoked Method and got data: ${resActorInvokeSay}`);
48
45
49
- // const resActorStateGet = await clientActor.actor.stateGet("DemoActor", "MyActorId1", "PropertyA");
50
- // await clientActor.actor.stateTransaction("DemoActor", "MyActorId1", [
51
- // {
52
- // operation: "upsert",
53
- // request: {
54
- // key: "key-1",
55
- // value: "my-new-data-1"
56
- // }
57
- // },
58
- // {
59
- // operation: "upsert",
60
- // request: {
61
- // key: "key-to-delete",
62
- // value: "my-new-data-1"
63
- // }
64
- // },
65
- // {
66
- // operation: "delete",
67
- // request: {
68
- // key: "key-to-delete"
69
- // }
70
- // }
71
- // ]);
46
+ console . log ( "[Dapr-JS][Example][Actors] Trying to invoke method 'say' with msg 'hello world'" ) ;
47
+ const resActorInvokeSay = await client . actor . invoke ( "PUT" , DemoActorSayImpl . name , actorId , "sayString" , "Hello World" ) ;
48
+ console . log ( `[Dapr-JS][Example][Actors] Invoked Method and got data: ${ resActorInvokeSay } ` ) ;
72
49
73
- // const resActorStateGet = await clientActor.actor.stateGet("DemoActor", "MyActorId1", "key-to-delete");
74
- // console.log(`[Dapr-JS][Example][Actors] Get State (should be empty): ${JSON.stringify(resActorStateGet)}`);
75
- // const resActorStateGet2 = await clientActor.actor.stateGet("DemoActor", "MyActorId1", "key-1");
76
- // console.log(`[Dapr-JS][Example][Actors] Get State (should be my-new-data-1): ${JSON.stringify(resActorStateGet2)}`);
50
+ let resActorStateGet = await client . actor . stateGet ( DemoActorSayImpl . name , actorId , "PropertyA" ) ;
51
+ await client . actor . stateTransaction ( DemoActorSayImpl . name , actorId , [
52
+ {
53
+ operation : "upsert" ,
54
+ request : {
55
+ key : "key-1" ,
56
+ value : "my-new-data-1"
57
+ }
58
+ } ,
59
+ {
60
+ operation : "upsert" ,
61
+ request : {
62
+ key : "key-to-delete" ,
63
+ value : "my-new-data-1"
64
+ }
65
+ } ,
66
+ {
67
+ operation : "delete" ,
68
+ request : {
69
+ key : "key-to-delete"
70
+ }
71
+ }
72
+ ] ) ;
73
+
74
+ resActorStateGet = await client . actor . stateGet ( DemoActorSayImpl . name , actorId , "key-to-delete" ) ;
75
+ console . log ( `[Dapr-JS][Example][Actors] Get State (should be empty): ${ JSON . stringify ( resActorStateGet ) } ` ) ;
76
+
77
+ const resActorStateGet2 = await client . actor . stateGet ( DemoActorSayImpl . name , actorId , "key-1" ) ;
78
+ console . log ( `[Dapr-JS][Example][Actors] Get State (should be my-new-data-1): ${ JSON . stringify ( resActorStateGet2 ) } ` ) ;
77
79
}
78
80
79
81
start ( ) . catch ( ( e ) => {
0 commit comments