Detecting file changes
Now we need to focus on our file listener. You may recall this is the part of the application that will accept client connections from our web server and our backup application and announce any changes to files.
The basic flow of this part is as follows:
- Listen for changes to files in a goroutine.
- Accept connections and add to the pool in a goroutine.
- If any changes are detected, announce them to the entire pool.
All three happen concurrently, and the first and the third can happen without any connections in the pool, although we assume there will be a connection that is always on with both our web server and our backup application.
Another critical role the file listener will fulfill is analyzing the directory on first load and ...