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?
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
The guy never mentioned whether the processes are distributed i.e on diff machines, which will everything utterly impossible using file approach.
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.
This is fine if scalability is not a key consideration.
What kind of a queue are we talking about? I thought of an html queue, that would require another API development
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.
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
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
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
Обсуждают сегодня