and implemented a telegram bot which fetches my bot updates from telegram server and processes it , how to make this process concurrent without having two thdreads processing the same update ?
For instance : two users send a message to the bot at same time i want each thread to process a particular message concurently ( update ) , thinking of a way to allow a thread to work only when the first thread has fetched an update and then have set a flag to declare it is currently processing this particular update hence allowing the rest for others threads to work on .
Put updates in a channel and read from them in a loop Launch goroutines per update (or whatever your preferred threading model, maybe you prefer a pool of goroutines)
ok , so i have a process with fetches updates and store it in a channel
Обсуждают сегодня