@@ -35,10 +35,10 @@ const serverHost = "127.0.0.1"; // App Host of this Example Server
35
35
const serverPort = " 50051" ; // App Port of this Example Server
36
36
37
37
// HTTP Example
38
- const client = new DaprClient (daprHost , daprPort );
38
+ const client = new DaprClient ({ daprHost , daprPort } );
39
39
40
40
// GRPC Example
41
- const client = new DaprClient (daprHost , daprPort , CommunicationProtocolEnum .GRPC );
41
+ const client = new DaprClient ({ daprHost , daprPort , communicationProtocol: CommunicationProtocolEnum .GRPC } );
42
42
```
43
43
44
44
## Running
@@ -49,7 +49,7 @@ To run the examples, you can use two different protocols to interact with the Da
49
49
50
50
``` typescript
51
51
import { DaprClient } from " @dapr/dapr" ;
52
- const client = new DaprClient (daprHost , daprPort );
52
+ const client = new DaprClient ({ daprHost , daprPort } );
53
53
```
54
54
55
55
``` bash
@@ -66,7 +66,7 @@ Since HTTP is the default, you will have to adapt the communication protocol to
66
66
67
67
``` typescript
68
68
import { DaprClient , CommunicationProtocol } from " @dapr/dapr" ;
69
- const client = new DaprClient (daprHost , daprPort , CommunicationProtocol .GRPC );
69
+ const client = new DaprClient ({ daprHost , daprPort , communicationProtocol: CommunicationProtocol .GRPC } );
70
70
```
71
71
72
72
``` bash
@@ -88,7 +88,12 @@ import { DaprClient, CommunicationProtocol } from "@dapr/dapr";
88
88
89
89
// Allow a body size of 10Mb to be used
90
90
// The default is 4Mb
91
- const client = new DaprClient (daprHost , daprPort , CommunicationProtocol .HTTP , { maxBodySizeMb: 10 });
91
+ const client = new DaprClient ({
92
+ daprHost ,
93
+ daprPort ,
94
+ communicationProtocol: CommunicationProtocol .HTTP ,
95
+ maxBodySizeMb: 10 ,
96
+ });
92
97
```
93
98
94
99
### Proxying Requests
@@ -102,7 +107,7 @@ To perform gRPC proxying, simply create a proxy by calling the `client.proxy.cre
102
107
``` typescript
103
108
// As always, create a client to our dapr sidecar
104
109
// this client takes care of making sure the sidecar is started, that we can communicate, ...
105
- const clientSidecar = new DaprClient (daprHost , daprPort , CommunicationProtocolEnum .GRPC );
110
+ const clientSidecar = new DaprClient ({ daprHost , daprPort , communicationProtocol: CommunicationProtocol .GRPC } );
106
111
107
112
// Create a Proxy that allows us to use our gRPC code
108
113
const clientProxy = await clientSidecar .proxy .create <GreeterClient >(GreeterClient );
@@ -134,7 +139,7 @@ const daprHost = "127.0.0.1";
134
139
const daprPort = " 3500" ;
135
140
136
141
async function start() {
137
- const client = new DaprClient (daprHost , daprPort );
142
+ const client = new DaprClient ({ daprHost , daprPort } );
138
143
139
144
const serviceAppId = " my-app-id" ;
140
145
const serviceMethod = " say-hello" ;
@@ -174,7 +179,7 @@ const daprHost = "127.0.0.1";
174
179
const daprPort = " 3500" ;
175
180
176
181
async function start() {
177
- const client = new DaprClient (daprHost , daprPort );
182
+ const client = new DaprClient ({ daprHost , daprPort } );
178
183
179
184
const serviceStoreName = " my-state-store-name" ;
180
185
@@ -231,7 +236,7 @@ start().catch((e) => {
231
236
import { DaprClient } from " @dapr/dapr" ;
232
237
233
238
async function start() {
234
- const client = new DaprClient (daprHost , daprPort );
239
+ const client = new DaprClient ({ daprHost , daprPort } );
235
240
236
241
const res = await client .state .query (" state-mongodb" , {
237
242
filter: {
@@ -282,7 +287,7 @@ const daprHost = "127.0.0.1";
282
287
const daprPort = " 3500" ;
283
288
284
289
async function start() {
285
- const client = new DaprClient (daprHost , daprPort );
290
+ const client = new DaprClient ({ daprHost , daprPort } );
286
291
287
292
const pubSubName = " my-pubsub-name" ;
288
293
const topic = " topic-a" ;
@@ -355,7 +360,7 @@ const daprHost = "127.0.0.1";
355
360
const daprPort = " 3500" ;
356
361
357
362
async function start() {
358
- const client = new DaprClient (daprHost , daprPort );
363
+ const client = new DaprClient ({ daprHost , daprPort } );
359
364
360
365
const bindingName = " my-binding-name" ;
361
366
const bindingOperation = " create" ;
@@ -383,7 +388,7 @@ const daprHost = "127.0.0.1";
383
388
const daprPort = " 3500" ;
384
389
385
390
async function start() {
386
- const client = new DaprClient (daprHost , daprPort );
391
+ const client = new DaprClient ({ daprHost , daprPort } );
387
392
388
393
const secretStoreName = " my-secret-store" ;
389
394
const secretKey = " secret-key" ;
@@ -414,7 +419,7 @@ const daprHost = "127.0.0.1";
414
419
const daprAppId = " example-config" ;
415
420
416
421
async function start() {
417
- const client = new DaprClient (daprHost , process .env .DAPR_HTTP_PORT );
422
+ const client = new DaprClient ({ daprHost , daprPort: process .env .DAPR_HTTP_PORT } );
418
423
419
424
const config = await client .configuration .get (" config-store" , [" key1" , " key2" ]);
420
425
console .log (config );
@@ -438,7 +443,7 @@ const daprHost = "127.0.0.1";
438
443
const daprPortDefault = " 3500" ;
439
444
440
445
async function start() {
441
- const client = new DaprClient (daprHost , daprPort );
446
+ const client = new DaprClient ({ daprHost , daprPort } );
442
447
443
448
const storeName = " redislock" ;
444
449
const resourceId = " resourceId" ;
0 commit comments