All Projects → smallnest → channels

smallnest / channels

Licence: MIT license
go channel patterns

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to channels

Protobuf-Dreamer
A tiled DeepDream project for creating any size of image, on both CPU and GPU
Stars: ✭ 39 (-54.65%)
Mutual labels:  channel, channels
calcipher
Calculates the best possible answer for multiple-choice questions using techniques to maximize accuracy without any other outside resources or knowledge.
Stars: ✭ 15 (-82.56%)
Mutual labels:  patterns
ImHex-Patterns
Hex patterns, include patterns and magic files for the use with the ImHex Hex Editor
Stars: ✭ 192 (+123.26%)
Mutual labels:  patterns
dagger2-clean-mvp-example
Sample project with a basic approach to CLEAN architecture on Android
Stars: ✭ 41 (-52.33%)
Mutual labels:  patterns
notes
My personal tutorials and notes.
Stars: ✭ 34 (-60.47%)
Mutual labels:  patterns
xlbaidumap flutter
flutter 集成百度地图
Stars: ✭ 27 (-68.6%)
Mutual labels:  channels
python-realtime-table
Building realtime table using Python and Channels
Stars: ✭ 12 (-86.05%)
Mutual labels:  channels
react-figma-ui
🏗️ React implementation for figma-plugin-ds
Stars: ✭ 25 (-70.93%)
Mutual labels:  patterns
File-Maker
Generate data files for Wii Channels that have the latest news, forecast data, etc.
Stars: ✭ 65 (-24.42%)
Mutual labels:  channels
livelog
A Django Channels example project to demonstrate the ASGI use case.
Stars: ✭ 20 (-76.74%)
Mutual labels:  channels
s3-practical-guide
A practical guide for Sociocracy 3.0.
Stars: ✭ 56 (-34.88%)
Mutual labels:  patterns
goodcode
A curated collection of annotated code examples from prominent open-source projects
Stars: ✭ 184 (+113.95%)
Mutual labels:  patterns
transceiver
Channel based event bus with request/reply pattern, using promises. For node & browser.
Stars: ✭ 25 (-70.93%)
Mutual labels:  channels
locast2tuner
Locast to Emby/Plex/Channels server
Stars: ✭ 51 (-40.7%)
Mutual labels:  channels
comfy-channel
A 24/7 live video broadcast with automatic content selection and overlays using FFMPEG and Python!
Stars: ✭ 37 (-56.98%)
Mutual labels:  channel
KubernetesPatterns
YAML and Golang implementations of common Kubernetes patterns.
Stars: ✭ 71 (-17.44%)
Mutual labels:  patterns
chanbroker
ChanBroker, a Broker for goroutine, is simliar to kafka
Stars: ✭ 61 (-29.07%)
Mutual labels:  channel
ops channel
命令通道是联接人与机器,人与业务的一座桥.它跟常用的开源运维工具(`ansible`,`saltstack`,`puppet`)有相似之处,但也有着本质的差异。
Stars: ✭ 34 (-60.47%)
Mutual labels:  channel
slide
do you slide on all your nights like this?
Stars: ✭ 17 (-80.23%)
Mutual labels:  patterns
Patterns
Patterns in different programming languages
Stars: ✭ 30 (-65.12%)
Mutual labels:  patterns

Channel 应用模式

Lock/TryLock模式

最高效的TryLock

trylock

使用Channel实现TryLock

trylock_channel

使用Channel实现Timeout功能的TryLock

trylock_timeout

or 信号模式

从多个channel读取一个信号, 一旦读取到一个信号,则不再读取。

比如向多个服务器发送相同的http request,每个请求的结果放在单独的一个channel中, 只要其中一个服务器返回结果,则其它请求就被忽略。

or channel by goroutine

or_channel_go

最简单的方式就是为每个channel启动一个goroutine, 每个goroutine读取自己负责的channel,一旦读取到一个信号,就关闭返回的channel。 显然,为每个channel启动一个goroutine太浪费了,虽然goroutine是一种轻量级的实现,但是如果数量巨大的情况下也会导致资源的大量占用以及调度上的性能低下。

or channel (递归)

or_channel 基于递归的方式实现, 使用依次递归的方式

or channel (递归)

or_channel_rec 基于递归的方式实现, 使用分而治之的方式

or channel reflect

or_channel_rec 基于反射的方式

or_done_channel模式

与上面的or 信号模式不同, or done channel模式是从一个channel中读取数据,只有当channel被关闭,或者done 信号channel被关闭的时候,读取操作才退出。

or_done_channel

如果将done这个信号channel换成 context,则可以依靠 context.WithCancel 来cancel读取,和这个模式类似。

flat 模式

flat 将多个channels平展成一个channels。 与Fan In不同的是,输入的channels是从一个channel中读取出来的,而Fan In模式中的channels是一个channel slice。

map/reduce 模式

mapreduce

Fan In 扇入模式

将多个channel合并成一个channel

fanIn

Fan Out 扇出模式

将一个Channel分成多个Channel。 有两种情况, 一种是每个channel都包含同样的数据(复制模式), 另一种将原数据均匀分布到各输出channel中(分布模式)

References

  1. https://github.com/kat-co/concurrency-in-go-src
  2. https://github.com/campoy/justforfunc/tree/master/27-merging-chans
  3. https://github.com/eapache/channels
  4. https://github.com/LK4D4/trylock
  5. https://github.com/lrita/gosync
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].