Skip to content

s/GDLUploader->GDLUploadCoordinator/g and s/GDLLogBackend/GDLLogUploader #2256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GoogleDataLogger/GoogleDataLogger/Classes/GDLLogStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#import "GDLConsoleLogger.h"
#import "GDLLogEvent_Private.h"
#import "GDLRegistrar_Private.h"
#import "GDLUploader.h"
#import "GDLUploadCoordinator.h"

/** Creates and/or returns a singleton NSString that is the shared logging path.
*
Expand Down Expand Up @@ -57,7 +57,7 @@ - (instancetype)init {
_storageQueue = dispatch_queue_create("com.google.GDLLogStorage", DISPATCH_QUEUE_SERIAL);
_logHashToLogFile = [[NSMutableDictionary alloc] init];
_logTargetToLogFileSet = [[NSMutableDictionary alloc] init];
_uploader = [GDLUploader sharedInstance];
_uploader = [GDLUploadCoordinator sharedInstance];
}
return self;
}
Expand Down
4 changes: 2 additions & 2 deletions GoogleDataLogger/GoogleDataLogger/Classes/GDLRegistrar.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ - (instancetype)init {
return self;
}

- (void)registerBackend:(id<GDLLogBackend>)backend forLogTarget:(NSInteger)logTarget {
- (void)registerBackend:(id<GDLLogUploader>)backend forLogTarget:(GDLLogTarget)logTarget {
self.logTargetToBackend[@(logTarget)] = backend;
}

- (void)registerLogPrioritizer:(id<GDLLogPrioritizer>)prioritizer
forLogTarget:(NSInteger)logTarget {
forLogTarget:(GDLLogTarget)logTarget {
self.logTargetToPrioritizer[@(logTarget)] = prioritizer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

#import <Foundation/Foundation.h>

#import "GDLRegistrar.h"

NS_ASSUME_NONNULL_BEGIN

/** This class connects log storage and the backend implementations, providing logs to the uploaders
* and informing the log storage what logs were successfully uploaded or not.
*/
@interface GDLUploader : NSObject
@interface GDLUploadCoordinator : NSObject

/** Creates and/or returrns the singleton.
*
Expand All @@ -32,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
/** Forces the backend specified by the target to upload the provided set of logs. This should only
* ever happen when the QoS tier of a log requires it.
*/
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(NSInteger)logTarget;
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(GDLLogTarget)logTarget;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@
* limitations under the License.
*/

#import "GDLUploader.h"
#import "GDLUploadCoordinator.h"

@implementation GDLUploader
#import "GDLRegistrar_Private.h"

@implementation GDLUploadCoordinator

+ (instancetype)sharedInstance {
static GDLUploader *sharedUploader;
static GDLUploadCoordinator *sharedUploader;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedUploader = [[GDLUploader alloc] init];
sharedUploader = [[GDLUploadCoordinator alloc] init];
});
return sharedUploader;
}

- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(NSInteger)logTarget {
// TODO
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(GDLLogTarget)logTarget {
// Ask the prioritizer of the target for some logs
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "GDLLogStorage.h"

@class GDLUploader;
@class GDLUploadCoordinator;

@interface GDLLogStorage ()

Expand All @@ -31,6 +31,6 @@
NSMutableDictionary<NSNumber *, NSMutableSet<NSURL *> *> *logTargetToLogFileSet;

/** The log uploader instance to use. */
@property(nonatomic) GDLUploader *uploader;
@property(nonatomic) GDLUploadCoordinator *uploader;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@interface GDLRegistrar ()

/** A map of logTargets to backend implementations. */
@property(nonatomic) NSMutableDictionary<NSNumber *, id<GDLLogBackend>> *logTargetToBackend;
@property(nonatomic) NSMutableDictionary<NSNumber *, id<GDLLogUploader>> *logTargetToBackend;

/** A map of logTargets to prioritizer implementations. */
@property(nonatomic) NSMutableDictionary<NSNumber *, id<GDLLogPrioritizer>> *logTargetToPrioritizer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef void (^GDLBackendCompletionBlock)(NSSet<NSURL *> *_Nullable successfulUp
NSSet<NSURL *> *_Nullable unsuccessfulUploads);

/** This protocol defines the common interface for logging backend implementations. */
@protocol GDLLogBackend <NSObject>
@protocol GDLLogUploader <NSObject>

@required

Expand Down
14 changes: 11 additions & 3 deletions GoogleDataLogger/GoogleDataLogger/Classes/Public/GDLRegistrar.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@

#import <Foundation/Foundation.h>

#import <GoogleDataLogger/GDLLogBackend.h>
#import <GoogleDataLogger/GDLLogPrioritizer.h>
#import <GoogleDataLogger/GDLLogUploader.h>

NS_ASSUME_NONNULL_BEGIN

/** The list of targets supported by the shared logging infrastructure. */
typedef NS_ENUM(NSInteger, GDLLogTarget) {

/** The CCT log target. */
kGDLLogTargetCCT = 1000
};

/** Manages the registration of log targets with the logging SDK. */
@interface GDLRegistrar : NSObject

Expand All @@ -35,14 +42,15 @@ NS_ASSUME_NONNULL_BEGIN
* @param backend The backend object to register.
* @param logTarget The logTarget this backend object will be responsible for.
*/
- (void)registerBackend:(id<GDLLogBackend>)backend forLogTarget:(NSInteger)logTarget;
- (void)registerBackend:(id<GDLLogUploader>)backend forLogTarget:(GDLLogTarget)logTarget;

/** Registers a log prioritizer implementation with the GoogleDataLogger infrastructure.
*
* @param prioritizer The prioritizer object to register.
* @param logTarget The logTarget this prioritizer object will be responsible for.
*/
- (void)registerLogPrioritizer:(id<GDLLogPrioritizer>)prioritizer forLogTarget:(NSInteger)logTarget;
- (void)registerLogPrioritizer:(id<GDLLogPrioritizer>)prioritizer
forLogTarget:(GDLLogTarget)logTarget;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

#import "GDLLogBackend.h"
#import "GDLLogEvent.h"
#import "GDLLogPrioritizer.h"
#import "GDLLogProto.h"
#import "GDLLogTransformer.h"
#import "GDLLogUploader.h"
#import "GDLLogger.h"
#import "GDLRegistrar.h"
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

#import "GDLUploader.h"
#import "GDLUploadCoordinator.h"

NS_ASSUME_NONNULL_BEGIN

@interface GDLUploaderFake : GDLUploader
@interface GDLUploadCoordinatorFake : GDLUploadCoordinator

@property(nonatomic) BOOL forceUploadCalled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

#import "GDLUploaderFake.h"
#import "GDLUploadCoordinatorFake.h"

@implementation GDLUploaderFake
@implementation GDLUploadCoordinatorFake

- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(NSInteger)logTarget {
- (void)forceUploadLogs:(NSSet<NSURL *> *)logFiles target:(GDLLogTarget)logTarget {
self.forceUploadCalled = YES;
}

Expand Down
14 changes: 7 additions & 7 deletions GoogleDataLogger/Tests/Unit/GDLLogStorageTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@
#import "GDLRegistrar.h"
#import "GDLRegistrar_Private.h"

#import "GDLTestBackend.h"
#import "GDLTestPrioritizer.h"
#import "GDLTestUploader.h"

#import "GDLAssertHelper.h"
#import "GDLLogStorage+Testing.h"
#import "GDLRegistrar+Testing.h"
#import "GDLUploaderFake.h"
#import "GDLUploadCoordinatorFake.h"

static NSInteger logTarget = 1337;

@interface GDLLogStorageTest : GDLTestCase

/** The test backend implementation. */
@property(nullable, nonatomic) GDLTestBackend *testBackend;
@property(nullable, nonatomic) GDLTestUploader *testBackend;

/** The test prioritizer implementation. */
@property(nullable, nonatomic) GDLTestPrioritizer *testPrioritizer;

/** The uploader fake. */
@property(nonatomic) GDLUploaderFake *uploaderFake;
@property(nonatomic) GDLUploadCoordinatorFake *uploaderFake;

@end

@implementation GDLLogStorageTest

- (void)setUp {
[super setUp];
self.testBackend = [[GDLTestBackend alloc] init];
self.testBackend = [[GDLTestUploader alloc] init];
self.testPrioritizer = [[GDLTestPrioritizer alloc] init];
[[GDLRegistrar sharedInstance] registerBackend:_testBackend forLogTarget:logTarget];
[[GDLRegistrar sharedInstance] registerLogPrioritizer:_testPrioritizer forLogTarget:logTarget];
self.uploaderFake = [[GDLUploaderFake alloc] init];
self.uploaderFake = [[GDLUploadCoordinatorFake alloc] init];
[GDLLogStorage sharedInstance].uploader = self.uploaderFake;
}

Expand All @@ -66,7 +66,7 @@ - (void)tearDown {
self.testPrioritizer = nil;
[[GDLRegistrar sharedInstance] reset];
[[GDLLogStorage sharedInstance] reset];
[GDLLogStorage sharedInstance].uploader = [GDLUploader sharedInstance];
[GDLLogStorage sharedInstance].uploader = [GDLUploadCoordinator sharedInstance];
self.uploaderFake = nil;
}

Expand Down
4 changes: 2 additions & 2 deletions GoogleDataLogger/Tests/Unit/GDLLogUploaderTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "GDLTestCase.h"

#import "GDLUploader.h"
#import "GDLUploadCoordinator.h"

@interface GDLUploaderTest : GDLTestCase

Expand All @@ -26,7 +26,7 @@ @implementation GDLUploaderTest

/** Tests the default initializer. */
- (void)testSharedInstance {
XCTAssertEqual([GDLUploader sharedInstance], [GDLUploader sharedInstance]);
XCTAssertEqual([GDLUploadCoordinator sharedInstance], [GDLUploadCoordinator sharedInstance]);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

#import <Foundation/Foundation.h>

#import "GDLLogBackend.h"
#import "GDLLogUploader.h"

NS_ASSUME_NONNULL_BEGIN

/** This class implements the log backend protocol for testing purposes, providing APIs to allow
* tests to alter the uploader behavior without creating a bunch of specialized classes.
*/
@interface GDLTestBackend : NSObject <GDLLogBackend>
@interface GDLTestUploader : NSObject <GDLLogUploader>

/** A block that can be ran in -uploadLogs:onComplete:. */
@property(nullable, nonatomic) void (^uploadLogsBlock)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#import "GDLTestBackend.h"
#import "GDLTestUploader.h"

@implementation GDLTestBackend
@implementation GDLTestUploader

- (void)uploadLogs:(NSSet<NSURL *> *)logFiles onComplete:(GDLBackendCompletionBlock)onComplete {
if (_uploadLogsBlock) {
Expand Down