Coder Social home page Coder Social logo

dapr-spike's Introduction

dapr-spike

Spike code exploring a simple use case with dapr (distributed application runtime)

dapr concepts

dapr install

wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash

init

This will pull the required dapr binaries via Docker images and run as a container

dapr init

Verify install with

dapr -v

Verify components directory initialized with

ls $HOME/.dapr
bin  components  config.yaml # expected output

service invocation

server

run dapr sidecar on server

dapr run --app-id hello-world-server --app-port 3001 --dapr-http-port 3500 npm run start:server
or
npm run dapr:server

invoke server endpoint via dapr sidecar

curl http://localhost:3500/v1.0/invoke/hello-world-server/method/api/v1/message
{"message":"Hello World!"}

client

run dapr sidecar on client

dapr run --app-id hello-world-client --app-port 3002 --dapr-http-port 3501 npm run start:client
or
npm run dapr:client

invoke client endpoint via dapr sidecar

curl http://localhost:3501/v1.0/invoke/hello-world-client/method/fetch-message
{"message":"Hello World!","originAppId":"hello-world-server"}

state management

Create a new user:

curl --location 'localhost:3500/v1.0/invoke/hello-world-server/method/api/v1/user' \
--header 'Content-Type: application/json' \
--data '{
    "name": "Alan"
} '
9cdc5d54-5d74-4037-887c-2ea4e31b2271

Query for user:

curl --location 'http://localhost:3500/v1.0/invoke/hello-world-server/method/api/v1/user/9cdc5d54-5d74-4037-887c-2ea4e31b2271' 
{
    "id": "9cdc5d54-5d74-4037-887c-2ea4e31b2271",
    "name": "Alan"
}

pub/sub

TODO

secrets

TODO

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.