Created
June 19, 2017 08:51
-
-
Save disq/e6903684629077bb80afe40c5bcfb14f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"database/sql" | |
"time" | |
_ "github.com/VoltDB/voltdb-client-go/voltdbclient" | |
) | |
func main() { | |
db, err := sql.Open("voltdb", "localhost:21212") // <-- insert hostname here | |
if err != nil { | |
panic(err) | |
} | |
db.SetConnMaxLifetime(1 * time.Second) // <-- This will leak connections every second or so, observe with "netstat -an|grep 21212" | |
fmt.Println("Starting query...") | |
for { | |
stmt, err := db.Prepare("SELECT CURRENT_TIMESTAMP() FROM SOME_TABLE_IN_VOLTDB LIMIT 1") // <-- insert table name here | |
if err != nil { | |
panic(err) | |
} | |
var dest string | |
err = stmt.QueryRow().Scan(&dest) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(dest) | |
time.Sleep(500 * time.Millisecond) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment