- use more performant functions (mostly remove formatters were possible)
- move zap.Error() to the call site, rather than creating a new sugared logger with a key attached (not cheap)
- fix *w usages where the key was not provided.
The original handshake timeout is too short to dial connection
successfully under some situation. So the activator pod can not be
active. And the log message just say "Failed to send ping message to
ws://autoscaler.knative-serving.svc.cluster.local:8080", not easy to
figure out what's the problem underneeth.
The fix switch to websocket default dial, so the default handle shake
time is 45 seconds, and once dial error found, the error will be
reported as error.
* Clean up websocket code a bit.
1. %q are very annoying when actually trying to read logs and the address is obvious.
2. there's no reason to have external error (and we were swallowing the timeout error, should it happen)
* fixes
* Print target name when failed to ping
For example, when serving activator fails to ping autoscaler, it fails
with `Failed to send ping message` message. However, it does not print
target peer's name so it is difficult to debug.
This patch changes to print the target name.
* Print log without sprintf sugar
* Add ping message verification to the websocket connection.
* Recycle ticker.
* Add comment.
* Fix datarace by waiting for goroutines to finish on Shutdown.
* Cleanup websocket connection, actually test reconnects.
* Some more cleanup.
* Locally define connFactory to avoid races.
* Move locks around, harden test.
* Add logging.
* Drop redundant target.
* Move message encoding outside of the writerLock.
* Fix assignment nit.
* Remove named return value.
* Add close signal to long-running loops.
* Add todo for returning a messageType.
* Bump header to 2019.
* Add note on draining the messageChan.
* Drop target from signature.
* Drop target from test.
* Add a more speaking example to draining the messageChan.
* Fix typo.
* Relax read lock, improve test.
* Bump test coverage.
* Add double shutdown test.
* Remove code duplication in test.