Похожие чаты

Hey guys. I'm working on a crawler that writes data

to a file, crawlers can be multiple processes writing to the same file. So how shall I implement sync mutex on files between multiple go apps?

10 ответов

22 просмотра

Why don't you pass all outputs to a queue to be written in order? You could have a single queue worker reading from a chan or whatever, writing to the file. No race condition, everyone happy

AYUB
Why don't you pass all outputs to a queue to be wr...

The guy never mentioned whether the processes are distributed i.e on diff machines, which will everything utterly impossible using file approach.

Thirteen
The guy never mentioned whether the processes are ...

Doesn't need a file. One binary, several goroutines crawling and pushing the result into a channel(queue). Then another goroutine(queue worker) consumes data to be written to the file one by one.

AYUB
Doesn't need a file. One binary, several goroutine...

This is fine if scalability is not a key consideration.

ㅤ- Автор вопроса
AYUB
Why don't you pass all outputs to a queue to be wr...

What kind of a queue are we talking about? I thought of an html queue, that would require another API development

ㅤ- Автор вопроса
Thirteen
The guy never mentioned whether the processes are ...

It's on the same machine/server. Golang will crawl the web and put data in json files, PHP will process the data. I'm only responsible for Golang.

ㅤ- Автор вопроса
AYUB
Doesn't need a file. One binary, several goroutine...

Don't forget that I'm talking about multiple processes, if it was just one, I'd go with sync mutex or channels. What I'm looking for is a sync mutex shared between multiple apps/processes


What kind of a queue are we talking about? I thoug...

Shouldn’t be that much! You could keep it simple and write an endpoint which is accepting the data and it stupidly adds it to a channel. Then you can use your current file handler which is getting data from the channel

ㅤ- Автор вопроса
Mark X
Shouldn’t be that much! You could keep it simple a...

It even made the bot that mentioned you to freak out lol. So I guess using a tcp channel is the closest I can get. Hope I could make them change their mind, or get some rest because I feel like I'm overthinking it

Похожие вопросы

Обсуждают сегодня

Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Добрый вечер. Есть вопрос, а может и предложение. Был у меня диалог в другой группе о делфи и я задался вопросом: "А нельзя ли в делфи цвет //коментария и {комментария} сде...
Kraszx
24
Всем привет! Подскажи, пожалуйста, как передать в TComboBox сразу значение и id записи. На Delphi я делал так: ComboBox1.Items.AddObject('Какое-то значение', Pointer(id запис...
Евгений
13
Мдя, прикол, боевая сборка запускается (именно под отладчиком) после F9 примерно полторы минуты (97 секунд если быть точным). Начал копать - проблема детектится сразу - зависа...
Александр (Rouse_) Багель
38
How are we going bro about the Raids ??
🅿️abby_FX
13
я так понимаю, я так подозреваю, что создание такого плагина для человека, кто умеет писать плагины для делфи потребует минут 5-10 времени. но это мое подозрение. хотелось бы ...
Kraszx
7
Товарищи, кто работа с iphelper? Или может я в самой логике ошибки фигачу, не пойму.... var ifTable : PMIB_IFTABLE; size, corSize: DWORD; Buffer ...
Warfarellen
4
Здравствуйте, вопрос по структурам данных. Были у вас случаи, когда пришлось писать деревья или двунаправленные списки?
/ /
50
Keep saying it, it’s Trump or WW3. Iran will be emboldened if Harris wins by cheating. Israel will have to take the initiative against Iran. How has BTC faired everytime the...
Adz | Ferrum Network Product & Service Consultant @ Ferrum Network
1
Коллеги, добрый вечер. Создаю коллекцию от TFPGMap, ключ - перечисление, значение - целое. Нужно отсортировать коллекцию по значению. Как это можно сделать?
Kirill Filippenok
11
Карта сайта