mirror of https://github.com/dapr/quickstarts.git
Fixed a bunch of typoes
Signed-off-by: Bilgin Ibryam <bibryam@gmail.com>
This commit is contained in:
parent
bd31cf7d62
commit
cffc3eb02b
|
@ -68,7 +68,7 @@ dapr run -f .
|
||||||
4. Stop Dapr workflow with CTRL-C or:
|
4. Stop Dapr workflow with CTRL-C or:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
dapr stop -f .
|
dapr stop -f .
|
||||||
```
|
```
|
||||||
|
|
||||||
### View workflow output with Zipkin
|
### View workflow output with Zipkin
|
||||||
|
@ -83,11 +83,11 @@ launched on running `dapr init`.
|
||||||
|
|
||||||
### What happened?
|
### What happened?
|
||||||
|
|
||||||
When you ran the above comands:
|
When you ran the above commands:
|
||||||
|
|
||||||
1. An OrderPayload is made containing one car.
|
1. An OrderPayload is made containing one car.
|
||||||
2. A unique order ID for the workflow is generated (in the above example, `b4cb2687-1af0-4f8d-9659-eb6389c07ade`) and the workflow is scheduled.
|
2. A unique order ID for the workflow is generated (in the above example, `b4cb2687-1af0-4f8d-9659-eb6389c07ade`) and the workflow is scheduled.
|
||||||
3. The `NotifyActivity` workflow activity sends a notification saying an order for 10 cars has been received.
|
3. The `NotifyActivity` workflow activity sends a notification saying an order for 1 car has been received.
|
||||||
4. The `VerifyInventoryActivity` workflow activity checks the inventory data, determines if you can supply the ordered item, and responds with the number of cars in stock.
|
4. The `VerifyInventoryActivity` workflow activity checks the inventory data, determines if you can supply the ordered item, and responds with the number of cars in stock.
|
||||||
5. The total cost of the order is 5000, so the workflow will not call the `RequestApprovalActivity` activity.
|
5. The total cost of the order is 5000, so the workflow will not call the `RequestApprovalActivity` activity.
|
||||||
6. The `ProcessPaymentActivity` workflow activity begins processing payment for order `b4cb2687-1af0-4f8d-9659-eb6389c07ade` and confirms if successful.
|
6. The `ProcessPaymentActivity` workflow activity begins processing payment for order `b4cb2687-1af0-4f8d-9659-eb6389c07ade` and confirms if successful.
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
type OrderPayload struct {
|
type OrderPayload struct {
|
||||||
ItemName string `json:"item_name"`
|
ItemName string `json:"item_name"`
|
||||||
TotalCost int `json:"total_cost"`
|
TotalCost int `json:"total_cost"`
|
||||||
Quantity int `json:"quanity"`
|
Quantity int `json:"quantity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderResult struct {
|
type OrderResult struct {
|
||||||
|
@ -13,13 +13,13 @@ type OrderResult struct {
|
||||||
type InventoryItem struct {
|
type InventoryItem struct {
|
||||||
ItemName string `json:"item_name"`
|
ItemName string `json:"item_name"`
|
||||||
PerItemCost int `json:"per_item_cost"`
|
PerItemCost int `json:"per_item_cost"`
|
||||||
Quantity int `json:"quanity"`
|
Quantity int `json:"quantity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InventoryRequest struct {
|
type InventoryRequest struct {
|
||||||
RequestID string `json:"request_id"`
|
RequestID string `json:"request_id"`
|
||||||
ItemName string `json:"item_name"`
|
ItemName string `json:"item_name"`
|
||||||
Quantity int `json:"quanity"`
|
Quantity int `json:"quantity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InventoryResult struct {
|
type InventoryResult struct {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.dapr.quickstarts.workflows;
|
package io.dapr.quickstarts.workflows;
|
||||||
|
@ -73,22 +73,22 @@ public class WorkflowConsoleApp {
|
||||||
System.out.println("==========Begin the purchase of item:==========");
|
System.out.println("==========Begin the purchase of item:==========");
|
||||||
String itemName = inventory.getName();
|
String itemName = inventory.getName();
|
||||||
int orderQuantity = inventory.getQuantity();
|
int orderQuantity = inventory.getQuantity();
|
||||||
int totalcost = orderQuantity * inventory.getPerItemCost();
|
int totalCost = orderQuantity * inventory.getPerItemCost();
|
||||||
OrderPayload order = new OrderPayload();
|
OrderPayload order = new OrderPayload();
|
||||||
order.setItemName(itemName);
|
order.setItemName(itemName);
|
||||||
order.setQuantity(orderQuantity);
|
order.setQuantity(orderQuantity);
|
||||||
order.setTotalCost(totalcost);
|
order.setTotalCost(totalCost);
|
||||||
System.out.println("Starting order workflow, purchasing " + orderQuantity + " of " + itemName);
|
System.out.println("Starting order workflow, purchasing " + orderQuantity + " of " + itemName);
|
||||||
|
|
||||||
String instanceId = workflowClient.scheduleNewWorkflow(OrderProcessingWorkflow.class, order);
|
String instanceId = workflowClient.scheduleNewWorkflow(OrderProcessingWorkflow.class, order);
|
||||||
System.out.printf("scheduled new workflow instance of OrderProcessingWorkflow with instance ID: %s%n",
|
System.out.printf("Scheduled new workflow instance of OrderProcessingWorkflow with instance ID: %s%n",
|
||||||
instanceId);
|
instanceId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
workflowClient.waitForInstanceStart(instanceId, Duration.ofSeconds(10), false);
|
workflowClient.waitForInstanceStart(instanceId, Duration.ofSeconds(10), false);
|
||||||
System.out.printf("workflow instance %s started%n", instanceId);
|
System.out.printf("Workflow instance %s started%n", instanceId);
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
System.out.printf("workflow instance %s did not start within 10 seconds%n", instanceId);
|
System.out.printf("Workflow instance %s did not start within 10 seconds%n", instanceId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,13 +97,13 @@ public class WorkflowConsoleApp {
|
||||||
Duration.ofSeconds(30),
|
Duration.ofSeconds(30),
|
||||||
true);
|
true);
|
||||||
if (workflowStatus != null) {
|
if (workflowStatus != null) {
|
||||||
System.out.printf("workflow instance completed, out is: %s%n",
|
System.out.printf("Workflow instance completed, out is: %s%n",
|
||||||
workflowStatus.getSerializedOutput());
|
workflowStatus.getSerializedOutput());
|
||||||
} else {
|
} else {
|
||||||
System.out.printf("workflow instance %s not found%n", instanceId);
|
System.out.printf("Workflow instance %s not found%n", instanceId);
|
||||||
}
|
}
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
System.out.printf("workflow instance %s did not complete within 30 seconds%n", instanceId);
|
System.out.printf("Workflow instance %s did not complete within 30 seconds%n", instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -112,12 +112,12 @@ public class WorkflowConsoleApp {
|
||||||
// prepare 10 cars in inventory
|
// prepare 10 cars in inventory
|
||||||
InventoryItem inventory = new InventoryItem();
|
InventoryItem inventory = new InventoryItem();
|
||||||
inventory.setName("cars");
|
inventory.setName("cars");
|
||||||
inventory.setPerItemCost(50000);
|
inventory.setPerItemCost(5000);
|
||||||
inventory.setQuantity(10);
|
inventory.setQuantity(10);
|
||||||
DaprClient daprClient = new DaprClientBuilder().build();
|
DaprClient daprClient = new DaprClientBuilder().build();
|
||||||
restockInventory(daprClient, inventory);
|
restockInventory(daprClient, inventory);
|
||||||
|
|
||||||
// prepare order for 10 cars
|
// prepare order for 1 car
|
||||||
InventoryItem order = new InventoryItem();
|
InventoryItem order = new InventoryItem();
|
||||||
order.setName("cars");
|
order.setName("cars");
|
||||||
order.setPerItemCost(5000);
|
order.setPerItemCost(5000);
|
||||||
|
|
|
@ -127,7 +127,7 @@ export const orderProcessingWorkflow: TWorkflow = async function* (ctx: Workflow
|
||||||
}
|
}
|
||||||
|
|
||||||
const orderCompletedNotification: OrderNotification = {
|
const orderCompletedNotification: OrderNotification = {
|
||||||
message: `order ${orderId} processed successfully!`,
|
message: `Order ${orderId} processed successfully!`,
|
||||||
};
|
};
|
||||||
yield ctx.callActivity(notifyActivity, orderCompletedNotification);
|
yield ctx.callActivity(notifyActivity, orderCompletedNotification);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue