������Я�̼���Butters������ԭ�⡰�ɻ� | �վ�����200�ڣ�Я�̸�����ȫ�첽����ʵ��������ʱͨѶ�������������Ű档
cover_opti.png (11.8 KB, ���ش���: 1)
���ظ��� ���浽����
8 ��ǰ �ϴ�
1.png (20.57 KB, ���ش���: 0)
18 ��ǰ �ϴ�
2.png (7.83 KB, ���ش���: 0)
ȫ�첽 = server���첽 + ҵ�������첽 + client���첽
3.png (26.71 KB, ���ش���: 1)
public interface Processor<T> { ProcessorType getType(); int getOrder(); boolean shouldProcess(RequestContext context); //����ͳһ��װΪMaybe Maybe<T> process(RequestContext context) throws Exception; }
public abstract class AbstractProcessor implements Processor { //ͬ��&����Ӧ���̳д˷��� //����������ҵ������ protected void processSync(RequestContext context) throws Exception {} //ͬ��&����Ӧ���̳д˷������������� //�������������⡢δͨ��У��ʱ�ľ�̬��Ӧ protected T processSyncAndGetReponse(RequestContext context) throws Exception { process(context); return null; }; //�첽���̳д˷��� //��������֤����Ȩ���漰Զ�̵��õ�ģ�� protected Maybe<T> processAsync(RequestContext context) throws Exception { T response = processSyncAndGetReponse(context); if (response == null) { return Maybe.empty(); } else { return Maybe.just(response); } }; @Override public Maybe<T> process(RequestContext context) throws Exception { Maybe<T> maybe = processAsync(context); if (maybe instanceof ScalarCallable) { //��ʶͬ������������������װ return maybe; } else { //ͳһ�ӳ�ʱ��Ĭ�Ϻ��Դ��� return maybe.timeout(getAsyncTimeout(context), TimeUnit.MILLISECONDS, Schedulers.from(context.getEventloop()), timeoutFallback(context)); } } protected long getAsyncTimeout(RequestContext context) { return 2000; } protected Maybe<T> timeoutFallback(RequestContext context) { return Maybe.empty(); }
public class RxUtil{ //����ij�Σ���Inbound���ڵĶ���filter����Callable<Maybe<T>>�� public static <T> Maybe<T> concat(Iterable<? extends Callable<Maybe<T>>> iterable) { Iterator<? extends Callable<Maybe<T>>> sources = iterable.iterator(); while (sources.hasNext()) { Maybe<T> maybe; try { maybe = sources.next().call(); } catch (Exception e) { return Maybe.error(e); } if (maybe != null) { if (maybe instanceof ScalarCallable) { //ͬ������ T response = ((ScalarCallable<T>)maybe).call(); if (response != null) { //��response���ж� return maybe; } } else { //�첽���� if (sources.hasNext()) { //��sources�����ص�������filter�ظ����� return new ConcattedMaybe(maybe, sources); } else { return maybe; } } } } return Maybe.empty(); } }
public class ProcessEngine{ //�����Σ�����Ĭ�ϳ�ʱ���������� private void process(RequestContext context) { List<Callable<Maybe<Response>>> inboundTask = get(ProcessorType.INBOUND, context); List<Callable<Maybe<Void>>> outboundTask = get(ProcessorType.OUTBOUND, context); List<Callable<Maybe<Response>>> errorTask = get(ProcessorType.ERROR, context); List<Callable<Maybe<Void>>> logTask = get(ProcessorType.LOG, context); RxUtil.concat(inboundTask) //inbound�� .toSingle() //��ȡresponse .flatMapMaybe(response -> { context.setOriginResponse(response); return RxUtil.concat(outboundTask); }) //����outbound .onErrorResumeNext(e -> { context.setThrowable(e); return RxUtil.concat(errorTask).flatMap(response -> { context.resetResponse(response); return RxUtil.concat(outboundTask); }); }) //�쳣������error�������½���outbound .flatMap(response -> RxUtil.concat(logTask)) //��־�� .timeout(asyncTimeout.get(), TimeUnit.MILLISECONDS, Schedulers.from(context.getEventloop()), Maybe.error(new ServerException(500, "Async-Timeout-Processing")) ) //ȫ�ֶ��׳�ʱ .subscribe( //�ͷ���Դ unused -> { logger.error("this should not happen, " + context); context.release(); }, e -> { logger.error("this should not happen, " + context, e); context.release(); }, () -> context.release() ); } }
4.png (9.8 KB, ���ش���: 1)
5.png (11.75 KB, ���ش���: 1)
6.png (12.51 KB, ���ش���: 1)
7.png (11.68 KB, ���ش���: 1)
8.png (100.86 KB, ���ش���: 0)
9.png (121.86 KB, ���ش���: 1)
10.png (30.72 KB, ���ش���: 1)
11.png (31.5 KB, ���ش���: 2)
12.png (12.49 KB, ���ش���: 1)
13.png (25.01 KB, ���ش���: 1)
{ //ƥ�䷽ʽ "type": "uri", //HTTPĬ�ϲ���uriǰƥ�䣬�ڲ�ͨ�����ṹѰַ��˽��Э�飨SOTP��ͨ������Ψһ��ʶ��λ�� "value": "/hotel/order", "matcherType": "prefix", //��ǩ������ //����portal��Ȩ���������������У��簴����/�Ǻ��ģ��� "tags": [ "owner_admin", "org_framework", "appId_123456" ], "properties": { "core": "true" }, //endpoint��Ϣ "routes": [{ //condition���ڶ���·�ɣ��簴app�汾���֡���query�ط����� "condition": "true", "conditionParam": {}, "zone": "PRO", //����������ַ��Ȩ�����ڻҶȳ��� "targets": [{ "url": "http://test.ctrip.com/hotel", "weight": 100 } ] }] }
14.png (28.86 KB, ���ش���: 1)
{ //ģ�����ƣ���Ӧ�����ڲ�ij������ģ�� "name": "addResponseHeader", //ִ�н� "stage": "PRE_RESPONSE", //ִ��˳�� "ruleOrder": 0, //�Ҷȱ��� "grayRatio": 100, //ִ������ "condition": "true", "conditionParam": {}, //ִ�в��� //����${}��ʽ������ģ�壬���ڻ�ȡ����ʱ���� "actionParam": { "connection": "keep-alive", "x-service-call": "${request.func.remoteCost}", "Access-Control-Expose-Headers": "x-service-call", "x-gate-root-id": "${func.catRootMessageId}" }, //�쳣������ʽ�������׳������� "exceptionHandle": "return" }
��Դ����ʱͨѶ�� - ��ʱͨѶ������������
��������Դ�ƶ��˼�ʱͨѶ���ܡ�
�������� / ���� / ָ�� / ����
������Web�˼�ʱͨѶ���ܡ�
��ϸ���� / ����Դ�� / �ֲ��̳�
�ƶ���ʵʱ����Ƶ���ܡ�
��ϸ���� / ���ܲ��� / ��װ����
����MobileIMSDK���ƶ�IMϵͳ��
��ϸ���� / ��Ʒ��ͼ / ��װ����
һ�ײ�Ʒ��Web��IMϵͳ��
��ϸ���� / ��Ʒ��ͼ / ��ʾ��Ƶ
һ�״�Ѫ����NEXT��Ʒ��IMϵͳ��
��ϸ���� / ��Ʒ��ͼ / ��װ
��������������100����
������ְ��2�����ϵĺϸ���ʽ����
Ϊ��������ͻ�����Ŀ����ߡ������ȡ�
Copyright © 2014-2024 ��ʱͨѶ�� - ��ʱͨѶ���������� / �汾 V4.4
��������ʱ����Ϣ�Ƽ�����˾ (��ICP��16005070��-1��
Processed in 0.218759 second(s), 43 queries , Gzip On.