Skip to content

Commit

Permalink
iOS: split EnvoyEngine.h into multiple header files (#24397)
Browse files Browse the repository at this point in the history
Resolves envoyproxy/envoy-mobile#333

Signed-off-by: JP Simard <jp@jpsim.com>
  • Loading branch information
jpsim committed Dec 7, 2022
1 parent d3d4a01 commit ff9ab2b
Show file tree
Hide file tree
Showing 15 changed files with 561 additions and 483 deletions.
12 changes: 12 additions & 0 deletions mobile/library/objective-c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@ exports_files([
objc_library(
name = "envoy_engine_objc_lib",
srcs = [
"EnvoyAliases.h",
"EnvoyConfiguration.h",
"EnvoyConfiguration.m",
"EnvoyEngineImpl.m",
"EnvoyEventTracker.h",
"EnvoyEventTracker.m",
"EnvoyHTTPCallbacks.h",
"EnvoyHTTPCallbacks.m",
"EnvoyHTTPFilter.h",
"EnvoyHTTPFilter.m",
"EnvoyHTTPFilterCallbacksImpl.h",
"EnvoyHTTPFilterCallbacksImpl.m",
"EnvoyHTTPFilterFactory.h",
"EnvoyHTTPFilterFactory.m",
"EnvoyHTTPStream.h",
"EnvoyHTTPStreamImpl.m",
"EnvoyKeyValueStore.h",
"EnvoyLogger.h",
"EnvoyLogger.m",
"EnvoyNativeFilterConfig.h",
"EnvoyNativeFilterConfig.m",
"EnvoyNetworkMonitor.h",
"EnvoyNetworkMonitor.m",
"EnvoyStringAccessor.h",
"EnvoyStringAccessor.m",
],
hdrs = [
Expand Down
25 changes: 25 additions & 0 deletions mobile/library/objective-c/EnvoyAliases.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#import <Foundation/Foundation.h>

#import "library/common/types/c_types.h"

NS_ASSUME_NONNULL_BEGIN

/// Return codes for Engine interface. @see /library/common/types/c_types.h
extern const int kEnvoySuccess;
extern const int kEnvoyFailure;

/// A set of headers that may be passed to/from an Envoy stream.
typedef NSDictionary<NSString *, NSArray<NSString *> *> EnvoyHeaders;

typedef NSDictionary<NSString *, NSString *> EnvoyTags;

/// A set of key-value pairs describing an event.
typedef NSDictionary<NSString *, NSString *> EnvoyEvent;

/// Contains internal HTTP stream metrics, context, and other details.
typedef envoy_stream_intel EnvoyStreamIntel;

// Contains one time HTTP stream metrics, context, and other details.
typedef envoy_final_stream_intel EnvoyFinalStreamIntel;

NS_ASSUME_NONNULL_END
101 changes: 101 additions & 0 deletions mobile/library/objective-c/EnvoyConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#import <Foundation/Foundation.h>

@class EnvoyHTTPFilterFactory;
@class EnvoyNativeFilterConfig;
@class EnvoyStringAccessor;
@protocol EnvoyKeyValueStore;

NS_ASSUME_NONNULL_BEGIN

/// Typed configuration that may be used for starting Envoy.
@interface EnvoyConfiguration : NSObject

@property (nonatomic, assign) BOOL adminInterfaceEnabled;
@property (nonatomic, strong, nullable) NSString *grpcStatsDomain;
@property (nonatomic, assign) UInt32 connectTimeoutSeconds;
@property (nonatomic, assign) UInt32 dnsFailureRefreshSecondsBase;
@property (nonatomic, assign) UInt32 dnsFailureRefreshSecondsMax;
@property (nonatomic, assign) UInt32 dnsQueryTimeoutSeconds;
@property (nonatomic, assign) UInt32 dnsMinRefreshSeconds;
@property (nonatomic, strong) NSString *dnsPreresolveHostnames;
@property (nonatomic, assign) UInt32 dnsRefreshSeconds;
@property (nonatomic, assign) BOOL enableHappyEyeballs;
@property (nonatomic, assign) BOOL enableGzip;
@property (nonatomic, assign) BOOL enableBrotli;
@property (nonatomic, assign) BOOL enableInterfaceBinding;
@property (nonatomic, assign) BOOL enableDrainPostDnsRefresh;
@property (nonatomic, assign) BOOL enforceTrustChainVerification;
@property (nonatomic, assign) BOOL enablePlatformCertificateValidation;
@property (nonatomic, assign) UInt32 h2ConnectionKeepaliveIdleIntervalMilliseconds;
@property (nonatomic, assign) UInt32 h2ConnectionKeepaliveTimeoutSeconds;
@property (nonatomic, assign) BOOL h2ExtendKeepaliveTimeout;
@property (nonatomic, assign) UInt32 maxConnectionsPerHost;
@property (nonatomic, assign) UInt32 statsFlushSeconds;
@property (nonatomic, assign) UInt32 streamIdleTimeoutSeconds;
@property (nonatomic, assign) UInt32 perTryIdleTimeoutSeconds;
@property (nonatomic, strong) NSString *appVersion;
@property (nonatomic, strong) NSString *appId;
@property (nonatomic, strong) NSString *virtualClusters;
@property (nonatomic, strong) NSString *directResponseMatchers;
@property (nonatomic, strong) NSString *directResponses;
@property (nonatomic, strong) NSArray<EnvoyNativeFilterConfig *> *nativeFilterChain;
@property (nonatomic, strong) NSArray<EnvoyHTTPFilterFactory *> *httpPlatformFilterFactories;
@property (nonatomic, strong) NSDictionary<NSString *, EnvoyStringAccessor *> *stringAccessors;
@property (nonatomic, strong) NSDictionary<NSString *, id<EnvoyKeyValueStore>> *keyValueStores;
@property (nonatomic, strong) NSArray<NSString *> *statsSinks;

/**
Create a new instance of the configuration.
*/
- (instancetype)initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled
GrpcStatsDomain:(nullable NSString *)grpcStatsDomain
connectTimeoutSeconds:(UInt32)connectTimeoutSeconds
dnsRefreshSeconds:(UInt32)dnsRefreshSeconds
dnsFailureRefreshSecondsBase:(UInt32)dnsFailureRefreshSecondsBase
dnsFailureRefreshSecondsMax:(UInt32)dnsFailureRefreshSecondsMax
dnsQueryTimeoutSeconds:(UInt32)dnsQueryTimeoutSeconds
dnsMinRefreshSeconds:(UInt32)dnsMinRefreshSeconds
dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames
enableHappyEyeballs:(BOOL)enableHappyEyeballs
enableGzip:(BOOL)enableGzip
enableBrotli:(BOOL)enableBrotli
enableInterfaceBinding:(BOOL)enableInterfaceBinding
enableDrainPostDnsRefresh:(BOOL)enableDrainPostDnsRefresh
enforceTrustChainVerification:(BOOL)enforceTrustChainVerification
enablePlatformCertificateValidation:(BOOL)enablePlatformCertificateValidation
h2ConnectionKeepaliveIdleIntervalMilliseconds:
(UInt32)h2ConnectionKeepaliveIdleIntervalMilliseconds
h2ConnectionKeepaliveTimeoutSeconds:(UInt32)h2ConnectionKeepaliveTimeoutSeconds
h2ExtendKeepaliveTimeout:(BOOL)h2ExtendKeepaliveTimeout
maxConnectionsPerHost:(UInt32)maxConnectionsPerHost
statsFlushSeconds:(UInt32)statsFlushSeconds
streamIdleTimeoutSeconds:(UInt32)streamIdleTimeoutSeconds
perTryIdleTimeoutSeconds:(UInt32)perTryIdleTimeoutSeconds
appVersion:(NSString *)appVersion
appId:(NSString *)appId
virtualClusters:(NSString *)virtualClusters
directResponseMatchers:(NSString *)directResponseMatchers
directResponses:(NSString *)directResponses
nativeFilterChain:
(NSArray<EnvoyNativeFilterConfig *> *)nativeFilterChain
platformFilterChain:
(NSArray<EnvoyHTTPFilterFactory *> *)httpPlatformFilterFactories
stringAccessors:
(NSDictionary<NSString *, EnvoyStringAccessor *> *)
stringAccessors
keyValueStores:
(NSDictionary<NSString *, id<EnvoyKeyValueStore>> *)
keyValueStores
statsSinks:(NSArray<NSString *> *)statsSinks;

/**
Resolves the provided configuration template using properties on this configuration.
@param templateYAML The template configuration to resolve.
@return The resolved template. Nil if the template fails to fully resolve.
*/
- (nullable NSString *)resolveTemplate:(NSString *)templateYAML;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit ff9ab2b

Please sign in to comment.