-
Notifications
You must be signed in to change notification settings - Fork 39
Separate DB worker from sync #932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
| recvChan := make(chan *message_api.SubscribeEnvelopesResponse) | ||
| errChan := make(chan error) | ||
| writeQueue := make(chan *envUtils.OriginatorEnvelope, 10) | ||
| errChan := make(chan error, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guarantees that the reader routine can exit if the main routine is doing something else. Otherwise the write to err might block forever.
Separate database worker from sync by extracting envelope storage logic from
|
| @@ -0,0 +1,247 @@ | |||
| package sync | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than the struct, all content is copied from the original place without changes.
fbac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Love the separation of concerns.
The DB goroutine lifecycle was tied to the lifecycle of the GRPC connection. There were no guarantees that the DB conn won't outlive the main routine when being rebuilt. This could lead to concurrent DB writing coroutines, out-of-order writes and other nastiness.