H
H
hitakiri2017-08-22 21:32:29
go
hitakiri, 2017-08-22 21:32:29

What is the best way to collect data from several streams, for subsequent sending to the client?

There are about 40 functions divided logically into packages, each package works in a separate thread, and a web server for GUI implementation (a simple client on a web socket) also works in a separate thread. The functions are very simple - for working with the file system (checking the existence of files, copying files, renaming, etc.).
The problem is that each function passes a lot of different types of information to the client. Now the transfer is implemented as a crutch from a large structure, which is filled by a timer with data from each function and then sent to the client.
Most likely, there are some ready-made solutions or patterns for this task. But unfortunately I can not find solutions yet, maybe someone solved a similar problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
evnuh, 2017-08-22
@evnuh

Why bother with Go if you don't understand its basic "share by communication" paradigm?
You here, from what I understand, definitely need channels. Because there are many threads + one structure + filling by timer, it makes you think that a complete mess is going on.
Describe the problem better.

M
mukizu, 2017-08-23
@mukizu

From what I understand it is banal https://gobyexample.com/worker-pools

K
kmg4e, 2017-08-24
@kmg4e

Now the transfer is implemented as a crutch from a large structure, which is filled by a timer with data from each function and then sent to the client.

Why is it a crutch?
If the client needs all this data only at once, then you need a large structure. You won't go anywhere.
The only thing is that if you want to somehow more efficiently parallelize this business, then it is better to write to the structure not by a timer, but to wait for data from different channels at the collection point of the structure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question