Skip to content

Conversation

smacker
Copy link
Contributor

@smacker smacker commented Jan 10, 2019

Ref: #64

@carlosms
Copy link
Contributor

Is this something we should add to the go example analyzer?

@smacker
Copy link
Contributor Author

smacker commented Jan 10, 2019

Example analyzer doesn't keep an open connection to data server but opens a new one for each event.

README.md Outdated
@@ -38,6 +38,8 @@ When DataService is being dialed, you should:
- turn off [gRPC fail-fast](https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md) mode if your analyzer creates a connection to DataServer before it was actually started. This way the RPCs are queued until the chanel is ready:
- go: using `grpc.FailFast(false)`
([example](https://github.com/src-d/lookout-gometalint-analyzer/blob/7b4b37fb3109299516fbb43017934d131784f49f/cmd/gometalint-analyzer/main.go#L66)).
- golang: reset connection backoff to data server on event:
if you keep connection to data server open you need to reset backoff when analyzer receives new event. Use conn.[ResetConnectBackoff](https://godoc.org/google.golang.org/grpc#ClientConn.ResetConnectBackoff) method in your event handlers. It's needed to avoid broken connection after lookoutd redeployment. In case of a long restart of lookoutd grpc backoff timeout may increase big enough so analyzer wouldn't reconnect before it makes request to data server.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A suggestion, same text with "DataServer" for consistency with the rest of the doc and more verbosity to make the reason more clear.

Suggested change
if you keep connection to data server open you need to reset backoff when analyzer receives new event. Use conn.[ResetConnectBackoff](https://godoc.org/google.golang.org/grpc#ClientConn.ResetConnectBackoff) method in your event handlers. It's needed to avoid broken connection after lookoutd redeployment. In case of a long restart of lookoutd grpc backoff timeout may increase big enough so analyzer wouldn't reconnect before it makes request to data server.
golang: reset connection backoff to DataServer on event:
if you keep the connection to DataServer open you need to reset the backoff when your analyzer receives a new event. Use the [`conn.ResetConnectBackoff`](https://godoc.org/google.golang.org/grpc#ClientConn.ResetConnectBackoff) method in your event handlers. It's needed to avoid broken connections after a `lookoutd` redeployment. In case of a long restart of `lookoutd` gRPC server, the backoff timeout may increase so much that the analyzer will not be able to reconnect before it makes the new request to DataServer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Signed-off-by: Maxim Sukharev <max@smacker.ru>
Copy link
Contributor

@carlosms carlosms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Is there any other repo where we should apply this? The dummy analyzer, gometalinter, etc?

@smacker
Copy link
Contributor Author

smacker commented Jan 11, 2019

All of them use a new connection for each request as far as I remember. We don't have any "production-ready" go analyzer which would keep an open connection.

@smacker smacker merged commit ac2bb80 into src-d:master Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants