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

Update from github.com/golang/protobuf to google.golang.org/protobuf #382

Merged
merged 1 commit into from
Feb 28, 2023
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ docker_release:
output/pganalyze_collector/snapshot.pb.go: $(PROTOBUF_FILES)
ifdef PROTOC_VERSION
mkdir -p $(PWD)/bin
GOBIN=$(PWD)/bin go install github.com/golang/protobuf/protoc-gen-go
protoc --go_out=Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp:output/pganalyze_collector -I protobuf $(PROTOBUF_FILES)
GOBIN=$(PWD)/bin go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc --go_out=. --go_opt=module=github.com/pganalyze/collector -I protobuf $(PROTOBUF_FILES)
else
@echo '👷 Warning: protoc not found, skipping protocol buffer regeneration (to install protoc check Makefile instructions in install_protoc step)'
endif
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/go-ini/ini v1.62.0
github.com/go-ole/go-ole v0.0.0-20160708033836-be49f7c07711 // indirect
github.com/golang-jwt/jwt/v4 v4.1.0 // indirect
github.com/golang/protobuf v1.4.2
github.com/golang/protobuf v1.4.2 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/gorhill/cronexpr v0.0.0-20160318121724-f0984319b442
github.com/guregu/null v0.0.0-20160228005316-41961cea0328
Expand Down
13 changes: 6 additions & 7 deletions output/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"strings"
"time"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/pganalyze/collector/output/pganalyze_collector"
"github.com/pganalyze/collector/state"
"github.com/pganalyze/collector/util"
uuid "github.com/satori/go.uuid"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
)

func uploadAndSubmitCompactSnapshot(s pganalyze_collector.CompactSnapshot, grant state.Grant, server *state.Server, collectionOpts state.CollectionOpts, logger *util.Logger, collectedAt time.Time, quiet bool, kind string) error {
Expand All @@ -30,7 +30,7 @@ func uploadAndSubmitCompactSnapshot(s pganalyze_collector.CompactSnapshot, grant
s.SnapshotVersionMinor = 0
s.CollectorVersion = util.CollectorNameAndVersion
s.SnapshotUuid = snapshotUUID.String()
s.CollectedAt, _ = ptypes.TimestampProto(collectedAt)
s.CollectedAt = timestamppb.New(collectedAt)

data, err = proto.Marshal(&s)
if err != nil {
Expand Down Expand Up @@ -81,13 +81,12 @@ func debugCompactOutputAsJSON(logger *util.Logger, compressedData bytes.Buffer)
}

var out bytes.Buffer
var marshaler jsonpb.Marshaler
dataJSON, err := marshaler.MarshalToString(s)
dataJSON, err := protojson.Marshal(s)
if err != nil {
logger.PrintError("Failed to transform protocol buffers to JSON: %s", err)
return
}
json.Indent(&out, []byte(dataJSON), "", "\t")
json.Indent(&out, dataJSON, "", "\t")
logger.PrintInfo("Dry run - data that would have been sent will be output on stdout:\n")
fmt.Printf("%s\n", out.String())
}
Expand Down
13 changes: 6 additions & 7 deletions output/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"strings"
"time"

"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/pganalyze/collector/output/pganalyze_collector"
snapshot "github.com/pganalyze/collector/output/pganalyze_collector"
"github.com/pganalyze/collector/output/transform"
"github.com/pganalyze/collector/state"
"github.com/pganalyze/collector/util"
uuid "github.com/satori/go.uuid"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
)

func SendFull(server *state.Server, collectionOpts state.CollectionOpts, logger *util.Logger, newState state.PersistedState, diffState state.DiffState, transientState state.TransientState, collectedIntervalSecs uint32) error {
Expand All @@ -45,7 +45,7 @@ func submitFull(s snapshot.FullSnapshot, server *state.Server, collectionOpts st
s.SnapshotVersionMinor = 0
s.CollectorVersion = util.CollectorNameAndVersion
s.SnapshotUuid = snapshotUUID.String()
s.CollectedAt, _ = ptypes.TimestampProto(collectedAt)
s.CollectedAt = timestamppb.New(collectedAt)
s.CollectorLogSnapshotDisabled = server.CollectionStatus.LogSnapshotDisabled
s.CollectorLogSnapshotDisabledReason = server.CollectionStatus.LogSnapshotDisabledReason

Expand Down Expand Up @@ -98,13 +98,12 @@ func debugOutputAsJSON(logger *util.Logger, compressedData bytes.Buffer) {
}

var out bytes.Buffer
var marshaler jsonpb.Marshaler
dataJSON, err := marshaler.MarshalToString(s)
dataJSON, err := protojson.Marshal(s)
if err != nil {
logger.PrintError("Failed to transform protocol buffers to JSON: %s", err)
return
}
json.Indent(&out, []byte(dataJSON), "", "\t")
json.Indent(&out, dataJSON, "", "\t")
logger.PrintInfo("Dry run - data that would have been sent will be output on stdout:\n")
fmt.Printf("%s\n", out.String())
}
Expand Down
13 changes: 6 additions & 7 deletions output/pganalyze_collector/bloat_report.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions output/pganalyze_collector/buffercache_report.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading