From f0fb9460aeb6ec3411023ce035bdf59ac286dda2 Mon Sep 17 00:00:00 2001 From: Michael Rebello Date: Mon, 29 Jul 2019 15:06:36 -0700 Subject: [PATCH] objc: move EnvoyEngine streaming calls to protocol (#311) Moves the streaming method requirements out of the `EnvoyEngine` class and into a protocol interface. Swift will then take a conformer to this protocol instead of calling directly into `EnvoyEngine`, which will allow us to inject mock conformers for better testing. We'll do this on Android as well. Signed-off-by: Michael Rebello Signed-off-by: JP Simard --- mobile/library/objective-c/EnvoyEngine.h | 43 +++++++++++++----------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/mobile/library/objective-c/EnvoyEngine.h b/mobile/library/objective-c/EnvoyEngine.h index e24eb537f4b6..56338f5890ac 100644 --- a/mobile/library/objective-c/EnvoyEngine.h +++ b/mobile/library/objective-c/EnvoyEngine.h @@ -4,25 +4,8 @@ NS_ASSUME_NONNULL_BEGIN -/// Wrapper layer to simplify calling into Envoy's C/++ API. -@interface EnvoyEngine : NSObject - -/** - Run the Envoy engine with the provided config and log level. - - @param config The configuration file with which to start Envoy. - @return A status indicating if the action was successful. - */ -+ (EnvoyStatus)runWithConfig:(NSString *)config; - -/** - Run the Envoy engine with the provided config and log level. - - @param config The configuration file with which to start Envoy. - @param logLevel The log level to use when starting Envoy. - @return A status indicating if the action was successful. - */ -+ (EnvoyStatus)runWithConfig:(NSString *)config logLevel:(NSString *)logLevel; +/// Protocol interface for streaming with the Envoy engine. +@protocol EnvoyEngineStreamInterface /** Open an underlying HTTP stream. @@ -88,6 +71,28 @@ NS_ASSUME_NONNULL_BEGIN */ + (EnvoyStatus)resetStream:(EnvoyStream *)stream; +@end + +/// Wrapper layer for calling into Envoy's C/++ API. +@interface EnvoyEngine : NSObject + +/** + Run the Envoy engine with the provided config and log level. + + @param config The configuration file with which to start Envoy. + @return A status indicating if the action was successful. + */ ++ (EnvoyStatus)runWithConfig:(NSString *)config; + +/** + Run the Envoy engine with the provided config and log level. + + @param config The configuration file with which to start Envoy. + @param logLevel The log level to use when starting Envoy. + @return A status indicating if the action was successful. + */ ++ (EnvoyStatus)runWithConfig:(NSString *)config logLevel:(NSString *)logLevel; + /// Performs necessary setup after Envoy has initialized and started running. /// TODO: create a post-initialization callback from Envoy to handle this automatically. + (void)setupEnvoy;