Похожие чаты

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

25 просмотров

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

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта