Похожие чаты

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 ответов

7 просмотров

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

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

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

@LGCYMan @JustinKKW Q/A List 1. this part confuses me on #8: "From there, a bridge between erc20 LGXY and erc20 LGXY will be out once that swap is closed." does this mean ...
Sig | LGCY | BattleVerse L1 | BitWin
1
Did @Beeker really get banned? That's ridiculous. He's one of the few left here with half a brain and you might not always like his narrative @dgb_ycagel , but he often keeps ...
Leroy Gerrits
1
async login(req: Request, res: Response, next: NextFunction): Promise<void> { try { const { errors, input } = await RequestValidator(LoginRequest, req.body...
. .
1
Anyone here suffers from unexplained aural migraines, who would be up for talking for a bit? Doesn't *have* to be aural, but I am not asking about headaches, I mean actual mi...
Martin Rys
55
Я тут за тем, чтобы задать вопрос, так как не знаю ассемблер, учу с/с++. Короче, насколько дорога операция перехода в функцию при ее вызове? Дело в том, что в с++ есть макросы...
Максим Рябцев
11
hello friends. Do you know how can I learn getx? I have a software project that I should deliver it up to 5 weeks later and I need to learn firebase too. I will be thankfull
AmirHossein Razavi
15
Доброе время суток! у меня тут иноды закончились. и понял почему по сути кстит, я периодически очищаю постгрес и сентри контайнер: postgres=# DELETE FROM nodestore_node WHER...
Юсиф Насиров
9
A couple thoughts from a random internet stranger: 1. If you want this project to gain traction you cannot keep being negative. If I just came here after finding out about Kd...
Eric Wild
46
Привет, нужен совет старших товарищей. Есть глобальная переменная var DefaultDataFolder:string; инициализируем DefaultDataFolder:='a:\_OUT\'; есть примитивная процедур...
Max Otto
14
Hello guys, I have staked Matic as stMatic via Lido nearly a year ago and recently I wanted to unstake but the platform offered me to unstake via Kyberswap for a faster trans...
Mike
7
Карта сайта