mirror of https://github.com/dapr/docs.git
Add missing snippets in quickstarts section
Signed-off-by: Wralith <wralithdev@gmail.com>
This commit is contained in:
parent
401ff35e94
commit
59b9621a49
|
|
@ -273,7 +273,7 @@ dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 --resources
|
||||||
In the `checkout` publisher service, we're publishing the orderId message to the Redis instance called `orderpubsub` [(as defined in the `pubsub.yaml` component)]({{< ref "#pubsubyaml-component-file" >}}) and topic `orders`. As soon as the service starts, it publishes in a loop:
|
In the `checkout` publisher service, we're publishing the orderId message to the Redis instance called `orderpubsub` [(as defined in the `pubsub.yaml` component)]({{< ref "#pubsubyaml-component-file" >}}) and topic `orders`. As soon as the service starts, it publishes in a loop:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const client = new DaprClient(DAPR_HOST, DAPR_HTTP_PORT);
|
const client = new DaprClient({ daprHost, daprPort });
|
||||||
|
|
||||||
await client.pubsub.publish(PUBSUB_NAME, PUBSUB_TOPIC, order);
|
await client.pubsub.publish(PUBSUB_NAME, PUBSUB_TOPIC, order);
|
||||||
console.log("Published data: " + JSON.stringify(order));
|
console.log("Published data: " + JSON.stringify(order));
|
||||||
|
|
|
||||||
|
|
@ -177,29 +177,19 @@ dapr run --app-id order-processor --resources-path ../../../resources/ -- npm ru
|
||||||
The `order-processor` service writes, reads, and deletes an `orderId` key/value pair to the `statestore` instance [defined in the `statestore.yaml` component]({{< ref "#statestoreyaml-component-file" >}}). As soon as the service starts, it performs a loop.
|
The `order-processor` service writes, reads, and deletes an `orderId` key/value pair to the `statestore` instance [defined in the `statestore.yaml` component]({{< ref "#statestoreyaml-component-file" >}}). As soon as the service starts, it performs a loop.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const client = new DaprClient(DAPR_HOST, DAPR_HTTP_PORT);
|
const client = new DaprClient({ daprHost, daprPort, communicationProtocol })
|
||||||
|
|
||||||
// Save state into the state store
|
// Save state into a state store
|
||||||
client.state.save(STATE_STORE_NAME, [
|
await client.state.save(DAPR_STATE_STORE_NAME, state)
|
||||||
{
|
console.log("Saving Order: ", order)
|
||||||
key: orderId.toString(),
|
|
||||||
value: order
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
console.log("Saving Order: ", order);
|
|
||||||
|
|
||||||
// Get state from the state store
|
// Get state from a state store
|
||||||
var result = client.state.get(STATE_STORE_NAME, orderId.toString());
|
const savedOrder = await client.state.get(DAPR_STATE_STORE_NAME, order.orderId)
|
||||||
result.then(function(val) {
|
console.log("Getting Order: ", savedOrd
|
||||||
console.log("Getting Order: ", val);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Delete state from the state store
|
|
||||||
client.state.delete(STATE_STORE_NAME, orderId.toString());
|
|
||||||
result.then(function(val) {
|
|
||||||
console.log("Deleting Order: ", val);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// Delete state from the state store
|
||||||
|
await client.state.delete(DAPR_STATE_STORE_NAME, order.orderId)
|
||||||
|
console.log("Deleting Order: ", order)
|
||||||
```
|
```
|
||||||
### Step 3: View the order-processor outputs
|
### Step 3: View the order-processor outputs
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue