We might want to think about extracting this to a data structure that handles its own locking; the client shouldn't need a lock itself. Check out this as an example: https://github.com/cloudfoundry/sshark/blob/master/registry.go