Skip to content

Commit

Permalink
objc: move EnvoyEngine streaming calls to protocol (#311)
Browse files Browse the repository at this point in the history
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 <me@michaelrebello.com>
Signed-off-by: JP Simard <jp@jpsim.com>
  • Loading branch information
rebello95 authored and jpsim committed Nov 29, 2022
1 parent 9ca8e25 commit f0fb946
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions mobile/library/objective-c/EnvoyEngine.h
Expand Up @@ -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.
Expand Down Expand Up @@ -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 <EnvoyEngineStreamInterface>

/**
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;
Expand Down

0 comments on commit f0fb946

Please sign in to comment.