I'm writing an image uploading server, and by posting to an url, users can upload an image, and then from another url, they can retrieve it back.
The tricky part is that I want to compress the image after uploading. My current design is that uploading is finished as soon as the image is uploaded to the server, after which I spawn a goroutine to exec a command to do the compression. When the user requests the image , I'll wait for the command to finish if it still on going, after which I send the compressed image back. I have two questions: 1. Does the design sound right to you? 2. How do I tell if the image still being compressed? For #2, I currently use syncmap from 1.9. I store the file name as the key, and a wait group as the value. The wait group starts before I run the compression command, and is considered done when the command finishes. When an image request comes in, I check if the corresponding key exist, if not, it means the image is already compressed, so I just send it. If so, I wait on the wait group. Do you think that's the correct way of doing it? The part that bothers me is that this seem to be a common problem which is to track the progress of each individual goroutine. Having to rely on a feature that just came out worries me a little bit given the age of go. Do you think there is a more direct way to implement it? Thanks. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.