├── .devcontainer
├── Dockerfile
├── devcontainer.json
└── env-compose.yaml
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── feature_request.md
│ ├── proposal.md
│ └── question.md
├── pull_request_template.md
└── workflows
│ └── test.yaml
├── .gitignore
├── .vscode
└── settings.json
├── CONTRIBUTING.MD
├── LICENSE
├── README.md
├── analysis_options.yaml
├── codecov
├── daprdocs
├── README.md
└── content
│ └── en
│ ├── dart-sdk-contributing
│ └── dart-contributing.md
│ └── dart-sdk-docs
│ ├── _index.md
│ ├── dapr-client
│ └── _index.md
│ └── dapr-server
│ └── _index.md
├── infrastructure
└── gh_actions_components
│ ├── client
│ ├── bindings-mqtt.yaml
│ ├── pubsub-redis.yaml
│ ├── secret-envvars.yaml
│ └── state-redis.yaml
│ └── server
│ ├── bindings-mqtt.yaml
│ └── pubsub-redis.yaml
├── melos.yaml
├── melos_dapr_dart_sdk.iml
└── packages
├── dapr_client
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── example
│ ├── dapr_client_example.dart
│ ├── secrets_management
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ ├── analysis_options.yaml
│ │ ├── bin
│ │ │ └── secrets_management.dart
│ │ ├── components
│ │ │ ├── local_secrets.json
│ │ │ └── secrets_local.yaml
│ │ ├── melos_secrets_management.iml
│ │ └── pubspec.yaml
│ └── state_management
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ ├── analysis_options.yaml
│ │ ├── bin
│ │ └── state_management.dart
│ │ ├── components
│ │ └── state-redis.yaml
│ │ ├── melos_state_management.iml
│ │ └── pubspec.yaml
├── lib
│ ├── dapr_client.dart
│ └── src
│ │ ├── abstractions
│ │ ├── client.dart
│ │ ├── client_actor.dart
│ │ ├── client_binding.dart
│ │ ├── client_invoker.dart
│ │ ├── client_pubsub.dart
│ │ ├── client_secrets.dart
│ │ └── client_state.dart
│ │ └── implementations
│ │ ├── dapr_client.dart
│ │ ├── grpc
│ │ ├── grpc_binding.dart
│ │ ├── grpc_client.dart
│ │ ├── grpc_invoker.dart
│ │ ├── grpc_pub_sub.dart
│ │ ├── grpc_secret.dart
│ │ └── grpc_state.dart
│ │ └── http
│ │ ├── http_binding.dart
│ │ ├── http_client.dart
│ │ ├── http_invoker.dart
│ │ ├── http_pub_sub.dart
│ │ ├── http_secret.dart
│ │ └── http_state.dart
├── melos_dapr_client.iml
├── pubspec.yaml
└── test
│ ├── components
│ ├── bindings-mqtt.yaml
│ ├── pubsub-redis.yaml
│ ├── secret-envvars.yaml
│ └── state-redis.yaml
│ ├── e2e
│ ├── grpc
│ │ └── grpc_test.dart
│ └── http
│ │ └── http_test.dart
│ └── unit
│ ├── dapr_client_test.dart
│ └── env_defaults
│ └── dapr_client_env_test.dart
├── dapr_common
├── .gitignore
├── CHANGELOG.md
├── README.md
├── analysis_options.yaml
├── example
│ └── dapr_common_example.dart
├── lib
│ ├── dapr_common.dart
│ └── src
│ │ ├── config
│ │ └── dapr_config_constants.dart
│ │ ├── enum
│ │ ├── communication_protocol.dart
│ │ ├── http_method.dart
│ │ └── state_option_enums.dart
│ │ ├── mocks
│ │ ├── http_mocks.dart
│ │ └── http_mocks.mocks.dart
│ │ ├── models
│ │ ├── client
│ │ │ ├── client_type_definitions.dart
│ │ │ └── generated
│ │ │ │ ├── actor_models.dart
│ │ │ │ ├── actor_models.freezed.dart
│ │ │ │ ├── actor_models.g.dart
│ │ │ │ ├── bindings_models.dart
│ │ │ │ ├── bindings_models.freezed.dart
│ │ │ │ ├── bindings_models.g.dart
│ │ │ │ ├── pub_sub_models.dart
│ │ │ │ ├── pub_sub_models.freezed.dart
│ │ │ │ ├── pub_sub_models.g.dart
│ │ │ │ ├── secret_models.dart
│ │ │ │ ├── secret_models.freezed.dart
│ │ │ │ ├── secret_models.g.dart
│ │ │ │ ├── state_models.dart
│ │ │ │ ├── state_models.freezed.dart
│ │ │ │ └── state_models.g.dart
│ │ └── server
│ │ │ ├── generated
│ │ │ ├── bindings_models.dart
│ │ │ ├── bindings_models.freezed.dart
│ │ │ ├── bindings_models.g.dart
│ │ │ ├── invoker_models.dart
│ │ │ ├── invoker_models.freezed.dart
│ │ │ ├── invoker_models.g.dart
│ │ │ ├── pub_sub_models.dart
│ │ │ ├── pub_sub_models.freezed.dart
│ │ │ └── pub_sub_models.g.dart
│ │ │ └── server_type_definitions.dart
│ │ └── utils
│ │ └── utils.dart
├── melos_dapr_common.iml
├── pubspec.yaml
└── test
│ └── dapr_common_test.dart
├── dapr_proto
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── example
│ └── dapr_proto_example.dart
├── lib
│ ├── dapr_proto.dart
│ └── src
│ │ └── proto
│ │ ├── dapr
│ │ └── proto
│ │ │ ├── common
│ │ │ └── v1
│ │ │ │ ├── common.pb.dart
│ │ │ │ ├── common.pbenum.dart
│ │ │ │ ├── common.pbjson.dart
│ │ │ │ └── common.proto
│ │ │ └── runtime
│ │ │ └── v1
│ │ │ ├── appcallback.pb.dart
│ │ │ ├── appcallback.pbenum.dart
│ │ │ ├── appcallback.pbgrpc.dart
│ │ │ ├── appcallback.pbjson.dart
│ │ │ ├── appcallback.proto
│ │ │ ├── dapr.pb.dart
│ │ │ ├── dapr.pbenum.dart
│ │ │ ├── dapr.pbgrpc.dart
│ │ │ ├── dapr.pbjson.dart
│ │ │ └── dapr.proto
│ │ └── google
│ │ └── protobuf
│ │ ├── any.pb.dart
│ │ ├── any.pbenum.dart
│ │ ├── any.pbjson.dart
│ │ ├── any.proto
│ │ ├── empty.pb.dart
│ │ ├── empty.pbenum.dart
│ │ ├── empty.pbjson.dart
│ │ └── empty.proto
├── melos_dapr_proto.iml
├── pubspec.yaml
├── scripts
│ └── sh
│ │ └── update_dapr_grpc.sh
└── test
│ └── dapr_proto_test.dart
└── dapr_server
├── .gitignore
├── CHANGELOG.md
├── README.md
├── analysis_options.yaml
├── example
├── dapr_server_example.dart
└── service_invoker
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── analysis_options.yaml
│ ├── bin
│ └── service_invoker.dart
│ ├── melos_service_invoker.iml
│ └── pubspec.yaml
├── lib
├── dapr_server.dart
└── src
│ ├── abstractions
│ ├── server.dart
│ ├── server_actor.dart
│ ├── server_binding.dart
│ ├── server_invoker.dart
│ └── server_pub_sub.dart
│ ├── exceptions
│ └── dapr_server_exceptions.dart
│ └── implementations
│ ├── dapr_server.dart
│ ├── grpc
│ ├── grpc_binding.dart
│ ├── grpc_invoker.dart
│ ├── grpc_pubsub.dart
│ ├── grpc_server.dart
│ └── grpc_server_impl.dart
│ └── http
│ ├── http_bindings.dart
│ ├── http_invoker.dart
│ ├── http_pub_sub.dart
│ ├── http_server.dart
│ └── http_server_impl.dart
├── melos_dapr_server.iml
├── pubspec.yaml
└── test
├── components
├── bindings-mqtt.yaml
└── pubsub-redis.yaml
├── grpc
└── grpc_test.dart
└── http
└── http_test.dart
/.devcontainer/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM dart:stable
2 |
3 | # Avoid warnings by switching to noninteractive
4 | ENV DEBIAN_FRONTEND=noninteractive
5 |
6 | # This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
7 | # property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
8 | # will be updated to match your local UID/GID (when using the dockerFile property).
9 | # See https://aka.ms/vscode-remote/containers/non-root-user for details.
10 | ARG USERNAME=vscode
11 | ARG USER_UID=1000
12 | ARG USER_GID=$USER_UID
13 |
14 | # Configure apt and install packages
15 | RUN apt-get update \
16 | && apt-get -y install --no-install-recommends apt-utils dialog wget curl 2>&1 \
17 | #
18 | # Install Docker CE CLI
19 | && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
20 | && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
21 | && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
22 | && apt-get update \
23 | && apt-get install -y docker-ce-cli \
24 | #
25 | # Install Dapr CLI and initialize it in slim mode.
26 | && wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash \
27 | # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
28 | && groupadd --gid $USER_GID $USERNAME \
29 | && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
30 | #
31 | # Install protobuf compiler
32 | && apt install -y protobuf-compiler \
33 | #
34 | # [Optional] Add sudo support for the non-root user
35 | && apt-get install -y sudo \
36 | && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
37 | && chmod 0440 /etc/sudoers.d/$USERNAME \
38 | #
39 | # Clean up
40 | && apt-get autoremove -y \
41 | && apt-get clean -y \
42 | && rm -rf /var/lib/apt/lists/* \
43 | #
44 | # Install Melos
45 | && dart pub global activate melos \
46 | && dart pub global activate protoc_plugin \
47 | && dart pub global activate coverage
48 | #
49 | # CirusCi flutter image sets the user name to cirus ci
50 | # Clearing it to ensure the commit goes under the correct name.
51 | # && git config --global --unset user.name \
52 | # && git config --global --unset user.email
53 | # Setup pub bin cache in the path.
54 | # Need to find if this is the correct way to set melos in path.
55 | ENV PATH ${PATH}:/root/.pub-cache/bin
56 |
57 | # Switch back to dialog for any ad-hoc use of apt-get
58 | ENV DEBIAN_FRONTEND=dialog
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | // For format details, see https://aka.ms/vscode-remote/devcontainer.json.
2 | {
3 | "name": "Dapr - DART SDK",
4 | // "context": "..",
5 | // "dockerFile": "Dockerfile",
6 | "dockerComposeFile": [
7 | "env-compose.yaml"
8 | ],
9 | "service": "dart-sdk-dev-env",
10 | // Set *default* container specific settings.json values on container create.
11 | "settings": {
12 | "terminal.integrated.profiles.linux": {
13 | "bash": {
14 | "path": "bash"
15 | },
16 | "zsh": {
17 | "path": "zsh"
18 | },
19 | "fish": {
20 | "path": "fish"
21 | },
22 | "tmux": {
23 | "path": "tmux",
24 | "icon": "terminal-tmux"
25 | },
26 | "pwsh": {
27 | "path": "pwsh",
28 | "icon": "terminal-powershell"
29 | }
30 | },
31 | "terminal.integrated.defaultProfile.linux": "bash",
32 | },
33 | // Add the IDs of extensions you want installed when the container is created.
34 | "extensions": [
35 | "ms-azuretools.vscode-dapr",
36 | "ms-azuretools.vscode-docker",
37 | "Dart-Code.dart-code",
38 | "Dart-Code.flutter",
39 | "blaxou.freezed",
40 | "zxh404.vscode-proto3",
41 | ],
42 | // "mounts": [
43 | // "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
44 | // ],
45 | "workspaceFolder": "/workspace",
46 | // All dart, flutter packages in this repository is maintained using melos.
47 | // See : https://melos.invertase.dev/
48 | // Melos is installed as part of Docker setup. See Dockerfile.
49 | // This command installs melos and bootstraps all the packages by run pub get on all the dart packages.
50 | "postAttachCommand": "dapr init --network dart_net && melos bootstrap && docker rename dapr_redis_dart_net dapr_redis",
51 | // Use 'forwardPorts' to make a list of ports inside the container available locally.
52 | // "forwardPorts": [],
53 | // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
54 | // "remoteUser": "vscode",
55 | "remoteEnv": {
56 | "CLNT_COMP_DIR": "./test/components",
57 | "SRV_COMP_DIR": "./test/components",
58 | }
59 | }
--------------------------------------------------------------------------------
/.devcontainer/env-compose.yaml:
--------------------------------------------------------------------------------
1 | version: "3"
2 |
3 | services:
4 | ###############################
5 | ## Redis state store service
6 | ###############################
7 | # redis:
8 | # container_name: "test-redis"
9 | # image: "redis:alpine"
10 | # ports:
11 | # - "6380:6379"
12 | # networks:
13 | # - dart-sdk-network
14 | #############################################
15 | ## Mosquitto MQTT message broker for bindings
16 | #############################################
17 | # mosquitto:
18 | # container_name: "test-mosquitto"
19 | # image: "eclipse-mosquitto"
20 | # ports:
21 | # - "1883:1883"
22 | # - "9000:9001"
23 | # volumes:
24 | # - type: bind
25 | # source: ../infrastructure/mosquitto.conf
26 | # target: /mosquitto/config/mosquitto.conf
27 | # networks:
28 | # - dart-sdk-network
29 | ###################################
30 | ## Rabitt MQ
31 | ###################################
32 | rabbitmq:
33 | image: rabbitmq:3-management-alpine
34 | container_name: 'dapr_rabbitmq'
35 | ports:
36 | - 5672:5672
37 | - 15672:15672
38 | networks:
39 | - dart_net
40 | ############################
41 | ## Dapr placement service
42 | ############################
43 | # placement:
44 | # container_name: "test-dapr-placement"
45 | # image: "daprio/dapr"
46 | # command: ["./placement", "-port", "50006"]
47 | # ports:
48 | # - "50006:50006"
49 | # networks:
50 | # - dart-sdk-network
51 | ###################################
52 | ##
53 | ## Dapr dart-sdk dev environment
54 | ##
55 | ## Builds the environtment from
56 | ## the Dockerfile in this directory
57 | ###################################
58 | dart-sdk-dev-env:
59 | container_name: "dart-sdk-dev-env"
60 | build:
61 | context: .
62 | dockerfile: Dockerfile
63 | volumes:
64 | # Forwards the local Docker socket to the container.
65 | - /var/run/docker.sock:/var/run/docker.sock
66 | # Update this to wherever you want VS Code to mount the folder of your project
67 | - ..:/workspace:cached
68 | # Overrides default command so things don't shut down after the process ends.
69 | # entrypoint: /usr/local/share/docker-init.sh
70 | command: sleep infinity
71 | networks:
72 | - dart_net
73 | # volumes:
74 | networks:
75 | dart_net:
76 | name: "dart_net"
77 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Report a bug in dapr dart sdk
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **Sdk version & Dapr Version**
14 |
15 | **Steps to reproduce the problem**
16 |
17 | **Expected behavior**
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Raise a feature request for dart-sdk
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the feature you'd like**
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/proposal.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Proposal
3 | about: Create a technical proposal for dart-sdk
4 | title: ''
5 | labels: proposal
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the proposal**
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question
3 | about: Ask a question related to dart-sdk
4 | title: ''
5 | labels: question
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe your question**
11 |
12 | **Steps to reproduce if applicable**
13 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | # Description
2 |
3 | _Please explain the changes you've made_
4 |
5 | ## Issue reference
6 |
7 | We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
8 |
9 | Please reference the issue this PR will close: #_[issue number]_
10 |
11 | ## Checklist
12 |
13 | Please make sure you've completed the relevant tasks for this PR, out of the following list:
14 |
15 | * [ ] Code compiles correctly
16 | * [ ] Created/updated tests
17 | * [ ] Extended the documentation
18 |
--------------------------------------------------------------------------------
/.github/workflows/test.yaml:
--------------------------------------------------------------------------------
1 | name: E2E & unit tests
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | - release-*
8 | tags:
9 | - v*
10 | pull_request:
11 | branches:
12 | - main
13 | - release-*
14 |
15 | jobs:
16 | run-all-tests:
17 | runs-on: ubuntu-latest
18 | env:
19 | DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh
20 | SRV_COMP_DIR: ../../infrastructure/gh_actions_components/server
21 | CLNT_COMP_DIR: ../../infrastructure/gh_actions_components/client
22 | services:
23 | dapr_rabbitmq:
24 | image: rabbitmq:3-management-alpine
25 | ports:
26 | - 5672:5672
27 | - 15672:15672
28 | steps:
29 | - uses: actions/checkout@v2
30 |
31 | - name: Dapr - Install CLI
32 | run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}
33 |
34 | - name: Dapr - Initialize
35 | run: dapr init
36 |
37 | # - name: Run RabbitMQ container
38 | # run: docker run -d -p 5672:5672 --name dapr_rabbitmq rabbitmq:3-management-alpine
39 | - name: List docker containers
40 | run: docker ps
41 |
42 | - name: Install dart
43 | uses: dart-lang/setup-dart@v1
44 | with:
45 | sdk: stable
46 |
47 | - name: Install Melos
48 | run: dart pub global activate melos
49 |
50 | - name: Install coverage package for dart
51 | run: dart pub global activate coverage
52 |
53 | - name: Install jq for processing json in terminal
54 | run: |
55 | sudo apt-get update -y
56 | sudo apt-get install -y jq
57 |
58 | - name: Run client unit tests
59 | run: |
60 | melos run test:client:unit
61 |
62 | - name: Run client http e2e tests
63 | run: |
64 | melos run test:client:e2e:http
65 | export test_result=$(tail -1 packages/dapr_client/test/reports/tests_client_http.json)
66 | if $(echo $test_result | jq '.success') == true; then
67 | echo "No error found: All tests passed";
68 | else
69 | echo "Some test have failed. Pleas verify the logs"
70 | exit 1;
71 | fi
72 |
73 | - name: Run client grpc e2e tests
74 | run: |
75 | melos run test:client:e2e:grpc | tee cln_grpc.txt
76 | export test_result=$(tail -1 packages/dapr_client/test/reports/tests_client_grpc.json)
77 | if $(echo $test_result | jq '.success') == true; then
78 | echo "No error found: All tests passed";
79 | else
80 | echo "Some test have failed. Pleas verify the logs"
81 | exit 1;
82 | fi
83 |
84 | - name: Run server http e2e tests
85 | run: |
86 | melos run test:server:e2e:http | tee srv_http.txt
87 | export test_result=$(tail -1 packages/dapr_server/test/reports/tests_server_http.json)
88 | if $(echo $test_result | jq '.success') == true; then
89 | echo "No error found: All tests passed";
90 | else
91 | echo "Some test have failed. Pleas verify the logs"
92 | exit 1;
93 | fi
94 |
95 | - name: Run server grpc e2e tests
96 | run: |
97 | melos run test:server:e2e:grpc | tee srv_grpc.txt
98 | export test_result=$(tail -1 packages/dapr_server/test/reports/tests_server_grpc.json)
99 | if $(echo $test_result | jq '.success') == true; then
100 | echo "No error found: All tests passed";
101 | else
102 | echo "Some test have failed. Pleas verify the logs"
103 | exit 1;
104 | fi
105 |
106 | - name: Upload coverage to Codecov
107 | uses: codecov/codecov-action@v2
108 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 |
3 | # Remove coverage files from tracking.
4 | coverage
5 | coverage.lcov
6 | demo_shef_server
7 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | "dapr",
4 | "lcov"
5 | ]
6 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/invertase/melos)
2 | [](https://codecov.io/gh/Abhilash-Chandran/dart-sdk)
3 | [](https://github.com/Abhilash-Chandran/dart-sdk/actions/workflows/test.yaml)
4 |
5 | # Dapr dart sdk
6 |
7 | Welcome to the dart-sdk for dapr. This repository aims to provide and maintain the dart packages required to interact with dapr sidecar.
8 |
9 | ## What is Dapr?
10 | [Dapr](https://dapr.io/) is an API to build & maintain, portable and reliable microservices.
11 | It allows developers to build microservices that can inteface with a plethora of external services, through a set of standardised APIs.
12 | Using Dapr allows developers to focus on the core business logic instead of dealing with the SDKs required to connect with theses external services.
13 |
14 | Dapr enables this interfacing by defining a set of standard components namely building blocks each of which handle different core logic that a microservice would require to handle. This is achieved using a sidecar architecture in which the sidecar runs alongside your service or web app and enables interacting with external services through this sidecar.
15 |
16 | To learn more about Dapr head over to docs section at [https://dapr.io/](https://dapr.io/)
17 |
18 |
19 | ## What does this SDK offer?
20 |
21 | The Dart-sdk offers two main packages namely [dapr_client](packages/dapr_client/README.md) and [dapr_server](packages/dapr_server/README.md) which provides api's to interact with a dapr_sidercar.
22 |
23 | When using Dapr there are two main use cases.
24 |
25 | 1. An application interacting with the Dapr sidecar to invoke, publish or retrieve state.
26 |
27 | * [dapr_client](packages/dapr_client/README.md) eases this process by providing a unified api to interact with all the building blocks a sidecar offers.
28 |
29 | 2. An application which can be invoked by external services, which listens to a published message to take corresponding action.
30 |
31 | * [dapr_server](packages/dapr_server/README.md) eases this process by providing APIs to write daperised services which confirm to the required specification.
32 |
33 | The image below depicts both these use cases.
34 |
35 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | linter:
2 | rules:
3 | - prefer_relative_imports
--------------------------------------------------------------------------------
/codecov:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr-sandbox/dart-sdk/e8710adb2e71fceb4798d809d92bef1ba8495969/codecov
--------------------------------------------------------------------------------
/daprdocs/README.md:
--------------------------------------------------------------------------------
1 | # Dapr Dart SDK documentation
2 |
3 | This page covers how the documentation is structured for the Dapr Dart SDK
4 |
5 | ## Dapr Docs
6 |
7 | All Dapr documentation is hosted at [docs.dapr.io](https://docs.dapr.io), including the docs for the [Dart SDK](https://docs.dapr.io/developing-applications/sdks/dart/). Head over there if you want to read the docs.
8 |
9 | ### Dart SDK docs source
10 |
11 | Although the docs site code and content is in the [docs repo](https://github.com/dapr/docs), the
12 | Dart SDK content and images are within the `content` and `static` directories, respectively.
13 |
14 | This allows separation of roles and expertise between maintainers, and makes it easy to find the docs files you are looking for.
15 |
16 | ## Writing Dart SDK docs
17 |
18 | To get up and running to write Dart SDK docs, visit the [docs repo](https://github.com/dapr/docs) to initialize your environment. It will clone both the docs repo and this repo, so you can make changes and see it rendered within the site instantly, as well as commit and PR into this repo.
19 |
20 | Make sure to read the [docs contributing guide](https://docs.dapr.io/contributing/contributing-docs/) for information on style/semantics/etc.
21 |
22 | ## Docs architecture
23 |
24 | The docs site is built on [Hugo](https://gohugo.io), which lives in the docs repo. This repo is setup as a git submodule so that when the repo is cloned and initialized, the javascript-sdk repo, along with the docs, are cloned as well.
25 |
26 | Then, in the Hugo configuration file, the `daprdocs/content` and `daprdocs/static` directories are redirected to the `daprdocs/developing-applications/sdks/dart` and `static/dart` directories, respectively. Thus, all the content within this repo is folded into the main docs site.
27 |
--------------------------------------------------------------------------------
/daprdocs/content/en/dart-sdk-docs/_index.md:
--------------------------------------------------------------------------------
1 | ---
2 | type: docs
3 | title: "Dapr Dart SDK"
4 | linkTitle: "Dart"
5 | weight: 1000
6 | description: Dart SDK packages for developing Dapr applications
7 | no_list: true
8 | ---
9 |
10 | A Dart-sdk to help write Dapr application in dart. The sdk provides two set of
11 | packages namely `dapr_client` and `dapr_server`.
12 |
13 | {{< cardpane >}}
14 | {{< card title="**Client**">}}
15 | Use the Dapr Client dart sdk for invoking public Dapr APIs
16 |
17 | [**Learn more about the Dart client sdk**]({{< ref dapr-client >}})
18 | {{< /card >}}
19 | {{< card title="**Service**">}}
20 | Use the Dart Server (Callback) sdk to create services that will be invoked by Dapr.
21 |
22 | [**Learn more about the Dart server (Callback) sdk**]({{< ref dapr-server >}})
23 | {{< /card >}}
24 | {{< /cardpane >}}
25 |
--------------------------------------------------------------------------------
/infrastructure/gh_actions_components/client/bindings-mqtt.yaml:
--------------------------------------------------------------------------------
1 | # https://docs.dapr.io/reference/components-reference/supported-bindings/rabbitmq/
2 | apiVersion: dapr.io/v1alpha1
3 | kind: Component
4 | metadata:
5 | name: binding-rabbit
6 | namespace: default
7 | spec:
8 | type: bindings.rabbitmq
9 | version: v1
10 | metadata:
11 | - name: consumerID
12 | value: "{uuid}"
13 | - name: host
14 | value: "amqp://guest:guest@localhost:5672"
15 | - name: queueName
16 | value: "test-queue"
17 | - name: qos
18 | value: 1
19 | - name: retain
20 | value: "false"
21 | - name: cleanSession
22 | value: "false"
23 |
--------------------------------------------------------------------------------
/infrastructure/gh_actions_components/client/pubsub-redis.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: pubsub-redis
5 | namespace: default
6 | spec:
7 | type: pubsub.redis
8 | version: v1
9 | metadata:
10 | - name: redisHost
11 | value: localhost:6379
12 | - name: redisPassword
13 | value: ""
14 | - name: consumerID
15 | value: "myGroup"
16 | - name: enableTLS
17 | value: "false"
--------------------------------------------------------------------------------
/infrastructure/gh_actions_components/client/secret-envvars.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: secret-envvars
5 | namespace: default
6 | spec:
7 | type: secretstores.local.env
8 | version: v1
9 | metadata:
--------------------------------------------------------------------------------
/infrastructure/gh_actions_components/client/state-redis.yaml:
--------------------------------------------------------------------------------
1 | # https://docs.dapr.io/reference/components-reference/supported-bindings/redis/
2 | apiVersion: dapr.io/v1alpha1
3 | kind: Component
4 | metadata:
5 | name: state-redis
6 | namespace: default
7 | spec:
8 | type: state.redis
9 | version: v1
10 | metadata:
11 | - name: redisHost
12 | value: localhost:6379
13 | - name: redisPassword
14 | value: ""
15 | - name: enableTLS
16 | value: "false"
17 | - name: failover
18 | value: "false"
19 | - name: actorStateStore
20 | value: "true"
--------------------------------------------------------------------------------
/infrastructure/gh_actions_components/server/bindings-mqtt.yaml:
--------------------------------------------------------------------------------
1 | # https://docs.dapr.io/reference/components-reference/supported-bindings/rabbitmq/
2 | apiVersion: dapr.io/v1alpha1
3 | kind: Component
4 | metadata:
5 | name: binding-rabbit
6 | namespace: default
7 | spec:
8 | type: bindings.rabbitmq
9 | version: v1
10 | metadata:
11 | - name: consumerID
12 | value: "{uuid}"
13 | - name: host
14 | value: "amqp://guest:guest@localhost:5672"
15 | - name: queueName
16 | value: "test-queue"
17 | - name: qos
18 | value: 1
19 | - name: retain
20 | value: "false"
21 | - name: cleanSession
22 | value: "false"
23 |
--------------------------------------------------------------------------------
/infrastructure/gh_actions_components/server/pubsub-redis.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: pubsub-redis
5 | namespace: default
6 | spec:
7 | type: pubsub.redis
8 | version: v1
9 | metadata:
10 | - name: redisHost
11 | value: localhost:6379
12 | - name: redisPassword
13 | value: ""
14 | - name: consumerID
15 | value: "myGroup"
16 | - name: enableTLS
17 | value: "false"
--------------------------------------------------------------------------------
/melos_dapr_dart_sdk.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/dapr_client/.gitignore:
--------------------------------------------------------------------------------
1 | # Files and directories created by pub.
2 | .dart_tool/
3 | .packages
4 |
5 | # Conventional directory for build outputs.
6 | build/
7 |
8 | # Omit committing pubspec.lock for library packages; see
9 | # https://dart.dev/guides/libraries/private-files#pubspeclock.
10 | pubspec.lock
11 |
12 | # ignore test reports directory
13 | test/reports
--------------------------------------------------------------------------------
/packages/dapr_client/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.0.1
2 |
3 | - Initial version.
4 | - Client sdk for State and Secrete management API is ready for use.
5 |
--------------------------------------------------------------------------------
/packages/dapr_client/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Abhilash Chandran
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/packages/dapr_client/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the static analysis results for your project (errors,
2 | # warnings, and lints).
3 | #
4 | # This enables the 'recommended' set of lints from `package:lints`.
5 | # This set helps identify many issues that may lead to problems when running
6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic
7 | # style and format.
8 | #
9 | # If you want a smaller set of lints you can change this to specify
10 | # 'package:lints/core.yaml'. These are just the most critical lints
11 | # (the recommended set includes the core lints).
12 | # The core lints are also what is used by pub.dev for scoring packages.
13 |
14 | include: package:lints/recommended.yaml
15 |
16 | # Uncomment the following section to specify additional rules.
17 |
18 | # linter:
19 | # rules:
20 | # - camel_case_types
21 |
22 | analyzer:
23 | exclude:
24 | - lib/src/models/generated/**.g.dart
25 | - lib/src/models/generated/**.freezed.dart
26 |
27 | # For more information about the core and recommended set of lints, see
28 | # https://dart.dev/go/core-lints
29 |
30 | # For additional information about configuring this file, see
31 | # https://dart.dev/guides/language/analysis-options
32 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/dapr_client_example.dart:
--------------------------------------------------------------------------------
1 | void main(List args) {
2 |
3 | }
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/.gitignore:
--------------------------------------------------------------------------------
1 | # Files and directories created by pub.
2 | .dart_tool/
3 | .packages
4 |
5 | # Conventional directory for build output.
6 | build/
7 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 1.0.0
2 |
3 | - Initial version.
4 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/README.md:
--------------------------------------------------------------------------------
1 | A simple command-line application.
2 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the static analysis results for your project (errors,
2 | # warnings, and lints).
3 | #
4 | # This enables the 'recommended' set of lints from `package:lints`.
5 | # This set helps identify many issues that may lead to problems when running
6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic
7 | # style and format.
8 | #
9 | # If you want a smaller set of lints you can change this to specify
10 | # 'package:lints/core.yaml'. These are just the most critical lints
11 | # (the recommended set includes the core lints).
12 | # The core lints are also what is used by pub.dev for scoring packages.
13 |
14 | include: package:lints/recommended.yaml
15 |
16 | # Uncomment the following section to specify additional rules.
17 |
18 | # linter:
19 | # rules:
20 | # - camel_case_types
21 |
22 | # analyzer:
23 | # exclude:
24 | # - path/to/excluded/files/**
25 |
26 | # For more information about the core and recommended set of lints, see
27 | # https://dart.dev/go/core-lints
28 |
29 | # For additional information about configuring this file, see
30 | # https://dart.dev/guides/language/analysis-options
31 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/bin/secrets_management.dart:
--------------------------------------------------------------------------------
1 | import 'package:dapr_client/dapr_client.dart';
2 |
3 | void main(List arguments) async {
4 | // Defaults to http protocol
5 | final daprClient = DaprClient(daprPort: 3500);
6 |
7 | // Switch to grpc by changing the commmunication protocol.
8 | // final daprClient = DaprClient(
9 | // daprPort: 50000, communicationProtocol: CommunicationProtocol.grpc);
10 |
11 | // Fetch the secret from local store.
12 | final mySecret = await daprClient.secret
13 | .get(secretStoreName: 'secret-local', key: 'my-secret');
14 |
15 | print("================");
16 | print('My secret is $mySecret');
17 | print("================");
18 |
19 | // Fetch the bulk secret from local store.
20 | final myBulkSecret =
21 | await daprClient.secret.getBulk(secretStoreName: 'secret-local');
22 |
23 | print("================");
24 | print('My secret is $myBulkSecret');
25 | print("================");
26 | }
27 |
28 | // dapr run --app-id myapp --dapr-http-port 3500 --dapr-grpc-port 50000 --components-path ./components dart run
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/components/local_secrets.json:
--------------------------------------------------------------------------------
1 | {
2 | "my-secret": "I'm Batman",
3 | "secret_2": {
4 | "friend_1": "Christopher Nolan",
5 | "enemy_1": "Joker"
6 | }
7 | }
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/components/secrets_local.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: secret-local
5 | namespace: default
6 | spec:
7 | type: secretstores.local.file
8 | version: v1
9 | metadata:
10 | - name: secretsFile
11 | value: components/local_secrets.json
12 | - name: nestedSeparator
13 | value: ":"
14 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/melos_secrets_management.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/secrets_management/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: secrets_management
2 | description: A simple command-line application.
3 | version: 1.0.0
4 | # homepage: https://www.example.com
5 | publish_to: none
6 |
7 | environment:
8 | sdk: ">=2.14.4 <3.0.0"
9 |
10 | dependencies:
11 | # dapr_client: 0.1.0
12 | dapr_client:
13 | path: "../../"
14 |
15 | dev_dependencies:
16 | lints: ^1.0.0
17 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/state_management/.gitignore:
--------------------------------------------------------------------------------
1 | # Files and directories created by pub.
2 | .dart_tool/
3 | .packages
4 |
5 | # Conventional directory for build output.
6 | build/
7 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/state_management/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 1.0.0
2 |
3 | - Initial version.
4 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/state_management/README.md:
--------------------------------------------------------------------------------
1 | A simple command-line application.
2 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/state_management/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the static analysis results for your project (errors,
2 | # warnings, and lints).
3 | #
4 | # This enables the 'recommended' set of lints from `package:lints`.
5 | # This set helps identify many issues that may lead to problems when running
6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic
7 | # style and format.
8 | #
9 | # If you want a smaller set of lints you can change this to specify
10 | # 'package:lints/core.yaml'. These are just the most critical lints
11 | # (the recommended set includes the core lints).
12 | # The core lints are also what is used by pub.dev for scoring packages.
13 |
14 | include: package:lints/recommended.yaml
15 |
16 | # Uncomment the following section to specify additional rules.
17 |
18 | # linter:
19 | # rules:
20 | # - camel_case_types
21 |
22 | # analyzer:
23 | # exclude:
24 | # - path/to/excluded/files/**
25 |
26 | # For more information about the core and recommended set of lints, see
27 | # https://dart.dev/go/core-lints
28 |
29 | # For additional information about configuring this file, see
30 | # https://dart.dev/guides/language/analysis-options
31 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/state_management/bin/state_management.dart:
--------------------------------------------------------------------------------
1 | import 'package:dapr_client/dapr_client.dart';
2 |
3 | void main(List arguments) async {
4 | final daprClient = DaprClient(daprPort: 3500);
5 |
6 | // Save a new state
7 | await daprClient.state.save(
8 | storeName: "state-redis",
9 | stateObjects: [SaveStateItem(key: 'key-1', value: 'value-1')],
10 | );
11 |
12 | // Save additional key value pairs
13 | await daprClient.state.save(
14 | storeName: "state-redis",
15 | stateObjects: [
16 | SaveStateItem(key: 'key-2', value: 'value-2'),
17 | SaveStateItem(key: 'key-3', value: 'value-3'),
18 | ],
19 | );
20 |
21 | // Retrieve and print an existing state.
22 | final stateKey2 =
23 | await daprClient.state.get(storeName: 'state-redis', key: 'key-2');
24 |
25 | print("======================================");
26 | print("State value for key-2 is $stateKey2");
27 | print("======================================");
28 |
29 | // Fetch bulk state key-value pairs.
30 | final allKeys = await daprClient.state
31 | .getBulk(storeName: 'state-redis', keys: ['key-1', 'key-3']);
32 |
33 | print("======================================");
34 | print("Bulk Key value pair is is $allKeys");
35 | print("======================================");
36 |
37 | // Perform transactions on state store
38 | await daprClient.state.transaction(storeName: 'state-redis', operations: [
39 | StateOperation(
40 | operation: 'upsert',
41 | request: StateOperationRequest(key: 'key-1', value: 'updated-value-1'),
42 | ),
43 | StateOperation(
44 | operation: 'upsert',
45 | request: StateOperationRequest(key: 'key-2', value: 'updated-value-2'),
46 | ),
47 | StateOperation(
48 | operation: 'delete',
49 | request: StateOperationRequest(key: 'key-3'),
50 | ),
51 | ]);
52 |
53 | // verify the transaction result
54 | final allKeys2 = await daprClient.state
55 | .getBulk(storeName: 'state-redis', keys: ['key-1', 'key-2']);
56 | print("======================================");
57 | print("Bulk Key value pair is is $allKeys2");
58 | print("======================================");
59 |
60 | // delete existing key-value pairs
61 | await daprClient.state.delete(storeName: 'state-redis', key: 'key-1');
62 | await daprClient.state.delete(storeName: 'state-redis', key: 'key-2');
63 | }
64 |
65 |
66 | // dapr run --app-id myapp --dapr-http-port 3500 --dapr-grpc-port 50000 --components-path ./components dart run
--------------------------------------------------------------------------------
/packages/dapr_client/example/state_management/components/state-redis.yaml:
--------------------------------------------------------------------------------
1 | # https://docs.dapr.io/reference/components-reference/supported-bindings/redis/
2 | apiVersion: dapr.io/v1alpha1
3 | kind: Component
4 | metadata:
5 | name: state-redis
6 | namespace: default
7 | spec:
8 | type: state.redis
9 | version: v1
10 | metadata:
11 | - name: redisHost
12 | value: dapr_redis:6379
13 | - name: redisPassword
14 | value: ""
15 | - name: enableTLS
16 | value: "false"
17 | - name: failover
18 | value: "false"
19 | - name: actorStateStore
20 | value: "true"
--------------------------------------------------------------------------------
/packages/dapr_client/example/state_management/melos_state_management.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/dapr_client/example/state_management/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: state_management
2 | description: A simple command-line application.
3 | version: 1.0.0
4 | # homepage: https://www.example.com
5 |
6 | publish_to: none
7 | environment:
8 | sdk: ">=2.14.4 <3.0.0"
9 |
10 | dependencies:
11 | # dapr_client: 0.1.0
12 | dapr_client:
13 | path: "../../"
14 |
15 | dev_dependencies:
16 | lints: ^1.0.0
17 |
--------------------------------------------------------------------------------
/packages/dapr_client/lib/dapr_client.dart:
--------------------------------------------------------------------------------
1 | /// Support for doing something awesome.
2 | ///
3 | /// More dartdocs go here.
4 | library dapr_client;
5 |
6 | export 'src/implementations/dapr_client.dart';
7 | export 'package:dapr_common/dapr_common.dart';
8 |
9 |
--------------------------------------------------------------------------------
/packages/dapr_client/lib/src/abstractions/client.dart:
--------------------------------------------------------------------------------
1 | import 'package:dapr_common/dapr_common.dart';
2 |
3 | /// An abstract client which exposes client related information.
4 | ///
5 | /// Will be implemented by the respective clients such as [HttpClient] and [GrpcClient].
6 | abstract class Client {
7 | T get client;
8 | String get clientHost;
9 | int get clientPort;
10 | CommunicationProtocol get communicationProtocol;
11 | }
12 |
--------------------------------------------------------------------------------
/packages/dapr_client/lib/src/abstractions/client_actor.dart:
--------------------------------------------------------------------------------
1 | import 'package:dapr_common/dapr_common.dart';
2 |
3 | abstract class ClientActor {
4 | /// The client for the chose protocol.
5 | T get client;
6 |
7 | /// Based on the following api definition.
8 | ///
9 | /// https://docs.dapr.io/reference/api/actors_api/#invoke-actor-method
10 | ///
11 | Future