docs: 微服务平台下基于 GraphQL 构建 BFF 的思考changeLog

This commit is contained in:
LiuBinPeng
2021-11-29 09:50:54 +08:00
parent 6ec45450a2
commit 2c4b8c577c
40 changed files with 1175 additions and 30 deletions

View File

@@ -263,8 +263,8 @@ typedef CF_OPTIONS(CFOptionFlags, CFRunLoopActivity) {
kCFRunLoopBeforeTimers , // 触发 Timer 回调
kCFRunLoopBeforeSources , // 触发 Source0 回调
kCFRunLoopBeforeWaiting , // 等待 mach_port 消息
kCFRunLoopAfterWaiting ), // 接收 mach_port 消息
kCFRunLoopExit , // 退出 loop
kCFRunLoopAfterWaiting, // 接收 mach_port 消息
kCFRunLoopExit, // 退出 loop
kCFRunLoopAllActivities // loop 所有状态改变
}
```
@@ -2678,24 +2678,24 @@ CFNetwork 使用 CFReadStreamRef 来传递数据,使用回调函数的形式
```objective-c
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
// 为 NSURLConnection、NSURLSession、CFNetwork 代理设置代理转发
@interface NetworkDelegateProxy : NSProxy
+ (instancetype)setProxyForObject:(id)originalTarget withNewDelegate:(id)newDelegate;
@end
NS_ASSUME_NONNULL_END
// .m
@interface NetworkDelegateProxy () {
id _originalTarget;
id _NewDelegate;
}
@end
```
@@ -2797,7 +2797,7 @@ CFNetwork 使用 CFReadStreamRef 来传递数据,使用回调函数的形式
```objective-c
// NSURLConnection+Monitor.m
@implementation NSURLConnection (Monitor)
+ (void)load
{
static dispatch_once_t onceToken;
@@ -2807,7 +2807,7 @@ CFNetwork 使用 CFReadStreamRef 来传递数据,使用回调函数的形式
}
});
}
- (_Nonnull instancetype)apm_initWithRequest:(NSURLRequest *)request delegate:(nullable id)delegate
{
/*
@@ -2823,23 +2823,23 @@ CFNetwork 使用 CFReadStreamRef 来传递数据,使用回调函数的形式
return [self apm_initWithRequest:rq delegate:delegate];
} else {
[rq setValue:traceId forHTTPHeaderField:@"head_key_traceid"];
NSURLSessionAndConnectionImplementor *mockDelegate = [NSURLSessionAndConnectionImplementor new];
[self registerDelegateMethod:@"connection:didFailWithError:" originalDelegate:delegate newDelegate:mockDelegate flag:"v@:@@"];
[self registerDelegateMethod:@"connection:didReceiveResponse:" originalDelegate:delegate newDelegate:mockDelegate flag:"v@:@@"];
[self registerDelegateMethod:@"connection:didReceiveData:" originalDelegate:delegate newDelegate:mockDelegate flag:"v@:@@"];
[self registerDelegateMethod:@"connection:didFailWithError:" originalDelegate:delegate newDelegate:mockDelegate flag:"v@:@@"];
[self registerDelegateMethod:@"connectionDidFinishLoading:" originalDelegate:delegate newDelegate:mockDelegate flag:"v@:@"];
[self registerDelegateMethod:@"connection:willSendRequest:redirectResponse:" originalDelegate:delegate newDelegate:mockDelegate flag:"@@:@@"];
delegate = [NetworkDelegateProxy setProxyForObject:delegate withNewDelegate:mockDelegate];
// 调用 hook 之前的初始化方法,返回 NSURLConnection
return [self apm_initWithRequest:rq delegate:delegate];
}
}
- (void)registerDelegateMethod:(NSString *)methodName originalDelegate:(id<NSURLConnectionDelegate>)originalDelegate newDelegate:(NSURLSessionAndConnectionImplementor *)newDelegate flag:(const char *)flag
{
if ([originalDelegate respondsToSelector:NSSelectorFromString(methodName)]) {
@@ -2853,7 +2853,7 @@ CFNetwork 使用 CFReadStreamRef 来传递数据,使用回调函数的形式
class_addMethod([originalDelegate class], NSSelectorFromString(methodName), class_getMethodImplementation([newDelegate class], NSSelectorFromString(methodName)), flag);
}
}
@end
```
@@ -2897,10 +2897,10 @@ CFNetwork 使用 CFReadStreamRef 来传递数据,使用回调函数的形式
struct objc_object {
Class _Nonnull isa OBJC_ISA_AVAILABILITY;
};
/// A pointer to an instance of a class.
typedef struct objc_object *id;
```
![isa swizzling](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/2020-04-13-isaSwizzling.png)
@@ -3324,7 +3324,7 @@ typedef CFHTTPMessageRef (*APMURLResponseFetchHTTPResponse)(CFURLRef response);
- (void)stopLoadi
{
[self.internalConnection cancel];
HCTNetworkTrafficModel *model = [[HCTNetworkTrafficModel alloc] init];
model.path = self.request.URL.path;
model.host = self.request.URL.host;
@@ -3489,7 +3489,7 @@ typedef CFHTTPMessageRef (*APMURLResponseFetchHTTPResponse)(CFURLRef response);
self.internalResponse = response;
[self.client URLProtocol:self wasRedirectedToRequest:request redirectResponse:response];
}
HCTNetworkTrafficModel *model = [[HCTNetworkTrafficModel alloc] init];
model.path = request.URL.path;
model.host = request.URL.host;
@@ -3499,7 +3499,7 @@ typedef CFHTTPMessageRef (*APMURLResponseFetchHTTPResponse)(CFURLRef response);
model.bodyLength = [connection.currentRequest dgm_getBodyLength];
model.emptyLineLength = [self.internalResponse apm_getEmptyLineLength];
model.length = model.lineLength + model.headerLength + model.bodyLength + model.emptyLineLength;
NSDictionary *networkTrafficDictionary = [model convertToDictionary];
[[HermesClient sharedInstance] sendWithType:APMMonitorNetworkTrafficType meta:networkTrafficDictionary payload:nil];
return request;

4
Chapter1 - iOS/1.97.md Normal file
View File

@@ -0,0 +1,4 @@
# __attribute__ 的骚操作
https://mp.weixin.qq.com/s/FTC-IYVCqzGU-00nj5bVfw
https://www.jianshu.com/p/965f6f903114

1132
Chapter1 - iOS/1.98.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -98,4 +98,7 @@
* [92、flutter 无痕埋点](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.92.md)
* [93、flutter 新功能引导](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.93.md)
* [94、APM-Wake Up](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.94.md)
* [95、从 flutter 和前端角度出发,聊聊单线程模型下如何保证 UI 流畅性](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.95.md)
* [95、从 flutter 和前端角度出发,聊聊单线程模型下如何保证 UI 流畅性](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.95.md)
* [96、一个提高 App 运算性能的想法](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.96.md)
* [97、__attribute__ 的骚操作](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.97.md)
* [98、前端、BFF、后端一些常见的设计模式](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.98.md)