Skip to content
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

feat: Add ping ability #97

Merged
merged 4 commits into from
Dec 16, 2023
Merged

Conversation

webstradev
Copy link
Contributor

@webstradev webstradev commented Dec 16, 2023

This PR adds a Ping and PingContext method to the Driver which satisfy the sql driver interface.

It uses a simple SELECT 1 to test the connection, which I believe is how most drivers implement a ping.

I have added a test to test the funcitonality and also included an example.

Closes #96

defer tx.Rollback()
defer func() {
err := tx.Rollback()
log.Fatal(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be:

if err != nil {
  log.Fatal(err)
}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah it should haha ill change that now

@haaawk
Copy link
Contributor

haaawk commented Dec 16, 2023

This adds the Ping only to websockets, no?
We have also HTTP transport that needs the support too.

@webstradev
Copy link
Contributor Author

This adds the Ping only to websockets, no? We have also HTTP transport that needs the support too.

Ah at first glance it didn't look like that had a diver but I guess it needs to be added to the hranaV2Conn
I'll amend that now

@webstradev
Copy link
Contributor Author

@haaawk Should be ready for re-review

@haaawk haaawk merged commit 8383a53 into tursodatabase:main Dec 16, 2023
4 checks passed
@webstradev webstradev deleted the add-ping-ability branch December 16, 2023 18:16
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.

bug: db.Ping is a no op
2 participants