Skip to content

Commit

Permalink
Merge branch 'master' into multi-app-run
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Yuknewicz <[email protected]>
  • Loading branch information
paulyuk authored Sep 22, 2023
2 parents dbe603d + e278ba4 commit 6445c2e
Show file tree
Hide file tree
Showing 22 changed files with 78 additions and 64 deletions.
6 changes: 6 additions & 0 deletions .github/holopin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
organization: dapr
defaultSticker: clmjkxscc122740fl0mkmb7egi
stickers:
-
id: clmjkxscc122740fl0mkmb7egi
alias: ghc2023
2 changes: 2 additions & 0 deletions bindings/components/binding-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ spec:
metadata:
- name: schedule
value: "@every 10s" # valid cron schedule
- name: direction
value: "input"
2 changes: 2 additions & 0 deletions bindings/components/binding-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ spec:
metadata:
- name: url # Required
value: "user=postgres password=docker host=localhost port=5432 dbname=orders pool_min_conns=1 pool_max_conns=10"
- name: direction
value: "output"
4 changes: 2 additions & 2 deletions bindings/go/http/batch/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dapr run --app-id batch-http --app-port 6003 --dapr-http-port 3503 --dapr-grpc-p
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -56,7 +56,7 @@ func processBatch(w http.ResponseWriter, r *http.Request) {

defer fileContent.Close()

byteResult, _ := ioutil.ReadAll(fileContent)
byteResult, _ := io.ReadAll(fileContent)

var orders Orders

Expand Down
4 changes: 2 additions & 2 deletions bindings/go/sdk/batch/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -57,7 +57,7 @@ func processBatch(w http.ResponseWriter, r *http.Request) {

defer fileContent.Close()

byteResult, _ := ioutil.ReadAll(fileContent)
byteResult, _ := io.ReadAll(fileContent)

var orders Orders

Expand Down
10 changes: 5 additions & 5 deletions configuration/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -39,7 +39,7 @@ func main() {
fmt.Print("Could not get config item, err:" + err.Error())
os.Exit(1)
}
result, _ := ioutil.ReadAll(getResponse.Body)
result, _ := io.ReadAll(getResponse.Body)
fmt.Println("Configuration for "+item+":", string(result))
}

Expand Down Expand Up @@ -69,7 +69,7 @@ func subscribeToConfigUpdates(subscriptionId *string) {
fmt.Println("Error subscribing to config updates, err:" + err.Error())
os.Exit(1)
}
sub, err := ioutil.ReadAll(subscription.Body)
sub, err := io.ReadAll(subscription.Body)
if err != nil {
fmt.Print("Unable to read subscription id, err: " + err.Error())
os.Exit(1)
Expand Down Expand Up @@ -115,7 +115,7 @@ func unsubscribeFromConfigUpdates(subscriptionId string) {
if err != nil {
fmt.Println("Error unsubscribing from config updates, err:" + err.Error())
}
unsub, err := ioutil.ReadAll(unsubscribe.Body)
unsub, err := io.ReadAll(unsubscribe.Body)
if err != nil {
fmt.Print("Unable to read unsubscribe response, err: " + err.Error())
}
Expand All @@ -128,7 +128,7 @@ func unsubscribeFromConfigUpdates(subscriptionId string) {
}

func configUpdateHandler(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
log.Panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cryptography/javascript/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ expected_stdout_lines:
- "== APP == Encrypting federico-di-dio-photography-Q4g0Q-eVVEg-unsplash.jpg to encrypted.out"
- "== APP == Encrypted the message to encrypted.out"
- "== APP == == Decrypting message using streams"
- "== APP == Encrypting encrypted.out to decrypted.out"
- "== APP == Decrypting encrypted.out to decrypted.out.jpg"
- "== APP == Decrypted the message to decrypted.out.jpg"
- "Exited App successfully"
expected_stderr_lines:
Expand Down
3 changes: 2 additions & 1 deletion cryptography/javascript/sdk/crypto-quickstart/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function encryptDecryptStream(client) {

// Decrypt the message
console.log("== Decrypting message using streams");
console.log("Encrypting encrypted.out to decrypted.out");
console.log("Decrypting encrypted.out to decrypted.out.jpg");
await pipeline(
createReadStream("encrypted.out"),
await client.crypto.decrypt({
Expand All @@ -84,4 +84,5 @@ async function encryptDecryptStream(client) {
console.log("Decrypted the message to decrypted.out.jpg");
}

// Start the code
await start();
15 changes: 8 additions & 7 deletions cryptography/javascript/sdk/crypto-quickstart/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cryptography/javascript/sdk/crypto-quickstart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"author": "",
"license": "MIT",
"dependencies": {
"@dapr/dapr": "3.1.0"
"@dapr/dapr": "~3.1.2"
},
"devDependencies": {
"@types/node": "^18.0.0",
"eslint": "^8.42.0"
}
}
4 changes: 3 additions & 1 deletion pub_sub/go/http/checkout/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func main() {
log.Fatal(err.Error())
}

req.Header.Set("Content-Type", "application/json")

// Publish an event using Dapr pub/sub
res, err := client.Do(req)
if err != nil {
Expand All @@ -43,6 +45,6 @@ func main() {

fmt.Println("Published data:", order)

time.Sleep(1000)
time.Sleep(time.Second)
}
}
14 changes: 9 additions & 5 deletions pub_sub/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package main

import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand All @@ -18,7 +19,7 @@ type JSONObj struct {
}

type Result struct {
Data string `json:"data"`
Data map[string]int `json:"data"`
}

func getOrder(w http.ResponseWriter, r *http.Request) {
Expand All @@ -40,7 +41,7 @@ func getOrder(w http.ResponseWriter, r *http.Request) {
}

func postOrder(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
if err != nil {
log.Fatal(err)
}
Expand All @@ -49,7 +50,10 @@ func postOrder(w http.ResponseWriter, r *http.Request) {
if err != nil {
log.Fatal(err.Error())
}
fmt.Println("Subscriber received:", string(result.Data))
for k, v := range result.Data {
d := fmt.Sprintf(`Subscriber received: {"%s":%d}`, k, v)
fmt.Println(d)
}
obj, err := json.Marshal(data)
if err != nil {
log.Fatal(err.Error())
Expand All @@ -76,7 +80,7 @@ func main() {

// Start the server; this is a blocking call
err := http.ListenAndServe(":"+appPort, r)
if err != http.ErrServerClosed {
if !errors.Is(err, http.ErrServerClosed) {
log.Panic(err)
}
}
2 changes: 1 addition & 1 deletion pub_sub/go/sdk/checkout/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func main() {

fmt.Println("Published data:", order)

time.Sleep(1000)
time.Sleep(time.Second)
}
}
6 changes: 6 additions & 0 deletions pub_sub/python/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This section shows how to run both applications at once using [multi-app run tem

1. Install dependencies:

1. Run the Python subscriber app (flask version) with Dapr:

<!-- STEP
name: Install Python dependencies
-->
Expand All @@ -33,8 +35,10 @@ pip3 install -r requirements.txt
cd ..
```
<!-- END_STEP -->

2. Open a new terminal window and run the multi app run template:


<!-- STEP
name: Run multi app run template
expected_stdout_lines:
Expand Down Expand Up @@ -84,6 +88,7 @@ The terminal console output should look similar to this:
== APP - checkout-sdk == INFO:root:Published data: {"orderId": 9}
== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:27] "POST /orders HTTP/1.1" 200 -
== APP - order-processor-sdk == Subscriber received : 9
```

3. Stop and clean up application processes
Expand Down Expand Up @@ -132,4 +137,5 @@ dapr run --app-id checkout-sdk --resources-path ../../../components/ -- python3
```bash
dapr stop --app-id checkout-sdk
dapr stop --app-id order-processor-sdk
dapr stop --app-id order-processor-sdk-fastapi
```
4 changes: 2 additions & 2 deletions secrets_management/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
)
Expand All @@ -25,6 +25,6 @@ func main() {
fmt.Print(err.Error())
os.Exit(1)
}
result, _ := ioutil.ReadAll(getResponse.Body)
result, _ := io.ReadAll(getResponse.Body)
fmt.Println("Fetched Secret: ", string(result))
}
4 changes: 2 additions & 2 deletions service_invocation/go/http/checkout/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -40,7 +40,7 @@ func main() {
}

// Read the response
result, err := ioutil.ReadAll(response.Body)
result, err := io.ReadAll(response.Body)
if err != nil {
log.Fatal(err)
}
Expand Down
9 changes: 5 additions & 4 deletions service_invocation/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package main

import (
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"

"github.com/gorilla/mux"
)

func getOrder(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
if err != nil {
log.Println("Error reading body:", err.Error())
}
Expand All @@ -26,10 +27,10 @@ func main() {
r := mux.NewRouter()
r.HandleFunc("/orders", getOrder).Methods("POST")

// Start the server listening on port 6001
// Start the server listening on port 6006
// This is a blocking call
err := http.ListenAndServe(":6006", r)
if err != http.ErrServerClosed {
if !errors.Is(err, http.ErrServerClosed) {
log.Println("Error starting HTTP server")
}
}
4 changes: 2 additions & 2 deletions state_management/go/http/order-processor/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -51,7 +51,7 @@ func main() {
if err != nil {
panic(err)
}
result, err := ioutil.ReadAll(getResponse.Body)
result, err := io.ReadAll(getResponse.Body)
if err != nil {
panic(err)
}
Expand Down
14 changes: 1 addition & 13 deletions tutorials/distributed-calculator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This quickstart shows method invocation and state persistent capabilities of Dap
- **Subtraction**: [.NET Core](https://docs.microsoft.com/en-us/dotnet/core/) application

The front-end application consists of a server and a client written in [React](https://reactjs.org/).
Kudos to [greatbunny](https://github.com/greatbunny) whose [React calculator](https://github.com/greatbunny/calculator) is adapted here.
Kudos to `ahfarmer` whose [React calculator](https://github.com/ahfarmer/calculator)

The following architecture diagram illustrates the components that make up this quickstart:

Expand Down Expand Up @@ -52,18 +52,6 @@ working_dir: "./go"

<!-- END_STEP -->

<!-- STEP
name: "Build go app"
working_dir: "./go"
-->

- Build the app. Run:
```bash
go build .
```

<!-- END_STEP -->

<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
Expand Down
Loading

0 comments on commit 6445c2e

Please sign in to comment.