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

Added editions 2023 support with hybrid protobuf api #206

Merged
merged 11 commits into from
Feb 3, 2025
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dev: installgorums ordering/ordering.pb.go ordering/ordering_grpc.pb.go
@protoc -I=$(proto_path) \
--go_out=:. \
--gorums_out=dev=true:. \
--go_opt=default_api_level=API_HYBRID \
$(zorums_proto)

benchmark: installgorums $(benchmark_deps)
Expand All @@ -29,13 +30,17 @@ $(static_file): $(static_files)
@protoc-gen-gorums --bundle=$(static_file)

%.pb.go : %.proto
@protoc -I=$(proto_path) --go_out=paths=source_relative:. $^
@protoc -I=$(proto_path) \
--go_opt=default_api_level=API_HYBRID \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: looks like an extra tab character on this line.

--go_out=paths=source_relative:. $^

%_grpc.pb.go : %.proto
@protoc -I=$(proto_path) --go-grpc_out=paths=source_relative:. $^
@protoc -I=$(proto_path) \
--go-grpc_out=paths=source_relative:. $^

%_gorums.pb.go : %.proto
@protoc -I=$(proto_path) --gorums_out=paths=source_relative:. $^
@protoc -I=$(proto_path) \
--gorums_out=paths=source_relative:. $^

tools:
@go mod download
Expand Down
2 changes: 1 addition & 1 deletion async.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type asyncCallState struct {
// This function should only be used by generated code.
func (c RawConfiguration) AsyncCall(ctx context.Context, d QuorumCallData) *Async {
expectedReplies := len(c)
md := &ordering.Metadata{MessageID: c.getMsgID(), Method: d.Method}
md := ordering.Metadata_builder{MessageID: c.getMsgID(), Method: d.Method}.Build()
replyChan := make(chan response, expectedReplies)

for _, n := range c {
Expand Down
22 changes: 11 additions & 11 deletions benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type (
func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
msg := &Echo{Payload: make([]byte, opts.Payload)}
msg := Echo_builder{Payload: make([]byte, opts.Payload)}.Build()
s := &Stats{}
var g errgroup.Group

Expand Down Expand Up @@ -97,7 +97,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error)
if err != nil {
return nil, err
}
result.ServerStats = memStats.MemoryStats
result.SetServerStats(memStats.GetMemoryStats())
}

return result, nil
Expand All @@ -106,7 +106,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error)
func runAsyncQCBenchmark(opts Options, cfg *Configuration, f asyncQCFunc) (*Result, error) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
msg := &Echo{Payload: make([]byte, opts.Payload)}
msg := Echo_builder{Payload: make([]byte, opts.Payload)}.Build()
s := &Stats{}
var g errgroup.Group

Expand Down Expand Up @@ -181,7 +181,7 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, f asyncQCFunc) (*Resu
if err != nil {
return nil, err
}
result.ServerStats = memStats.MemoryStats
result.SetServerStats(memStats.GetMemoryStats())
}

return result, nil
Expand All @@ -197,7 +197,7 @@ func runServerBenchmark(opts Options, cfg *Configuration, f serverFunc) (*Result

benchmarkFunc := func(stopTime time.Time) {
for !time.Now().After(stopTime) {
msg := &TimedMsg{SendTime: time.Now().UnixNano(), Payload: payload}
msg := TimedMsg_builder{SendTime: time.Now().UnixNano(), Payload: payload}.Build()
f(ctx, msg)
}
}
Expand Down Expand Up @@ -232,11 +232,11 @@ func runServerBenchmark(opts Options, cfg *Configuration, f serverFunc) (*Result
return nil, err
}

clientAllocs := (end.Mallocs - start.Mallocs) / resp.TotalOps
clientMem := (end.TotalAlloc - start.TotalAlloc) / resp.TotalOps
clientAllocs := (end.Mallocs - start.Mallocs) / resp.GetTotalOps()
clientMem := (end.TotalAlloc - start.TotalAlloc) / resp.GetTotalOps()

resp.AllocsPerOp = clientAllocs
resp.MemPerOp = clientMem
resp.SetAllocsPerOp(clientAllocs)
resp.SetMemPerOp(clientMem)
return resp, nil
}

Expand Down Expand Up @@ -279,9 +279,9 @@ func RunBenchmarks(benchRegex *regexp.Regexp, options Options, cfg *Configuratio
if err != nil {
return nil, err
}
result.Name = b.Name
result.SetName(b.Name)
i := sort.Search(len(results), func(i int) bool {
return results[i].Name >= result.Name
return results[i].GetName() >= result.GetName()
})
results = append(results, nil)
copy(results[i+1:], results[i:])
Expand Down
Loading