-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1492 from dilanSachi/multi-config-master
Fix client configuration getting overwritten when mutliple clients are available
- Loading branch information
Showing
11 changed files
with
244 additions
and
9 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
ballerina-tests/tests/79_multiple_client_configurations.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.com) All Rights Reserved. | ||
// | ||
// WSO2 LLC. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
import "google/protobuf/empty.proto"; | ||
|
||
service MultipleClientConfigsService1 { | ||
rpc call1(google.protobuf.Empty) returns (google.protobuf.Empty); | ||
} | ||
|
||
service MultipleClientConfigsService2 { | ||
rpc call1(google.protobuf.Empty) returns (google.protobuf.Empty); | ||
} |
38 changes: 38 additions & 0 deletions
38
ballerina-tests/tests/79_multiple_client_configurations_client.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 Inc. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/grpc; | ||
import ballerina/test; | ||
|
||
grpc:ClientConfiguration config1 = { | ||
secureSocket: { | ||
cert: "tests/resources/public.crt" | ||
} | ||
}; | ||
|
||
grpc:ClientConfiguration config2 = { | ||
secureSocket: { | ||
cert: "tests/resources/public2.crt" | ||
} | ||
}; | ||
|
||
@test:Config {enable: true} | ||
function testMultipleConfigurationsInMultiClientScenario() returns error? { | ||
MultipleClientConfigsService1Client ep1 = check new ("https://localhost:9179", config1); | ||
MultipleClientConfigsService2Client ep2 = check new ("https://localhost:9279", config2); | ||
check ep1->call1(); | ||
check ep2->call1(); | ||
} |
71 changes: 71 additions & 0 deletions
71
ballerina-tests/tests/79_multiple_client_configurations_pb.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 LLC. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/grpc; | ||
import ballerina/protobuf.types.empty; | ||
|
||
public const string MULTIPLE_CLIENT_CONFIGURATIONS_DESC = "0A2737395F6D756C7469706C655F636C69656E745F636F6E66696775726174696F6E732E70726F746F1A1B676F6F676C652F70726F746F6275662F656D7074792E70726F746F32580A1D4D756C7469706C65436C69656E74436F6E66696773536572766963653112370A0563616C6C3112162E676F6F676C652E70726F746F6275662E456D7074791A162E676F6F676C652E70726F746F6275662E456D70747932580A1D4D756C7469706C65436C69656E74436F6E66696773536572766963653212370A0563616C6C3112162E676F6F676C652E70726F746F6275662E456D7074791A162E676F6F676C652E70726F746F6275662E456D707479620670726F746F33"; | ||
|
||
public isolated client class MultipleClientConfigsService1Client { | ||
*grpc:AbstractClientEndpoint; | ||
|
||
private final grpc:Client grpcClient; | ||
|
||
public isolated function init(string url, *grpc:ClientConfiguration config) returns grpc:Error? { | ||
self.grpcClient = check new (url, config); | ||
check self.grpcClient.initStub(self, MULTIPLE_CLIENT_CONFIGURATIONS_DESC); | ||
} | ||
|
||
isolated remote function call1() returns grpc:Error? { | ||
empty:Empty message = {}; | ||
map<string|string[]> headers = {}; | ||
_ = check self.grpcClient->executeSimpleRPC("MultipleClientConfigsService1/call1", message, headers); | ||
} | ||
|
||
isolated remote function call1Context() returns empty:ContextNil|grpc:Error { | ||
empty:Empty message = {}; | ||
map<string|string[]> headers = {}; | ||
var payload = check self.grpcClient->executeSimpleRPC("MultipleClientConfigsService1/call1", message, headers); | ||
[anydata, map<string|string[]>] [_, respHeaders] = payload; | ||
return {headers: respHeaders}; | ||
} | ||
} | ||
|
||
public isolated client class MultipleClientConfigsService2Client { | ||
*grpc:AbstractClientEndpoint; | ||
|
||
private final grpc:Client grpcClient; | ||
|
||
public isolated function init(string url, *grpc:ClientConfiguration config) returns grpc:Error? { | ||
self.grpcClient = check new (url, config); | ||
check self.grpcClient.initStub(self, MULTIPLE_CLIENT_CONFIGURATIONS_DESC); | ||
} | ||
|
||
isolated remote function call1() returns grpc:Error? { | ||
empty:Empty message = {}; | ||
map<string|string[]> headers = {}; | ||
_ = check self.grpcClient->executeSimpleRPC("MultipleClientConfigsService2/call1", message, headers); | ||
} | ||
|
||
isolated remote function call1Context() returns empty:ContextNil|grpc:Error { | ||
empty:Empty message = {}; | ||
map<string|string[]> headers = {}; | ||
var payload = check self.grpcClient->executeSimpleRPC("MultipleClientConfigsService2/call1", message, headers); | ||
[anydata, map<string|string[]>] [_, respHeaders] = payload; | ||
return {headers: respHeaders}; | ||
} | ||
} | ||
|
45 changes: 45 additions & 0 deletions
45
ballerina-tests/tests/79_multiple_client_configurations_service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 LLC. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/grpc; | ||
|
||
listener grpc:Listener multiConfigListener1 = new (9179, secureSocket = { | ||
key: { | ||
certFile: "tests/resources/public.crt", | ||
keyFile: "tests/resources/private.key" | ||
} | ||
}); | ||
|
||
@grpc:Descriptor {value: MULTIPLE_CLIENT_CONFIGURATIONS_DESC} | ||
service "MultipleClientConfigsService1" on multiConfigListener1 { | ||
|
||
remote function call1() returns error? { | ||
} | ||
} | ||
|
||
listener grpc:Listener multiConfigListener2 = new (9279, secureSocket = { | ||
key: { | ||
certFile: "tests/resources/public2.crt", | ||
keyFile: "tests/resources/private2.key" | ||
} | ||
}); | ||
|
||
@grpc:Descriptor {value: MULTIPLE_CLIENT_CONFIGURATIONS_DESC} | ||
service "MultipleClientConfigsService2" on multiConfigListener2 { | ||
|
||
remote function call1() returns error? { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCSdfIOco/H6EFV | ||
wH2JA0XNw658K3dbUHNpiG9taxxh+WZyqGwTJypbwzsSwtmHJkmLSTnwwXKpAKvz | ||
cV0l1Pm1Tki38Q9rcuwQ1DKOh6Ovjf7UjF3JYrqkgpn2XgGxllsVPQsgjJd2GQ2c | ||
0WKbq/au+WBme6GK+gzUBDZK5hyiXcbauYnjA9q/r6pGzO95FhIHbwdtCD8OntfM | ||
sltaWV/jYcUjMb/+j4mj38ib7Mhrzm/fNT2snalzMqnSnTe1gErltv3r0bDXQFU+ | ||
wOy0xkb+0aAt/RRbqWoqVM+hOyfyuODXJiCoDnbmp3zPOkw9utykkhuOzBALqqkA | ||
co7XNFJnAgMBAAECggEABT1L7gFiLGQeJjuvIf4oep5z+QQzDmS35EAZwF/TEZwy | ||
8ooc56iAhuzaiabH0mJnwiBZ/sdk2y/ndtuI2gge8MH+rvnkM9NWJ5n3vwqSK/8X | ||
7TGiT0iFZco4SMx/IgO/eWiII99zsalex8vjy67gsczBCpmEo2yjldgaux41Swei | ||
8DuUZSg8f9BqzEHEVrhhRdFBfxbHbh/b/M8/vwwI2jD4SYWkKCfz9LpWHEwsPsCT | ||
Nwv+t3hXZaUxPygvWh7uI7XYbbHfvIB03xDiYh5Hn4W4palnJbTgc5SUrfunaQai | ||
IwrhYipdUmp1Ie32iQ9ccYzqcvTL+uKQuZp9C2tACQKBgQDGiYwsN6VvVLwCRpgQ | ||
2yqd7ypaoNMm4QCHXdfyD7MwsXfiyjKC4MdKjxmbYPTe0ipy+skIYKsSByrgDmrW | ||
X+ZXb7djuerE5GY947x8m1qXTIaH0pmZ7GgM839qiiT+OQQeaUqG5wg/9c3OH47+ | ||
MnBV4M+JXYzjHg8NKXQkLlhGXwKBgQC82dQkbVVk6lVC7MNosPMm++ATPIkdigSB | ||
YxbXwuSnLAljacQJi536G1kqmFnaUk2s5WHqVyIos/pejntft7vhl72GsybqYQFc | ||
COCS7mGdQ8Dy+Lp4ZxA16Ov4HCCoNFLZ8NTWu4mg04B3qnjcs1k2WsmdLhuj+1xt | ||
6AEhWPQg+QKBgDudi9CvOObwO7A3QGw3U1mvOjmSdzUCdSUwoapW2oixkX0xF+/C | ||
zTTvOVI1z/GkjAiQk5MHa/by3gX/bkdG7qSssBWq+vr6VlUZMDz+bTpnSTI5o9Pb | ||
b/cLmuQD7U3FEx6KoU1WzFxgU9ckFMzxmle/NLJbu/Vqzjw2iWBf5jPjAoGAai5P | ||
iOuwR705kxdsB0D2dcTIiAhRT7p6LgV4oneB+DxaSvr8riFCAY2+5KQkYQxFgCC4 | ||
nPnAywHmk6Oo2niDuqOGfGXeS4mfKhATtIkzeSjPI82VinzoMGd1xVqLQgepTcCK | ||
6vEmwLYqVR4UNoLgdh81nJqAEAMURPddK1LIcIECgYEAso51I7hipW/Bu+x9m+Oy | ||
dCpM/S0i9sVdvTQoy3mkiCGii1YRySVeHl2d4gnrT+872FBOI0PnhO8Cen5KVq4F | ||
HlHOpenNz9CPfjoyKO1ZzWDEf1dpxdJh8TbHnMi46DaG6xlxt46Raqbqmrp/aQkt | ||
IkDD4NBPFxZ0q4QsTi6vFhQ= | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |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3 | ||
fbli6R0floI7kfEHwinCyfv/u4qI2i8unXP2kBUXrsGeoDrMsoJUc94LX5L1pdpo | ||
c+qaCpP8CyTktiSlPmqfklGJzTh8h7+OJVPcWunnNwL6op2ZyyqMEgsRrzB0iCSA | ||
5URZRtTwLq/JJnnUE1YQFrndmOs4Go4+Xdx5Q/rquYBSGt8fpceTDxzrIdR2QS5a | ||
1FriP1l2k/Yi+st9XtYx6SiN5jcIpPWgQco8kxYtAtCER0dqJM3/UyuaAzYSJAnI | ||
cxANjATsH+ALr5F7bDCOqvMiSndJYh1V4d0ufC2YqbvIq/9XOg== | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters