This advice from a police dog handler: If you can't outrun a dog, it's best to stop and put the bike between you and the bike. A dog in attack mode will run through a cloud of mace and have his teeth on you before the mace can have any effect. Edit: an addition here: After you are stopped, get yourself out of the dog's territory, but in doing so keep the bike between you and always keep facing the dog. If you turn your back to it, it will attack.
Like mace, air horns are best used when the dog is still sizing you up, at point-blank range. Speaking as a gun owner, I don't think guns are a very good choice for cyclists. If you're willing to go the deadly force route, a hunting knife would have several advantages. Lighter, just as deadly at arm's length range, no licensing issues, safer for your buddies, dogs know what it is so just seeing it will back down many of them, and if you have to use it, there will be no question about whether or not the dog was really attacking you. Also there's no bang, so the owner won't immediately know that Fluffy is dead and come looking for you with his 3/4 ton P/U truck.