-
Notifications
You must be signed in to change notification settings - Fork 4
update streaming-query example #75
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
base: develop
Are you sure you want to change the base?
update streaming-query example #75
Conversation
e053289
to
ad56d24
Compare
ad56d24
to
73f4981
Compare
} | ||
defer rows.Close() | ||
go func() { | ||
time.Sleep(time.Duration(20) * time.Second) |
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.
we can capture signal to graceful shutdown program instead of running for 20 seconds.
please refer documents such as
https://emretanriverdi.medium.com/graceful-shutdown-in-go-c106fe1a99d9
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.
I would start reader and writers as go routines. The main thread will wait and cancel them via context once received signal.
https://gobyexample.com/timeouts
https://gobyexample.com/waitgroups
https://gobyexample.com/signals
} | ||
} | ||
|
||
func main() { |
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.
if err != nil { | ||
log.Fatal(err) | ||
} | ||
for id := int64(0); id < int64(7); id++ { |
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.
let's make 7 a const variable such as NumOfWriters to make code more clear.
No description provided.