@@ -39,9 +39,17 @@ const server = new DaprServer(serverHost, serverPort, daprHost, daprPort, Commun
39
39
const client = new DaprClient (daprHost, daprPort, CommunicationProtocolEnum .GRPC );
40
40
```
41
41
42
- ## Running using HTTP or gRPC
42
+ ## Running
43
43
44
- By default, the example uses HTTP. To run:
44
+ To run the examples, you can use two different protocols to interact with the Dapr sidecar: HTTP (default) or gRPC.
45
+
46
+ ### Using HTTP (default)
47
+
48
+ ``` javascript
49
+ import { DaprClient , DaprServer } from " dapr-client" ;
50
+ const client = new DaprClient (daprHost, daprPort);
51
+ const server = new DaprServer (appHost, appPort, daprHost, daprPort);
52
+ ```
45
53
46
54
``` bash
47
55
# Using dapr run
@@ -51,23 +59,23 @@ dapr run --app-id <example-sdk> --app-port 50051 --app-protocol http npm run sta
51
59
npm run start:dapr-http
52
60
```
53
61
54
- To use gRPC instead:
55
-
56
- - Add ` CommunicationProtocolEnum.GRPC ` to the DaprClient object creation:
62
+ ### Using gRPC
57
63
58
- ``` javascript
59
- const client = new DaprClient (daprHost, process .env .DAPR_HTTP_PORT , CommunicationProtocolEnum .GRPC );
60
- ```
64
+ Since HTTP is the default, you will have to adapt the communication protocol to use gRPC. You can do this by passing an extra argument to the client or server constructor.
61
65
62
- - To run:
66
+ ``` javascript
67
+ import { DaprClient , DaprServer , CommunicationProtocol } from " dapr-client" ;
68
+ const client = new DaprClient (daprHost, daprPort, CommunicationProtocol .GRPC );
69
+ const server = new DaprServer (appHost, appPort, daprHost, daprPort, CommunicationProtocol .GRPC );
70
+ ```
63
71
64
- ``` bash
65
- # Using dapr run
66
- dapr run --app-id < example-sdk> --app-port 50051 --app-protocol grpc npm run start
72
+ ``` bash
73
+ # Using dapr run
74
+ dapr run --app-id < example-sdk> --app-port 50051 --app-protocol grpc npm run start
67
75
68
- # or, using npm script
69
- npm run start:dapr-grpc
70
- ```
76
+ # or, using npm script
77
+ npm run start:dapr-grpc
78
+ ```
71
79
72
80
### DaprClient Library
73
81
A library that provides methods for how an application communicates with the Dapr sidecar.
0 commit comments