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

Add ReadLastEntryInfo to demo #352

Open
wants to merge 3 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions cmd/dqlite-demo/dqlite-demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"io"
"log"
"net"
"net/http"
Expand All @@ -14,6 +14,7 @@
"path/filepath"
"strings"

"github.com/canonical/go-dqlite/v3"
"github.com/canonical/go-dqlite/v3/app"
"github.com/canonical/go-dqlite/v3/client"
"github.com/pkg/errors"
Expand Down Expand Up @@ -65,7 +66,7 @@
if err != nil {
return err
}
data, err := ioutil.ReadFile(crt)
data, err := os.ReadFile(crt)

Check failure on line 69 in cmd/dqlite-demo/dqlite-demo.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-20.04)

undefined: os.ReadFile

Check failure on line 69 in cmd/dqlite-demo/dqlite-demo.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-22.04)

undefined: os.ReadFile

Check failure on line 69 in cmd/dqlite-demo/dqlite-demo.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-24.04)

undefined: os.ReadFile
if err != nil {
return err
}
Expand Down Expand Up @@ -104,7 +105,7 @@
err = row.Scan(&result)
case "PUT":
result = "done"
value, _ := ioutil.ReadAll(r.Body)
value, _ := io.ReadAll(r.Body)

Check failure on line 108 in cmd/dqlite-demo/dqlite-demo.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-20.04)

undefined: io.ReadAll

Check failure on line 108 in cmd/dqlite-demo/dqlite-demo.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-22.04)

undefined: io.ReadAll

Check failure on line 108 in cmd/dqlite-demo/dqlite-demo.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-24.04)

undefined: io.ReadAll
_, err = db.Exec(update, key, string(value[:]))
default:
err = fmt.Errorf("unsupported method")
Expand Down Expand Up @@ -138,6 +139,13 @@
app.Handover(context.Background())
app.Close()

lastEntry, err := dqlite.ReadLastEntryInfo(dir)
if err != nil {
return nil
}

fmt.Printf("dqlite-demo: last entry had term=%d index=%d", lastEntry.Term, lastEntry.Index)

return nil
},
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/dqlite/dqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"crypto/x509"
"fmt"
"io"
"io/ioutil"
"os"
"strings"
"time"
Expand Down Expand Up @@ -72,7 +71,7 @@
return err
}

data, err := ioutil.ReadFile(crt)
data, err := os.ReadFile(crt)

Check failure on line 74 in cmd/dqlite/dqlite.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-20.04)

undefined: os.ReadFile

Check failure on line 74 in cmd/dqlite/dqlite.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-22.04)

undefined: os.ReadFile

Check failure on line 74 in cmd/dqlite/dqlite.go

View workflow job for this annotation

GitHub Actions / build-and-test (1.13, ubuntu-24.04)

undefined: os.ReadFile
if err != nil {
return err
}
Expand Down
Loading