Skip to content

Commit

Permalink
refactor: switch to vtprotobuf, remove legacy dependencies
Browse files Browse the repository at this point in the history
 - switch to newer Golang protobuf package
 - remove gogo protobuf (deprecated)
 - use vtprotobuf (Vitess protobuf) instead of gogo
 - remove all prometheus_client references
 - remove Sirupsen references (namespace change)
 - fix recursive marshal in pquads

Signed-off-by: Christian Stewart <christian@paral.in>
  • Loading branch information
paralin committed Apr 29, 2023
1 parent 44c07ab commit 44db709
Show file tree
Hide file tree
Showing 51 changed files with 3,541 additions and 1,797 deletions.
103 changes: 103 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
PROTOWRAP=hack/bin/protowrap
PROTOC_GEN_GO=hack/bin/protoc-gen-go
PROTOC_GEN_VTPROTO=hack/bin/protoc-gen-go-vtproto
GOIMPORTS=hack/bin/goimports
GOLANGCI_LINT=hack/bin/golangci-lint
GO_MOD_OUTDATED=hack/bin/go-mod-outdated
GOLIST=go list -f "{{ .Dir }}" -m

export GO111MODULE=on
undefine GOARCH
undefine GOOS

all:

vendor:
go mod vendor

$(PROTOC_GEN_GO):
cd ./hack; \
go build -v \
-o ./bin/protoc-gen-go \
google.golang.org/protobuf/cmd/protoc-gen-go

$(PROTOC_GEN_VTPROTO):
cd ./hack; \
go build -v \
-o ./bin/protoc-gen-go-vtproto \
github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto

$(GOIMPORTS):
cd ./hack; \
go build -v \
-o ./bin/goimports \
golang.org/x/tools/cmd/goimports

$(PROTOWRAP):
cd ./hack; \
go build -v \
-o ./bin/protowrap \
github.com/aperturerobotics/goprotowrap/cmd/protowrap

$(GOLANGCI_LINT):
cd ./hack; \
go build -v \
-o ./bin/golangci-lint \
github.com/golangci/golangci-lint/cmd/golangci-lint

$(GO_MOD_OUTDATED):
cd ./hack; \
go build -v \
-o ./bin/go-mod-outdated \
github.com/psampaz/go-mod-outdated

.PHONY: gengo
gengo: $(GOIMPORTS) $(PROTOWRAP) $(PROTOC_GEN_GO) $(PROTOC_GEN_VTPROTO)
shopt -s globstar; \
set -eo pipefail; \
export PROJECT=$$(go list -m); \
export PATH=$$(pwd)/hack/bin:$${PATH}; \
mkdir -p $$(pwd)/vendor/$$(dirname $${PROJECT}); \
rm $$(pwd)/vendor/$${PROJECT} || true; \
ln -s $$(pwd) $$(pwd)/vendor/$${PROJECT} ; \
$(PROTOWRAP) \
-I $$(pwd)/vendor \
--go_out=$$(pwd)/vendor \
--go-vtproto_out=$$(pwd)/vendor \
--go-vtproto_opt=features=marshal+unmarshal+size+equal+clone \
--proto_path $$(pwd)/vendor \
--print_structure \
--only_specified_files \
$$(\
git \
ls-files "*.proto" |\
xargs printf -- \
"$$(pwd)/vendor/$${PROJECT}/%s "); \
rm $$(pwd)/vendor/$${PROJECT} || true
$(GOIMPORTS) -w ./

.PHONY: genproto
genproto: gengo

.PHONY: gen
gen: genproto

.PHONY: outdated
outdated: $(GO_MOD_OUTDATED)
go list -mod=mod -u -m -json all | $(GO_MOD_OUTDATED) -update -direct

.PHONY: list
list: $(GO_MOD_OUTDATED)
go list -mod=mod -u -m -json all | $(GO_MOD_OUTDATED)

.PHONY: lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run

.PHONY: fix
fix: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --fix

.PHONY: test
test:
go test -v ./...
1 change: 1 addition & 0 deletions appengine/appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build appengine || appenginevm
// +build appengine appenginevm

package main
Expand Down
1 change: 1 addition & 0 deletions appengine/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build appenginevm
// +build appenginevm

package main
Expand Down
10 changes: 1 addition & 9 deletions cmd/cayley/cayley.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !appengine
// +build !appengine

package main
Expand All @@ -26,7 +27,6 @@ import (
"strings"

"github.com/cayleygraph/cayley/cmd/cayley/command"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/cobra"
"github.com/spf13/viper"

Expand Down Expand Up @@ -89,13 +89,6 @@ var (
}
}()
}
if host, _ := cmd.Flags().GetString("metrics"); host != "" {
go func() {
if err := http.ListenAndServe(host, promhttp.Handler()); err != nil {
clog.Errorf("failed to run metrics handler: %v", err)
}
}()
}
return nil
},
}
Expand Down Expand Up @@ -160,7 +153,6 @@ func init() {
rootCmd.PersistentFlags().String("cpuprofile", "", "path to output cpu profile")

rootCmd.PersistentFlags().String("pprof", "", "host to serve pprof on (disabled by default)")
rootCmd.PersistentFlags().String("metrics", "", "host to serve metrics on (disabled by default)")

// bind flags to config variables
viper.BindPFlag(command.KeyBackend, rootCmd.PersistentFlags().Lookup("db"))
Expand Down
104 changes: 77 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,62 +1,112 @@
module github.com/cayleygraph/cayley

go 1.12
go 1.19

replace github.com/cayleygraph/quad => github.com/paralin/cayley-quad v1.2.5-0.20230429050549-1ed30505b980 // vtprotobuf

require (
github.com/badgerodon/peg v0.0.0-20130729175151-9e5f7f4d07ca
github.com/cayleygraph/quad v1.2.4
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc // indirect
github.com/coreos/bbolt v1.3.3 // indirect
github.com/cznic/mathutil v0.0.0-20170313102836-1447ad269d64
github.com/d4l3k/messagediff v1.2.1 // indirect
github.com/dennwc/graphql v0.0.0-20180603144102-12cfed44bc5d
github.com/dgraph-io/badger v1.5.5 // indirect
github.com/dlclark/regexp2 v1.1.4 // indirect
github.com/docker/docker v1.6.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dop251/goja v0.0.0-20190105122144-6d5bf35058fa
github.com/flimzy/diff v0.1.6 // indirect
github.com/fsouza/go-dockerclient v1.2.2
github.com/go-sourcemap/sourcemap v2.1.2+incompatible // indirect
github.com/go-sql-driver/mysql v1.4.1
github.com/gobuffalo/packr/v2 v2.7.1
github.com/gogo/protobuf v1.3.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/google/go-cmp v0.3.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect
github.com/golang/protobuf v1.5.2
github.com/hidal-go/hidalgo v0.0.0-20190814174001-42e03f3b5eaa
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect
github.com/jackc/pgx v3.3.0+incompatible
github.com/julienschmidt/httprouter v1.2.0
github.com/lib/pq v1.1.1
github.com/mattn/go-sqlite3 v1.10.0
github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/piprate/json-gold v0.5.0
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.4.0
github.com/stretchr/testify v1.8.2
github.com/syndtr/goleveldb v1.0.0
github.com/tylertreat/BoomFilters v0.0.0-20181028192813-611b3dbe80e8
golang.org/x/net v0.0.0-20190628185345-da137c7871d7
google.golang.org/appengine v1.6.1
)

require (
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9 // indirect
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Microsoft/go-winio v0.4.12 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/cenkalti/backoff v2.1.1+incompatible // indirect
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc // indirect
github.com/coreos/bbolt v1.3.3 // indirect
github.com/d4l3k/messagediff v1.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dennwc/base v1.0.0 // indirect
github.com/dgraph-io/badger v1.5.5 // indirect
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect
github.com/dlclark/regexp2 v1.1.4 // indirect
github.com/docker/docker v0.7.3-0.20180412203414-a422774e593b // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/flimzy/diff v0.1.6 // indirect
github.com/flimzy/kivik v1.8.1 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/go-kivik/couchdb v1.8.1 // indirect
github.com/go-kivik/kivik v1.8.1 // indirect
github.com/go-kivik/pouchdb v1.3.5 // indirect
github.com/go-sourcemap/sourcemap v2.1.2+incompatible // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gobuffalo/envy v1.7.1 // indirect
github.com/gobuffalo/logger v1.0.1 // indirect
github.com/gobuffalo/packd v0.3.0 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c // indirect
github.com/gopherjs/jsbuiltin v0.0.0-20180426082241-50091555e127 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e // indirect
github.com/mattn/go-sqlite3 v1.10.0
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v0.1.1 // indirect
github.com/opencontainers/selinux v1.0.0 // indirect
github.com/ory/dockertest v3.3.4+incompatible // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pelletier/go-toml v1.4.0 // indirect
github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/piprate/json-gold v0.3.0
github.com/prometheus/client_golang v0.9.3
github.com/pkg/errors v0.8.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
github.com/rogpeppe/go-internal v1.5.0 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 // indirect
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.4.0
github.com/stretchr/testify v1.4.0
github.com/syndtr/goleveldb v1.0.0
github.com/tylertreat/BoomFilters v0.0.0-20181028192813-611b3dbe80e8
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
github.com/xdg/stringprep v1.0.0 // indirect
go.etcd.io/bbolt v1.3.3 // indirect
go.mongodb.org/mongo-driver v1.0.4 // indirect
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc // indirect
golang.org/x/net v0.0.0-20190628185345-da137c7871d7
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20191009170203-06d7bd2c5f4f // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20191010075000-0337d82405ff // indirect
google.golang.org/appengine v1.6.1
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/olivere/elastic.v5 v5.0.81 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/Sirupsen/logrus => github.com/Sirupsen/logrus v1.0.1
Loading

0 comments on commit 44db709

Please sign in to comment.