Skip to content

Commit

Permalink
objc: convert EnvoyEngine into a protocol (#324)
Browse files Browse the repository at this point in the history
This was originally going to be done as part of envoyproxy/envoy-mobile#316, but we ran into build issues.

Making this change will allow us to mock `EnvoyEngine` from the Swift/Kotlin platform layers.

Signed-off-by: Michael Rebello <me@michaelrebello.com>
Signed-off-by: JP Simard <jp@jpsim.com>
  • Loading branch information
rebello95 authored and jpsim committed Nov 29, 2022
1 parent d1b79af commit d00b5df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion mobile/library/objective-c/EnvoyEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef NSDictionary<NSString *, NSArray<NSString *> *> EnvoyHeaders;
@end

/// Wrapper layer for calling into Envoy's C/++ API.
@interface EnvoyEngine : NSObject
@protocol EnvoyEngine

/**
Run the Envoy engine with the provided config and log level.
Expand All @@ -85,6 +85,11 @@ typedef NSDictionary<NSString *, NSArray<NSString *> *> EnvoyHeaders;

@end

// Concrete implementation of the `EnvoyEngine` protocol.
@interface EnvoyEngineImpl : NSObject <EnvoyEngine>

@end

@interface EnvoyHttpStream : NSObject
/**
Open an underlying HTTP stream.
Expand Down
2 changes: 1 addition & 1 deletion mobile/library/objective-c/EnvoyEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@implementation EnvoyObserver
@end

@implementation EnvoyEngine
@implementation EnvoyEngineImpl

#pragma mark - class methods
+ (int)runWithConfig:(NSString *)config {
Expand Down
2 changes: 1 addition & 1 deletion mobile/library/swift/src/Envoy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class Envoy: NSObject {
}

override func main() {
EnvoyEngine.run(withConfig: self.config, logLevel: self.logLevel.stringValue)
EnvoyEngineImpl.run(withConfig: self.config, logLevel: self.logLevel.stringValue)
}
}
}

0 comments on commit d00b5df

Please sign in to comment.