Merge branch 'master' into ryanvolum/dapr

This commit is contained in:
Yaron Schneider 2019-10-10 13:54:40 -07:00 committed by GitHub
commit adc3dc82ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 150 additions and 8 deletions

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
const express = require('express');
const bodyParser = require('body-parser');
require('isomorphic-fetch');

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
const express = require('express');
const bodyParser = require('body-parser');
require('isomorphic-fetch');

View File

@ -1,3 +1,8 @@
# ------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------------------------------
import time
import requests
import os

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
namespace Subtract.Models {
public class Operands {
public string OperandOne { get; set;}

View File

@ -1,4 +1,9 @@
using System;
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

View File

@ -1,4 +1,9 @@
using System;
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

View File

@ -40,7 +40,7 @@ multiplyapp-746588586f-kxpx4 2/2 Running 0 1m
subtractapp-7bbdfd5649-r4pxk 2/2 Running 0 2m
```
6. Next, let's take a look at our services and wait until we have an external IP configured for our front-end: `kubectl get svc -w`
5. Next, let's take a look at our services and wait until we have an external IP configured for our front-end: `kubectl get svc -w`
```bash
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
@ -58,8 +58,15 @@ subtractapp-7bbdfd5649-r4pxk 2/2 Running 0 2m
Each service ending in "-dapr" represents your services respective sidecars, while the `calculator-front-end` service represents the external load balancer for the React calculator front-end.
> **Note:** Minikube users cannot see the external IP. Instead, you can use `minikube service [service_name]` to access loadbalancer without external IP.
7. Take the external IP address for `calculator-front-end` and drop it in your browser and voilà! You have a working distributed calculator!
**For Minikube users**, execute the below command to open calculator on your browser
```
$ minikube service calculator-front-end
```
![Calculator Screenshot](./img/calculator-screenshot.JPG)
8. Open your browser's console window (using F12 key) to see the logs produced as we use the calculator. Note that each time we click a button, we see logs that indicate state persistence:

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
package main
import (

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
const express = require('express');
const bodyParser = require('body-parser');
const app = express();

View File

@ -1,3 +1,8 @@
# ------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------------------------------
import flask
from flask import request, jsonify
from flask_cors import CORS

View File

@ -2,6 +2,8 @@
In this sample, we'll create a publisher microservice and two subscriber microservices to demonstrate how Dapr enables a publish-subcribe pattern. The publisher will generate messages of a specific topic, while subscribers will listen for messages of specific topics. See [Why Pub-Sub](#why-pub-sub) to understand when this pattern might be a good choice for your software architecture.
Visit [this](https://github.com/dapr/docs/tree/master/concepts/publish-subscribe-messaging) link for more information about Dapr and Pub-Sub.
This sample includes one publisher:
- React front-end message generator
@ -109,10 +111,17 @@ Now that we've set up the Redis store, we can deploy our assets.
2. Run `kubectl apply -f .` which will deploy our publisher and two subscriber microservices. It will also apply the redis configuration we set up in the last step.
3. Run `kubectl get pods` to see each pod being provisioned.
4. Run `kubectl get svc -w` to get the external IP exposed by our `react-form` microservice. This may take a minute.
> **Note:** Minikube users cannot see the external IP. Instead, you can use `minikube service [service_name]` to access loadbalancer without external IP.
### Use the Sample
1. Copy the external IP from the last step into your browser and observe the same React form that we saw locally!
**For Minikube users**, execute the below command to open calculator on your browser
```
$ minikube service react-form
```
2. Create and submit messages of different types.
3. To see the logs generated from your subscribers, first run `kubectl get pods` to get the pod names for each subscriber. Then run `kubectl logs <POD NAME> <CONTAINER NAME>`. For example, I can see the logs for my `node-subscriber` service by running:

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
const express = require('express');
const bodyParser = require('body-parser');

View File

@ -1,3 +1,8 @@
# ------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------------------------------
import flask
from flask import request, jsonify
from flask_cors import CORS

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
import React from 'react';
import { MessageForm } from './MessageForm';
import { Nav } from './Nav';

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
import React from 'react';
export class MessageForm extends React.Component {

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
import React from 'react';
export function Nav(){

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
// This optional code is used to register a service worker.
// register() is not called by default.

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
const express = require('express');
const path = require('path');
const request = require('request');

View File

@ -1,3 +1,8 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ------------------------------------------------------------
const express = require('express');
const bodyParser = require('body-parser');
require('isomorphic-fetch');

View File

@ -1,3 +1,8 @@
# ------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------------------------------
import time
import requests
import os

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -4,8 +4,8 @@ This repository contains a series of samples that highlight Dapr capabilities. T
| Sample | Description |
|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [1.hello-world](/1.hello-world) | Demonstrates how to run Dapr locally. Highlights service invocation and state management. |
| [2.hello-kubernetes](/2.hello-kubernetes) | Demonstrates how to run Dapr in Kubernetes. Highlights service invocation and state management. |
| [3.distributed-calculator](/3.distributed-calculator) | Demonstrates a distributed calculator application that uses Dapr services to power a React web app. Highlights polyglot (multi-language) programming, service invocation and state management. |
| [4.pub-sub](4.pub-sub) | Demonstrates how we use Dapr to enable pub-sub applications. Uses Redis as a pub-sub component. |
| [5.bindings](5.bindings) | Demonstrates how we use Dapr to create input and output bindings to other components. Uses bindings to Kafka. |
| [1.hello-world](./1.hello-world) | Demonstrates how to run Dapr locally. Highlights service invocation and state management. |
| [2.hello-kubernetes](./2.hello-kubernetes) | Demonstrates how to run Dapr in Kubernetes. Highlights service invocation and state management. |
| [3.distributed-calculator](./3.distributed-calculator) | Demonstrates a distributed calculator application that uses Dapr services to power a React web app. Highlights polyglot (multi-language) programming, service invocation and state management. |
| [4.pub-sub](./4.pub-sub) | Demonstrates how we use Dapr to enable pub-sub applications. Uses Redis as a pub-sub component. |
| [5.bindings](./5.bindings) | Demonstrates how we use Dapr to create input and output bindings to other components. Uses bindings to Kafka. |