Giter Club home page Giter Club logo

gochan's Introduction

gochan

中文说明文档

background

In general, a buffered channel variable is defined with a dedicated goroutine to execute the specific events in channel.

If there are so many events that a single gorotine is not enough, may more goroutines are created to execute events. However, it is not okey if some events need to be executed sequentially.

Two events, for example, one order payment and goods delivery of that order, need to be executed sequentially. At the same time, events of different orders can be executed concurrently. So that we can push events of the same order to the same buffer channel, and a specific goroutine to execute the events in the queue.

Concurrency is achieved by expanding multiple similar combinations (a buffer channel and its specific goroutine) in parallel.

Usual design

a buffered channel variable is defined with a dedicated goroutine to execute the specific events in channel

event ->
        |
event -> buffer-channel -> goroutine
        |
event ->

State-independent concurrent design

There is no state dependency between events, so you can simply extend goroutine to speed up event execution.

event ->                 ->goroutine
        |               |
event -> buffer-channel -> goroutine
        |               |
event ->                 ->goroutine

State-dependent concurrent design (as gochan does)

Introduce a layer of dispatcher to distribute events to the corresponding buffer-channel according to a feature such as uuid.

event ->              -> buffer-channel -> goroutine
        |            |
event --> dispatcher -> buffer-channel -> goroutine
        |            |
event ->              -> buffer-channel -> goroutine

example

you can find example in examples.

gochan's People

Contributors

chalvern avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.