Skip to content

Commit

Permalink
chore: Added the support for parsing Multiple Data Plane URL's for ea…
Browse files Browse the repository at this point in the history
…ch Data Residency Region
  • Loading branch information
Desu Sai Venkat authored and Desu Sai Venkat committed Nov 9, 2022
1 parent 63e54c8 commit be30f3b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- Rudder (1.8.0)
- Rudder (1.7.1)

DEPENDENCIES:
- Rudder (from `.`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "."

SPEC CHECKSUMS:
Rudder: 0a5272646aa3b89295526cea2bf54d092044848a
Rudder: 61568212171ddc2efe7785d0a6a0de589d181370

PODFILE CHECKSUM: b22a79db44ea2c78e3500063ff2c7312ef613413

Expand Down
16 changes: 8 additions & 8 deletions Rudder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,6 @@
path = Events;
sourceTree = "<group>";
};
F69E95A929093E630016E5C9 /* RudderTests */ = {
isa = PBXGroup;
children = (
F69E95AA29093E630016E5C9 /* RudderTests.swift */,
);
path = RudderTests;
sourceTree = "<group>";
};
ED857DEE2912750900B7BFCE /* Others */ = {
isa = PBXGroup;
children = (
Expand All @@ -686,6 +678,14 @@
name = Others;
sourceTree = "<group>";
};
F69E95A929093E630016E5C9 /* RudderTests */ = {
isa = PBXGroup;
children = (
F69E95AA29093E630016E5C9 /* RudderTests.swift */,
);
path = RudderTests;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down
34 changes: 27 additions & 7 deletions RudderTests/RudderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,19 @@ class RudderTests: XCTestCase {
"liveEventsConfig": {
},
"dataPlaneUrls": {
"eu": "https://rudderstacgwyx-eu.dataplane.rudderstack.com",
"us": "https://rudderstacgwyx-us.dataplane.rudderstack.com"
"dataplanes": {
"EU": [
{
"url": "https://rudderstacgwyx-eu.dataplane.rudderstack.com",
"default": true
}
],
"US": [
{
"url": "https://rudderstacgwyx-us.dataplane.rudderstack.com",
"default": true
}
]
},
"id": "2GcaJMDRDWtZsZdeusASLcpyamz",
"name": "Android Dev 2",
Expand Down Expand Up @@ -119,8 +129,13 @@ class RudderTests: XCTestCase {
"liveEventsConfig": {
},
"dataPlaneUrls": {
"us": "https://rudderstacgwyx-us.dataplane.rudderstack.com"
"dataplanes": {
"US": [
{
"url": "https://rudderstacgwyx-us.dataplane.rudderstack.com",
"default": true
}
]
},
"id": "2GcaJMDRDWtZsZdeusASLcpyamz",
"name": "Android Dev 2",
Expand Down Expand Up @@ -192,8 +207,13 @@ class RudderTests: XCTestCase {
"liveEventsConfig": {
},
"dataPlaneUrls": {
"eu": "https://rudderstacgwyx-eu.dataplane.rudderstack.com"
"dataplanes": {
"EU": [
{
"url": "https://rudderstacgwyx-eu.dataplane.rudderstack.com",
"default": true
}
]
},
"id": "2GcaJMDRDWtZsZdeusASLcpyamz",
"name": "Android Dev 2",
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/Public/RSServerConfigSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readwrite) BOOL isSourceEnabled;
@property (nonatomic, readwrite) NSString *updatedAt;
@property (nonatomic, readwrite) NSMutableArray *destinations;
@property (nonatomic, readwrite) NSMutableDictionary* dataResidencyUrls;
@property (nonatomic, readwrite) NSMutableDictionary* dataPlanes;

- (void) addDestination: (RSServerDestination*) destination;
- (NSString *) getDataResidencyUrl:(RSDataResidencyServer) residency;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Classes/RSServerConfigManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ - (RSServerConfigSource *)_parseConfig:(NSString *)configStr {
[destinations addObject:destination];
}

source.dataResidencyUrls = [sourceDict objectForKey:@"dataPlaneUrls"];
source.dataPlanes = [sourceDict objectForKey:@"dataplanes"];
source.destinations = destinations;
} else {
[RSLogger logError:@"config deserializaion error"];
Expand Down
21 changes: 16 additions & 5 deletions Sources/Classes/RSServerConfigSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ - (instancetype)init
self = [super init];
if (self) {
self.destinations = [[NSMutableArray alloc] init];
self.dataResidencyUrls = [[NSMutableDictionary alloc] init];
self.dataPlanes = [[NSMutableDictionary alloc] init];
}
return self;
}
Expand All @@ -25,14 +25,25 @@ - (void)addDestination:(RSServerDestination *)destination {
}

- (NSString *) getDataResidencyUrl:(RSDataResidencyServer) residency {
NSArray * residenceDataPlanes;
switch(residency) {
case EU:
if([self.dataResidencyUrls objectForKey:@"eu"] != nil) {
return [self.dataResidencyUrls objectForKey:@"eu"];
}
residenceDataPlanes = [self.dataPlanes objectForKey:@"EU"];
default:
return [self.dataResidencyUrls objectForKey:@"us"];
if (residenceDataPlanes != nil)
break;
residenceDataPlanes = [self.dataPlanes objectForKey:@"US"];
}

if(residenceDataPlanes == nil)
return nil;
for (NSDictionary* residenceDataPlane in residenceDataPlanes) {
if([[residenceDataPlane objectForKey:@"default"] boolValue]) {
NSLog(@"Data type is %@",[[residenceDataPlane objectForKey:@"default"] class]);
return [residenceDataPlane objectForKey:@"url"];
}
}
return nil;
}

@end

0 comments on commit be30f3b

Please sign in to comment.