Skip to content

Commit 4c56ed0

Browse files
addjuarezAddison Juarezshubham1172
authored
feat(configuration): Change configuration API response to dictionary (#345)
* Update configuration api to dictionary Signed-off-by: addjuarez <[email protected]> * rename Signed-off-by: addjuarez <[email protected]> * use go 1.19 Signed-off-by: addjuarez <[email protected]> * fix e2e test Signed-off-by: addjuarez <[email protected]> * redo Signed-off-by: Addison Juarez <[email protected]> * remove Signed-off-by: addjuarez <[email protected]> * fix assert Signed-off-by: addjuarez <[email protected]> * add key back Signed-off-by: addjuarez <[email protected]> * feedback Signed-off-by: addjuarez <[email protected]> * fix uuidv4 Signed-off-by: addjuarez <[email protected]> * undo package changes Signed-off-by: Addison Juarez <[email protected]> * fix lock test Signed-off-by: Addison Juarez <[email protected]> * make pretty Signed-off-by: addjuarez <[email protected]> * Fix tests Signed-off-by: Shubham Sharma <[email protected]> * Fix tests Signed-off-by: Shubham Sharma <[email protected]> * Add unit test Signed-off-by: Shubham Sharma <[email protected]> * Fix lint Signed-off-by: Shubham Sharma <[email protected]> * Upgrade Dapr CLI Signed-off-by: Shubham Sharma <[email protected]> * re-trigger pipeline' ' Signed-off-by: Shubham Sharma <[email protected]> * Fix e2e Signed-off-by: Shubham Sharma <[email protected]> * Update protos Signed-off-by: Shubham Sharma <[email protected]> * Revert config e2e assertions; Signed-off-by: Shubham Sharma <[email protected]> * Fix lint Signed-off-by: Shubham Sharma <[email protected]> * Fix tests Signed-off-by: Shubham Sharma <[email protected]> * Fix lint Signed-off-by: Shubham Sharma <[email protected]> Signed-off-by: addjuarez <[email protected]> Signed-off-by: Addison Juarez <[email protected]> Signed-off-by: Addison Juarez <[email protected]> Signed-off-by: Shubham Sharma <[email protected]> Co-authored-by: Addison Juarez <[email protected]> Co-authored-by: Shubham Sharma <[email protected]>
1 parent 0d49145 commit 4c56ed0

30 files changed

+585
-333
lines changed

.github/workflows/test-e2e.yml

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ jobs:
3434
test-e2e:
3535
runs-on: ubuntu-latest
3636
env:
37-
GOVER: 1.17
38-
DAPR_CLI_VER: 1.8.0
39-
DAPR_RUNTIME_VER: 1.8.0
37+
GOVER: 1.19
38+
DAPR_CLI_VER: 1.9.1
39+
DAPR_RUNTIME_VER: 1.9.0
4040
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh
41-
DAPR_CLI_REF: '9472e6d977817243d6da28af3e3ca744414c54e6' # TODO, remove once DAPR CLI is upgraded to v1.7
42-
DAPR_REF: ''
41+
DAPR_CLI_REF: ""
42+
DAPR_REF: ""
4343
NODE_VER: 16.14.0
4444
services:
4545
emqx:
@@ -56,84 +56,84 @@ jobs:
5656
ports:
5757
- 27017:27017
5858
steps:
59-
- name: Set up Dapr CLI
60-
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}
61-
62-
- name: Set up Go ${{ env.GOVER }}
63-
if: env.DAPR_REF != '' || env.DAPR_CLI_REF != ''
64-
uses: actions/setup-go@v2
65-
with:
66-
go-version: ${{ env.GOVER }}
67-
68-
- name: Checkout Dapr CLI repo to custom reference
69-
uses: actions/checkout@v2
70-
if: env.DAPR_CLI_REF != ''
71-
with:
72-
repository: dapr/cli
73-
ref: ${{ env.DAPR_CLI_REF }}
74-
path: cli
75-
76-
- name: Checkout Dapr runtime repo to custom reference
77-
uses: actions/checkout@v2
78-
if: env.DAPR_REF != ''
79-
with:
80-
repository: dapr/dapr
81-
ref: ${{ env.DAPR_REF }}
82-
path: dapr
83-
84-
- name: Build and override dapr cli with referenced commit
85-
if: env.DAPR_CLI_REF != ''
86-
run: |
87-
cd cli
88-
make
89-
sudo cp dist/linux_amd64/release/dapr /usr/local/bin/dapr
90-
cd ..
91-
92-
- name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VER }}
93-
run: |
94-
dapr uninstall --all
95-
dapr init --runtime-version ${{ env.DAPR_RUNTIME_VER }}
96-
97-
- name: Build and override daprd with referenced commit.
98-
if: env.DAPR_REF != ''
99-
run: |
100-
cd dapr
101-
make
102-
mkdir -p $HOME/.dapr/bin/
103-
cp dist/linux_amd64/release/daprd $HOME/.dapr/bin/daprd
104-
cd ..
105-
106-
- name: Override placement service.
107-
if: env.DAPR_REF != ''
108-
run: |
109-
docker stop dapr_placement
110-
cd dapr
111-
./dist/linux_amd64/release/placement &
112-
113-
- name: Checkout JS-SDK
114-
uses: actions/checkout@v2
115-
116-
# Setup .npmrc file to publish to npm
117-
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
118-
- name: NodeJS - Install
119-
uses: actions/setup-node@v2
120-
with:
121-
node-version: ${{ env.NODE_VER }}
122-
registry-url: 'https://registry.npmjs.org'
123-
124-
- name: Build Package
125-
run: npm run build
126-
127-
- name: Run E2E tests
128-
id: tests
129-
run: npm run test:e2e:all
130-
131-
- name: Run E2E test to show successful typescript build
132-
id: typescript-build-test
133-
run: |
134-
cd test/e2e/typescript-build
135-
npm install
136-
dapr run --app-id typescript-build npm run start
137-
138-
- name: Upload test coverage
139-
uses: codecov/codecov-action@v1
59+
- name: Set up Dapr CLI
60+
run: wget -q ${{ env.DAPR_INSTALL_URL }} -O - | /bin/bash -s ${{ env.DAPR_CLI_VER }}
61+
62+
- name: Set up Go ${{ env.GOVER }}
63+
if: env.DAPR_REF != '' || env.DAPR_CLI_REF != ''
64+
uses: actions/setup-go@v2
65+
with:
66+
go-version: ${{ env.GOVER }}
67+
68+
- name: Checkout Dapr CLI repo to custom reference
69+
uses: actions/checkout@v2
70+
if: env.DAPR_CLI_REF != ''
71+
with:
72+
repository: dapr/cli
73+
ref: ${{ env.DAPR_CLI_REF }}
74+
path: cli
75+
76+
- name: Checkout Dapr runtime repo to custom reference
77+
uses: actions/checkout@v2
78+
if: env.DAPR_REF != ''
79+
with:
80+
repository: dapr/dapr
81+
ref: ${{ env.DAPR_REF }}
82+
path: dapr
83+
84+
- name: Build and override dapr cli with referenced commit
85+
if: env.DAPR_CLI_REF != ''
86+
run: |
87+
cd cli
88+
make
89+
sudo cp dist/linux_amd64/release/dapr /usr/local/bin/dapr
90+
cd ..
91+
92+
- name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VER }}
93+
run: |
94+
dapr uninstall --all
95+
dapr init --runtime-version ${{ env.DAPR_RUNTIME_VER }}
96+
97+
- name: Build and override daprd with referenced commit.
98+
if: env.DAPR_REF != ''
99+
run: |
100+
cd dapr
101+
make
102+
mkdir -p $HOME/.dapr/bin/
103+
cp dist/linux_amd64/release/daprd $HOME/.dapr/bin/daprd
104+
cd ..
105+
106+
- name: Override placement service.
107+
if: env.DAPR_REF != ''
108+
run: |
109+
docker stop dapr_placement
110+
cd dapr
111+
./dist/linux_amd64/release/placement &
112+
113+
- name: Checkout JS-SDK
114+
uses: actions/checkout@v2
115+
116+
# Setup .npmrc file to publish to npm
117+
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
118+
- name: NodeJS - Install
119+
uses: actions/setup-node@v2
120+
with:
121+
node-version: ${{ env.NODE_VER }}
122+
registry-url: "https://registry.npmjs.org"
123+
124+
- name: Build Package
125+
run: npm run build
126+
127+
- name: Run E2E tests
128+
id: tests
129+
run: npm run test:e2e:all
130+
131+
- name: Run E2E test to show successful typescript build
132+
id: typescript-build-test
133+
run: |
134+
cd test/e2e/typescript-build
135+
npm install
136+
dapr run --app-id typescript-build npm run start
137+
138+
- name: Upload test coverage
139+
uses: codecov/codecov-action@v1

scripts/fetch-proto.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ OS=$(echo `uname`|tr '[:upper:]' '[:lower:]')
33
ARCH=$(uname -m)
44
ORG_NAME="dapr"
55
REPO_NAME="dapr"
6-
BRANCH_NAME="v1.8.0"
6+
BRANCH_NAME="v1.9.0"
77

88
# Path to store output
99
PATH_ROOT=$(pwd)

src/implementation/Client/GRPCClient/configuration.ts

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { GetConfigurationResponse as GetConfigurationResponseResult } from "../.
2727
import { SubscribeConfigurationResponse as SubscribeConfigurationResponseResult } from "../../../types/configuration/SubscribeConfigurationResponse";
2828
import { SubscribeConfigurationCallback } from "../../../types/configuration/SubscribeConfigurationCallback";
2929
import { SubscribeConfigurationStream } from "../../../types/configuration/SubscribeConfigurationStream";
30+
import { ConfigurationItem } from "../../../types/configuration/ConfigurationItem";
31+
import { createConfigurationType } from "../../../utils/Client.util";
3032

3133
export default class GRPCClientConfiguration implements IClientConfiguration {
3234
client: GRPCClient;
@@ -59,23 +61,13 @@ export default class GRPCClientConfiguration implements IClientConfiguration {
5961
return reject(err);
6062
}
6163

62-
const wrapped: GetConfigurationResponseResult = {
63-
items: res.getItemsList().map((item) => ({
64-
key: item.getKey(),
65-
value: item.getValue(),
66-
version: item.getVersion(),
67-
metadata: item
68-
.getMetadataMap()
69-
.toObject()
70-
.reduce((result: object, [key, value]) => {
71-
// @ts-ignore
72-
result[key] = value;
73-
return result;
74-
}, {}),
75-
})),
64+
const configMap: { [k: string]: ConfigurationItem } = createConfigurationType(res.getItemsMap());
65+
66+
const result: SubscribeConfigurationResponseResult = {
67+
items: configMap,
7668
};
7769

78-
return resolve(wrapped);
70+
return resolve(result);
7971
});
8072
});
8173
}
@@ -135,21 +127,16 @@ export default class GRPCClientConfiguration implements IClientConfiguration {
135127

136128
stream.on("data", async (data: SubscribeConfigurationResponse) => {
137129
streamId = data.getId();
130+
const items = data.getItemsMap();
131+
132+
if (items.getLength() == 0) {
133+
return;
134+
}
135+
136+
const configMap: { [k: string]: ConfigurationItem } = createConfigurationType(items);
138137

139138
const wrapped: SubscribeConfigurationResponseResult = {
140-
items: data.getItemsList().map((item) => ({
141-
key: item.getKey(),
142-
value: item.getValue(),
143-
version: item.getVersion(),
144-
metadata: item
145-
.getMetadataMap()
146-
.toObject()
147-
.reduce((result: object, [key, value]) => {
148-
// @ts-ignore
149-
result[key] = value;
150-
return result;
151-
}, {}),
152-
})),
139+
items: configMap,
153140
};
154141

155142
await cb(wrapped);

src/proto/dapr/proto/common/v1/common.proto

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,14 @@ message StateOptions {
134134
StateConsistency consistency = 2;
135135
}
136136

137-
138137
// ConfigurationItem represents all the configuration with its name(key).
139138
message ConfigurationItem {
140-
// Required. The name of configuration item
141-
string key = 1;
142-
143139
// Required. The value of configuration item.
144-
string value = 2;
140+
string value = 1;
145141

146142
// Version is response only and cannot be fetched. Store is not expected to keep all versions available
147-
string version = 3;
143+
string version = 2;
148144

149145
// the metadata which will be passed to/from configuration store component.
150-
map<string,string> metadata = 4;
146+
map<string,string> metadata = 3;
151147
}

src/proto/dapr/proto/common/v1/common_pb.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ export namespace StateOptions {
204204
}
205205

206206
export class ConfigurationItem extends jspb.Message {
207-
getKey(): string;
208-
setKey(value: string): ConfigurationItem;
209207
getValue(): string;
210208
setValue(value: string): ConfigurationItem;
211209
getVersion(): string;
@@ -226,7 +224,6 @@ export class ConfigurationItem extends jspb.Message {
226224

227225
export namespace ConfigurationItem {
228226
export type AsObject = {
229-
key: string,
230227
value: string,
231228
version: string,
232229

0 commit comments

Comments
 (0)