Skip to content

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Yibo-Chen13
Copy link
Contributor

No description provided.

@Yibo-Chen13 Yibo-Chen13 linked an issue Dec 19, 2024 that may be closed by this pull request
@Yibo-Chen13 Yibo-Chen13 force-pushed the example/issue-48-update-streaming-query-examples branch 2 times, most recently from e053289 to ad56d24 Compare December 19, 2024 03:19
@Yibo-Chen13 Yibo-Chen13 force-pushed the example/issue-48-update-streaming-query-examples branch from ad56d24 to 73f4981 Compare December 19, 2024 03:20
}
defer rows.Close()
go func() {
time.Sleep(time.Duration(20) * time.Second)
Copy link
Collaborator

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

Copy link
Collaborator

@yuzifeng1984 yuzifeng1984 Jan 6, 2025

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() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I got below error in running the code. can you double check?

image

if err != nil {
log.Fatal(err)
}
for id := int64(0); id < int64(7); id++ {
Copy link
Collaborator

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.

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.

update examples for streaming query
2 participants