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

Allow builds without libdqlite #108

Merged
merged 1 commit into from
Jul 1, 2024
Merged
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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ go.vet:
$(DQLITE_BUILD_SCRIPTS_DIR)/static-go-vet.sh ./...

go.test:
go test -tags=libsqlite3 -v ./test
go test -v -p 1 ./...

go.test.dqlite:
$(DQLITE_BUILD_SCRIPTS_DIR)/static-go-test.sh -v ./test
$(DQLITE_BUILD_SCRIPTS_DIR)/static-go-test.sh -v ./...

go.bench:
go test -tags=libsqlite3 -v ./test -run "^$$" -bench "Benchmark" -benchmem
go test -tags=libsqlite3 -v ./... -run "^$$" -bench "Benchmark" -benchmem

go.bench.dqlite:
$(DQLITE_BUILD_SCRIPTS_DIR)/static-go-test.sh -v ./test -run "^$$" -bench "Benchmark" -benchmem
$(DQLITE_BUILD_SCRIPTS_DIR)/static-go-test.sh -v ./... -run "^$$" -bench "Benchmark" -benchmem

## Static Builds
static: bin/static/k8s-dqlite bin/static/dqlite
Expand Down
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,9 @@ func init() {
rootCmd.Flags().BoolVar(&rootCmdOpts.etcdMode, "etcd-mode", false, "Run in etcd mode")

rootCmd.AddCommand(dbctl.Command)

rootCmd.AddCommand(&cobra.Command{
Use: "version",
RunE: func(cmd *cobra.Command, args []string) error { return printVersions() },
})
}
22 changes: 6 additions & 16 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//go:build dqlite

package cmd

import (
"fmt"
"runtime"

"github.com/spf13/cobra"
)

/*
Expand Down Expand Up @@ -48,18 +48,8 @@ void print_dqlite_library_versions() {
*/
import "C"

var (
versionCmd = &cobra.Command{
Use: "version",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("go:", runtime.Version())
C.print_dqlite_library_versions()

return nil
},
}
)

func init() {
rootCmd.AddCommand(versionCmd)
func printVersions() error {
fmt.Println("go:", runtime.Version())
C.print_dqlite_library_versions()
return nil
}
9 changes: 9 additions & 0 deletions cmd/version_no_dqlite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !dqlite

package cmd

import "fmt"

func printVersions() error {
return fmt.Errorf("dqlite is not supported, compile with \"-tags dqlite\"")
}
2 changes: 2 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build dqlite

package server

import (
Expand Down
39 changes: 39 additions & 0 deletions pkg/server/server_no_dqlite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//go:build !dqlite

package server

import (
"context"
"errors"
"time"
)

var errNoDqlite = errors.New("dqlite is not supported, compile with \"-tags dqlite\"")
var closedCh = make(chan struct{})

func init() {
close(closedCh)
}

type Server struct{}

func (*Server) Start(ctx context.Context) error { return errNoDqlite }
func (*Server) MustStop() <-chan struct{} { return closedCh }
func (*Server) Shutdown(ctx context.Context) error { return errNoDqlite }

func New(
dir string,
listen string,
enableTLS bool,
diskMode bool,
clientSessionCacheSize uint,
minTLSVersion string,
watchAvailableStorageInterval time.Duration,
watchAvailableStorageMinBytes uint64,
lowAvailableStorageAction string,
admissionControlPolicy string,
admissionControlPolicyLimitMaxConcurrentTxn int64,
admissionControlOnlyWriteQueries bool,
) (*Server, error) {
return nil, errNoDqlite
}
Loading