From d020f12a2b18de5e7a5d4e82fcfba04f3af6f37e Mon Sep 17 00:00:00 2001 From: Edward Date: Thu, 7 May 2020 11:47:50 +0800 Subject: [PATCH] update README.md for context and fan_in --- cspell.json | 37 +++++++++++++++++++------------------ gomore/03_context/README.md | 6 +++++- gomore/04_fan_in/README.md | 11 +++++++++++ 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/cspell.json b/cspell.json index 124e443..053f509 100644 --- a/cspell.json +++ b/cspell.json @@ -7,24 +7,25 @@ "enabled": true, // words - list of words to be always considered correct "words": [ - "Goroutines", - "Stateful", - "Structs", - "bber", - "crazybber", - "ifelse", - "iostream", - "istack", - "karlseguin", - "logrusorgru", - "mongodb", - "nums", - "postgres", - "stretchr", - "struct", - "xargs", - "gomore", - "stackless" + "bber", + "crazybber", + "fanin", + "gomore", + "Goroutines", + "ifelse", + "iostream", + "istack", + "karlseguin", + "logrusorgru", + "mongodb", + "nums", + "postgres", + "stackless", + "Stateful", + "stretchr", + "struct", + "Structs", + "xargs" ], // flagWords - list of words to be always considered incorrect // This is useful for offensive words and common spelling errors. diff --git a/gomore/03_context/README.md b/gomore/03_context/README.md index 66fe232..fcdea5a 100644 --- a/gomore/03_context/README.md +++ b/gomore/03_context/README.md @@ -1,3 +1,7 @@ # 上下文模式 -用于取消一个操作,可能是一个http请求,可能是一个Channel消息队列. +上下文模式,就是使用上下传递参数,或者传递操作。 + +其实在,观察者模式中,就有用到上下文模式传递参数:[观察模式中的上下文模式](../../behavior/03_observer) + +这是演示,使用context取消http请求的场景。 diff --git a/gomore/04_fan_in/README.md b/gomore/04_fan_in/README.md index 084859a..8db6f12 100644 --- a/gomore/04_fan_in/README.md +++ b/gomore/04_fan_in/README.md @@ -1 +1,12 @@ # 淡入模式 + +或者叫做扇入模式,漏入模式,是一种消息传递模式,用于在工作组件(客户端:源、服务器:目标)之间创建聚合工作。 + +对于Go其本质是:将多个channel的消息/数据合并到一个,达到聚合的目的。 + +这里演示一个数据流,求和的例子。 + +注意,这里演示两种FanIn方式: + ++ 一种方式是多个Goroutine同时进行合并多个输入的channel. ++ 另一种方式是一个goroutine同时合并多个输入的channel数据。