Skip to content

Commit

Permalink
make stream url configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
markpokornycos committed Sep 21, 2017
1 parent 1d81cf6 commit 9f8f848
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the LaunchDarkly iOS SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [2.6.1] - 2017-09-21
### Added
-`streamUrl` property on `LDConfig` to allow customizing the Server Sent Events engine in streaming mode.

## [2.6.0] - 2017-08-25
### Added
- `doubleVariation` method for `double` value feature flags, as an alternative to `numberVariation`. Thanks @atlassian-gaustin!
Expand Down
2 changes: 1 addition & 1 deletion Darkly/DarklyConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#import "DarklyConstants.h"

NSString * const kClientVersion = @"2.6.0";
NSString * const kClientVersion = @"2.6.1";
NSString * const kBaseUrl = @"https://app.launchdarkly.com";
NSString * const kEventsUrl = @"https://mobile.launchdarkly.com";
NSString * const kStreamUrl = @"https://clientstream.launchdarkly.com/mping";
Expand Down
2 changes: 1 addition & 1 deletion Darkly/LDClientManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ - (void)configureEventSource {
DEBUG_LOGX(@"ClientManager aborting event source creation - event source running");
return;
}
eventSource = [LDEventSource eventSourceWithURL:[NSURL URLWithString:kStreamUrl] httpHeaders:[self httpHeadersForEventSource]];
eventSource = [LDEventSource eventSourceWithURL:[NSURL URLWithString:[LDClient sharedInstance].ldConfig.streamUrl] httpHeaders:[self httpHeadersForEventSource]];

[eventSource onMessage:^(LDEvent *event) {
if (![event.event isEqualToString:@"ping"]) { return; }
Expand Down
6 changes: 6 additions & 0 deletions Darkly/LDConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
*/
@property (nonatomic, copy, nullable) NSString* eventsUrl;

/**
The event source stream URL to the LaunchDarkly event source, should you need to override
the default.
*/
@property (nonatomic, copy, nullable) NSString* streamUrl;

/**
The capacity for storing feature flag and custom events. Events
are persisted on the client and then sent to the server on a regular
Expand Down
1 change: 1 addition & 0 deletions Darkly/LDConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ - (instancetype)initWithMobileKey:(NSString *)mobileKey {
self.backgroundFetchInterval = [NSNumber numberWithInt:kDefaultBackgroundFetchInterval];
self.baseUrl = kBaseUrl;
self.eventsUrl = kEventsUrl;
self.streamUrl = kStreamUrl;

return self;
}
Expand Down
8 changes: 8 additions & 0 deletions DarklyTests/LDConfigTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ - (void)testConfigOverrideBaseUrl {
XCTAssertFalse([config debugEnabled]);
}

- (void)testConfigOverrideStreamUrl {
NSString *dummyStreamUrl = @"https://clientstream.launchdarkly.com/dummySSEUrl";
LDConfig *config = [[LDConfig alloc] initWithMobileKey:@"testMobileKey"];
XCTAssertEqual(config.streamUrl, kStreamUrl);
config.streamUrl = dummyStreamUrl;
XCTAssertEqual(config.streamUrl, dummyStreamUrl);
}

- (void)testConfigOverrideCapacity {
NSString *testMobileKey = @"testMobileKey";
int testCapacity = 20;
Expand Down
4 changes: 2 additions & 2 deletions LaunchDarkly.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "LaunchDarkly"
s.version = "2.6.0"
s.version = "2.6.1"
s.summary = "iOS SDK for LaunchDarkly"

s.description = <<-DESC
Expand All @@ -23,7 +23,7 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = "9.0"
s.osx.deployment_target = '10.10'

s.source = { :git => "https://github.com/launchdarkly/ios-client.git", :tag => "2.6.0" }
s.source = { :git => "https://github.com/launchdarkly/ios-client.git", :tag => "2.6.1" }

s.source_files = "Darkly/*.{h,m}"

Expand Down

0 comments on commit 9f8f848

Please sign in to comment.