From 2125a3c7d5ec2a359c1356b60178f924ead4048b Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sun, 6 Apr 2025 14:16:27 +0200 Subject: [PATCH 01/27] quorum call iterator --- errors.go | 19 ++----------------- quorumcall.go | 38 ++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/errors.go b/errors.go index 2ac77f9b4..0f9e7e452 100644 --- a/errors.go +++ b/errors.go @@ -3,7 +3,6 @@ package gorums import ( "errors" "fmt" - "strings" ) // Incomplete is the error returned by a quorum call when the call cannot completed @@ -12,9 +11,7 @@ var Incomplete = errors.New("incomplete call") // QuorumCallError reports on a failed quorum call. type QuorumCallError struct { - cause error - errors []nodeError - replies int + cause error } // Is reports whether the target error is the same as the cause of the QuorumCallError. @@ -26,19 +23,7 @@ func (e QuorumCallError) Is(target error) bool { } func (e QuorumCallError) Error() string { - s := fmt.Sprintf("quorum call error: %s (errors: %d, replies: %d)", e.cause, len(e.errors), e.replies) - var b strings.Builder - b.WriteString(s) - if len(e.errors) == 0 { - return b.String() - } - b.WriteString("\nnode errors:\n") - for _, err := range e.errors { - b.WriteByte('\t') - b.WriteString(err.Error()) - b.WriteByte('\n') - } - return b.String() + return fmt.Sprintf("quorum call error: %s", e.cause) } // nodeError reports on a failed RPC call. diff --git a/quorumcall.go b/quorumcall.go index 40d6c7be8..476b853ce 100644 --- a/quorumcall.go +++ b/quorumcall.go @@ -2,6 +2,7 @@ package gorums import ( "context" + "iter" "github.com/relab/gorums/ordering" "google.golang.org/protobuf/reflect/protoreflect" @@ -22,7 +23,7 @@ type QuorumCallData struct { // QuorumCall performs a quorum call on the configuration. // // This method should be used by generated code only. -func (c RawConfiguration) QuorumCall(ctx context.Context, d QuorumCallData) (resp protoreflect.ProtoMessage, err error) { +func (c RawConfiguration) QuorumCall(ctx context.Context, d QuorumCallData) iter.Seq2[protoreflect.ProtoMessage, error] { expectedReplies := len(c) md := ordering.Metadata_builder{MessageID: c.getMsgID(), Method: d.Method}.Build() @@ -39,28 +40,25 @@ func (c RawConfiguration) QuorumCall(ctx context.Context, d QuorumCallData) (res n.channel.enqueue(request{ctx: ctx, msg: &Message{Metadata: md, Message: msg}}, replyChan, false) } - var ( - errs []nodeError - quorum bool - replies = make(map[uint32]protoreflect.ProtoMessage) - ) + replies := int(0) - for { - select { - case r := <-replyChan: - if r.err != nil { - errs = append(errs, nodeError{nodeID: r.nid, cause: r.err}) - break + return func(yield func(K protoreflect.ProtoMessage, V error) bool) { + for { + select { + case r := <-replyChan: + replies++ + if !yield(r.msg, r.err) { + return + } + case <-ctx.Done(): + yield(nil, QuorumCallError{cause: ctx.Err()}) + return } - replies[r.nid] = r.msg - if resp, quorum = d.QuorumFunction(d.Message, replies); quorum { - return resp, nil + if replies >= expectedReplies { + yield(nil, QuorumCallError{cause: Incomplete}) + return } - case <-ctx.Done(): - return resp, QuorumCallError{cause: ctx.Err(), errors: errs, replies: len(replies)} - } - if len(errs)+len(replies) == expectedReplies { - return resp, QuorumCallError{cause: Incomplete, errors: errs, replies: len(replies)} } } + } From a5644aeabe093772b335f1ae520d9f8a7479703f Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sun, 6 Apr 2025 18:52:19 +0200 Subject: [PATCH 02/27] added iteratord to protoc-gen-gorums --- async.go | 4 +- benchmark/benchmark.pb.go | 2 +- benchmark/benchmark_gorums.pb.go | 111 ++++-------------- cmd/protoc-gen-gorums/dev/zorums.pb.go | 2 +- .../dev/zorums_async_gorums.pb.go | 4 +- .../dev/zorums_client_gorums.pb.go | 17 +-- .../dev/zorums_correctable_gorums.pb.go | 4 +- .../dev/zorums_multicast_gorums.pb.go | 4 +- .../dev/zorums_qspec_gorums.pb.go | 4 +- .../dev/zorums_quorumcall_gorums.pb.go | 95 +++------------ .../dev/zorums_rpc_gorums.pb.go | 4 +- .../dev/zorums_server_gorums.pb.go | 4 +- .../dev/zorums_types_gorums.pb.go | 4 +- .../dev/zorums_unicast_gorums.pb.go | 4 +- .../gengorums/gorums_func_map.go | 1 + .../gengorums/template_client.go | 3 +- .../gengorums/template_quorumcall.go | 21 ++-- correctable.go | 4 +- gorums.pb.go | 2 +- internal/correctable/opts.pb.go | 2 +- ordering/ordering.pb.go | 2 +- ordering/ordering_grpc.pb.go | 2 +- quorumcall.go | 12 +- 23 files changed, 90 insertions(+), 222 deletions(-) diff --git a/async.go b/async.go index c8782c680..762daf42e 100644 --- a/async.go +++ b/async.go @@ -96,11 +96,11 @@ func (c RawConfiguration) handleAsyncCall(ctx context.Context, fut *Async, state return } case <-ctx.Done(): - fut.reply, fut.err = resp, QuorumCallError{cause: ctx.Err(), errors: errs, replies: len(replies)} + fut.reply, fut.err = resp, QuorumCallError{cause: ctx.Err()} return } if len(errs)+len(replies) == state.expectedReplies { - fut.reply, fut.err = resp, QuorumCallError{cause: Incomplete, errors: errs, replies: len(replies)} + fut.reply, fut.err = resp, QuorumCallError{cause: Incomplete} return } } diff --git a/benchmark/benchmark.pb.go b/benchmark/benchmark.pb.go index 1382847ed..59ca644a1 100644 --- a/benchmark/benchmark.pb.go +++ b/benchmark/benchmark.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v5.29.2 // source: benchmark/benchmark.proto package benchmark diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 1496d6d63..06719ad95 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+903a0213 -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: benchmark/benchmark.proto package benchmark @@ -13,6 +13,7 @@ import ( encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" emptypb "google.golang.org/protobuf/types/known/emptypb" + iter "iter" ) const ( @@ -38,7 +39,7 @@ type Configuration struct { // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test interface{} = struct{}{} + var test any = struct{}{} if _, empty := test.(QuorumSpec); !empty && qspec == nil { return nil, fmt.Errorf("config: missing required QuorumSpec") } @@ -121,7 +122,7 @@ func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuratio } } // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test interface{} = struct{}{} + var test any = struct{}{} if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { return nil, fmt.Errorf("config: missing required QuorumSpec") } @@ -172,13 +173,13 @@ func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) *AsyncEch // BenchmarkClient is the client interface for the Benchmark service. type BenchmarkClient interface { - StartServerBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error) - StopServerBenchmark(ctx context.Context, in *StopRequest) (resp *Result, err error) - StartBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error) - StopBenchmark(ctx context.Context, in *StopRequest) (resp *MemoryStatList, err error) - QuorumCall(ctx context.Context, in *Echo) (resp *Echo, err error) + StartServerBenchmark(ctx context.Context, in *StartRequest) iter.Seq2[*StartResponse, error] + StopServerBenchmark(ctx context.Context, in *StopRequest) iter.Seq2[*Result, error] + StartBenchmark(ctx context.Context, in *StartRequest) iter.Seq2[*StartResponse, error] + StopBenchmark(ctx context.Context, in *StopRequest) iter.Seq2[*MemoryStatList, error] + QuorumCall(ctx context.Context, in *Echo) iter.Seq2[*Echo, error] AsyncQuorumCall(ctx context.Context, in *Echo) *AsyncEcho - SlowServer(ctx context.Context, in *Echo) (resp *Echo, err error) + SlowServer(ctx context.Context, in *Echo) iter.Seq2[*Echo, error] Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption) } @@ -255,133 +256,67 @@ type QuorumSpec interface { // StartServerBenchmark is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. -func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error) { +func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartRequest) iter.Seq2[*StartResponse, error] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StartServerBenchmark", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*StartResponse, len(replies)) - for k, v := range replies { - r[k] = v.(*StartResponse) - } - return c.qspec.StartServerBenchmarkQF(req.(*StartRequest), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*StartResponse), err + return gorums.QuorumCall[*StartResponse](ctx, c.RawConfiguration, cd) } // StopServerBenchmark is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. -func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest) (resp *Result, err error) { +func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest) iter.Seq2[*Result, error] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StopServerBenchmark", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Result, len(replies)) - for k, v := range replies { - r[k] = v.(*Result) - } - return c.qspec.StopServerBenchmarkQF(req.(*StopRequest), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Result), err + return gorums.QuorumCall[*Result](ctx, c.RawConfiguration, cd) } // StartBenchmark is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. -func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error) { +func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) iter.Seq2[*StartResponse, error] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StartBenchmark", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*StartResponse, len(replies)) - for k, v := range replies { - r[k] = v.(*StartResponse) - } - return c.qspec.StartBenchmarkQF(req.(*StartRequest), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*StartResponse), err + return gorums.QuorumCall[*StartResponse](ctx, c.RawConfiguration, cd) } // StopBenchmark is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. -func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) (resp *MemoryStatList, err error) { +func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) iter.Seq2[*MemoryStatList, error] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StopBenchmark", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*MemoryStat, len(replies)) - for k, v := range replies { - r[k] = v.(*MemoryStat) - } - return c.qspec.StopBenchmarkQF(req.(*StopRequest), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*MemoryStatList), err + return gorums.QuorumCall[*MemoryStatList](ctx, c.RawConfiguration, cd) } // benchmarks -func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) (resp *Echo, err error) { +func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) iter.Seq2[*Echo, error] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.QuorumCall", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Echo, len(replies)) - for k, v := range replies { - r[k] = v.(*Echo) - } - return c.qspec.QuorumCallQF(req.(*Echo), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Echo), err + return gorums.QuorumCall[*Echo](ctx, c.RawConfiguration, cd) } // SlowServer is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. -func (c *Configuration) SlowServer(ctx context.Context, in *Echo) (resp *Echo, err error) { +func (c *Configuration) SlowServer(ctx context.Context, in *Echo) iter.Seq2[*Echo, error] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.SlowServer", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Echo, len(replies)) - for k, v := range replies { - r[k] = v.(*Echo) - } - return c.qspec.SlowServerQF(req.(*Echo), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Echo), err + return gorums.QuorumCall[*Echo](ctx, c.RawConfiguration, cd) } // Benchmark is the server-side API for the Benchmark Service diff --git a/cmd/protoc-gen-gorums/dev/zorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums.pb.go index 8c1f169c0..3a206f53d 100644 --- a/cmd/protoc-gen-gorums/dev/zorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go index 9d8227f9e..9d3b267d1 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index 324e19940..9bfb61546 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev @@ -10,6 +10,7 @@ import ( context "context" gorums "github.com/relab/gorums" emptypb "google.golang.org/protobuf/types/known/emptypb" + iter "iter" ) const ( @@ -21,12 +22,12 @@ const ( // ZorumsServiceClient is the client interface for the ZorumsService service. type ZorumsServiceClient interface { - QuorumCall(ctx context.Context, in *Request) (resp *Response, err error) - QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) (resp *Response, err error) - QuorumCallCustomReturnType(ctx context.Context, in *Request) (resp *MyResponse, err error) - QuorumCallCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) (resp *MyResponse, err error) - QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) (resp *Response, err error) - QuorumCallEmpty2(ctx context.Context, in *Request) (resp *emptypb.Empty, err error) + QuorumCall(ctx context.Context, in *Request) iter.Seq2[*Response, error] + QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) iter.Seq2[*Response, error] + QuorumCallCustomReturnType(ctx context.Context, in *Request) iter.Seq2[*MyResponse, error] + QuorumCallCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) iter.Seq2[*MyResponse, error] + QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) iter.Seq2[*Response, error] + QuorumCallEmpty2(ctx context.Context, in *Request) iter.Seq2[*emptypb.Empty, error] Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) MulticastPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) Multicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) diff --git a/cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go index 5599dad2a..4be8d5b57 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index 21c807df1..b5c5ba474 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go index 871cca0ca..6d028d34a 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index e37d8886a..c6e7f7fe5 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev @@ -11,6 +11,7 @@ import ( gorums "github.com/relab/gorums" protoreflect "google.golang.org/protobuf/reflect/protoreflect" emptypb "google.golang.org/protobuf/types/known/emptypb" + iter "iter" ) const ( @@ -21,133 +22,67 @@ const ( ) // QuorumCall plain. -func (c *Configuration) QuorumCall(ctx context.Context, in *Request) (resp *Response, err error) { +func (c *Configuration) QuorumCall(ctx context.Context, in *Request) iter.Seq2[*Response, error] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCall", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallQF(req.(*Request), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Response), err + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // QuorumCall with per_node_arg option. -func (c *Configuration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) (resp *Response, err error) { +func (c *Configuration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) iter.Seq2[*Response, error] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallPerNodeArg", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallPerNodeArgQF(req.(*Request), r) - } cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { return f(req.(*Request), nid) } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Response), err + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // QuorumCall with custom_return_type option. -func (c *Configuration) QuorumCallCustomReturnType(ctx context.Context, in *Request) (resp *MyResponse, err error) { +func (c *Configuration) QuorumCallCustomReturnType(ctx context.Context, in *Request) iter.Seq2[*MyResponse, error] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallCustomReturnType", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallCustomReturnTypeQF(req.(*Request), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*MyResponse), err + return gorums.QuorumCall[*MyResponse](ctx, c.RawConfiguration, cd) } // QuorumCallCombo with all supported options. -func (c *Configuration) QuorumCallCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) (resp *MyResponse, err error) { +func (c *Configuration) QuorumCallCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) iter.Seq2[*MyResponse, error] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallCombo", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallComboQF(req.(*Request), r) - } cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { return f(req.(*Request), nid) } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*MyResponse), err + return gorums.QuorumCall[*MyResponse](ctx, c.RawConfiguration, cd) } // QuorumCallEmpty for testing imported message type. -func (c *Configuration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) (resp *Response, err error) { +func (c *Configuration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) iter.Seq2[*Response, error] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallEmpty", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallEmptyQF(req.(*emptypb.Empty), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Response), err + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // QuorumCallEmpty2 for testing imported message type. -func (c *Configuration) QuorumCallEmpty2(ctx context.Context, in *Request) (resp *emptypb.Empty, err error) { +func (c *Configuration) QuorumCallEmpty2(ctx context.Context, in *Request) iter.Seq2[*emptypb.Empty, error] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallEmpty2", } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*emptypb.Empty, len(replies)) - for k, v := range replies { - r[k] = v.(*emptypb.Empty) - } - return c.qspec.QuorumCallEmpty2QF(req.(*Request), r) - } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*emptypb.Empty), err + return gorums.QuorumCall[*emptypb.Empty](ctx, c.RawConfiguration, cd) } diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index 6986453d9..f077df916 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index c91e648e0..e37076a6b 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go index 049bbb6c5..1ee4d28d8 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index 8a4be534b..25f93e195 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d62f9a0e -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 +// protoc v5.29.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go index 15dc11a9a..e30141241 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go @@ -22,6 +22,7 @@ var importMap = map[string]protogen.GoImportPath{ "math": protogen.GoImportPath("math"), "rand": protogen.GoImportPath("math/rand"), "sync": protogen.GoImportPath("sync"), + "iter": protogen.GoImportPath("iter"), "atomic": protogen.GoImportPath("sync/atomic"), "context": protogen.GoImportPath("context"), "trace": protogen.GoImportPath("golang.org/x/net/trace"), diff --git a/cmd/protoc-gen-gorums/gengorums/template_client.go b/cmd/protoc-gen-gorums/gengorums/template_client.go index db1e65829..ee0c0dc7c 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_client.go +++ b/cmd/protoc-gen-gorums/gengorums/template_client.go @@ -9,6 +9,7 @@ var clientVariables = ` {{$context := use "context.Context" .GenFile}} {{$_ := use "gorums.EnforceVersion" .GenFile}} {{$callOpt := use "gorums.CallOption" .GenFile}} +{{$iterator := use "iter.Seq2" .GenFile}} ` var clientConfigurationInterface = ` @@ -27,7 +28,7 @@ var clientConfigurationInterface = ` {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) *{{$customOut}} {{- else}} {{- $customOut := customOut $genFile .}} - {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) (resp *{{$customOut}}, err error) + {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) {{$iterator}}[*{{$customOut}}, error] {{- end}} {{- end}} } diff --git a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go index 7fd408580..7e08a4806 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go +++ b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go @@ -12,6 +12,11 @@ var commonVariables = ` {{$unexportOutput := unexport .Method.Output.GoIdent.GoName}} ` +// Common variables used in several template functions. +var quorumCallVariables = ` +{{$iterator := use "iter.Seq2" .GenFile}} +` + var quorumCallComment = ` {{$comments := .Method.Comments.Leading}} {{if ne $comments ""}} @@ -33,7 +38,7 @@ var quorumCallComment = ` var quorumCallSignature = `func (c *Configuration) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}})` + - `(resp *{{$customOut}}, err error) { + `{{$iterator}}[*{{$customOut}}, error] { ` var qcVar = ` @@ -48,28 +53,18 @@ var quorumCallBody = ` cd := {{$callData}}{ Message: in, Method: "{{$fullName}}", } - cd.QuorumFunction = func(req {{$protoMessage}}, replies map[uint32]{{$protoMessage}}) ({{$protoMessage}}, bool) { - r := make(map[uint32]*{{$out}}, len(replies)) - for k, v := range replies { - r[k] = v.(*{{$out}}) - } - return c.qspec.{{$method}}QF(req.(*{{$in}}), r) - } {{- if hasPerNodeArg .Method}} cd.PerNodeArgFn = func(req {{$protoMessage}}, nid uint32) {{$protoMessage}} { return f(req.(*{{$in}}), nid) } {{- end}} - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*{{$customOut}}), err + return gorums.QuorumCall[*{{$customOut}}](ctx, c.RawConfiguration, cd) } ` var quorumCall = commonVariables + + quorumCallVariables + qcVar + quorumCallComment + quorumCallSignature + diff --git a/correctable.go b/correctable.go index f5c95b1cb..5e98cc25a 100644 --- a/correctable.go +++ b/correctable.go @@ -164,12 +164,12 @@ func (c RawConfiguration) handleCorrectableCall(ctx context.Context, corr *Corre } } case <-ctx.Done(): - corr.set(resp, clevel, QuorumCallError{cause: ctx.Err(), errors: errs, replies: len(replies)}, true) + corr.set(resp, clevel, QuorumCallError{cause: ctx.Err()}, true) return } if (state.data.ServerStream && len(errs) == state.expectedReplies) || (!state.data.ServerStream && len(errs)+len(replies) == state.expectedReplies) { - corr.set(resp, clevel, QuorumCallError{cause: Incomplete, errors: errs, replies: len(replies)}, true) + corr.set(resp, clevel, QuorumCallError{cause: Incomplete}, true) return } } diff --git a/gorums.pb.go b/gorums.pb.go index b8514d1ac..ca92169b4 100644 --- a/gorums.pb.go +++ b/gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v5.29.2 // source: gorums.proto package gorums diff --git a/internal/correctable/opts.pb.go b/internal/correctable/opts.pb.go index 135182538..a68225dc0 100644 --- a/internal/correctable/opts.pb.go +++ b/internal/correctable/opts.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v5.29.2 // source: internal/correctable/opts.proto package correctable diff --git a/ordering/ordering.pb.go b/ordering/ordering.pb.go index ec74f30e6..a9323e7ec 100644 --- a/ordering/ordering.pb.go +++ b/ordering/ordering.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v5.29.2 // source: ordering/ordering.proto package ordering diff --git a/ordering/ordering_grpc.pb.go b/ordering/ordering_grpc.pb.go index 44271a0ae..385adba95 100644 --- a/ordering/ordering_grpc.pb.go +++ b/ordering/ordering_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.29.3 +// - protoc v5.29.2 // source: ordering/ordering.proto package ordering diff --git a/quorumcall.go b/quorumcall.go index 9bef86548..cb2eefe72 100644 --- a/quorumcall.go +++ b/quorumcall.go @@ -23,7 +23,7 @@ type QuorumCallData struct { // QuorumCall performs a quorum call on the configuration. // // This method should be used by generated code only. -func (c RawConfiguration) QuorumCall(ctx context.Context, d QuorumCallData) iter.Seq2[protoreflect.ProtoMessage, error] { +func QuorumCall[responseType protoreflect.ProtoMessage](ctx context.Context, c RawConfiguration, d QuorumCallData) iter.Seq2[responseType, error] { expectedReplies := len(c) md := ordering.NewGorumsMetadata(ctx, c.getMsgID(), d.Method) @@ -41,24 +41,24 @@ func (c RawConfiguration) QuorumCall(ctx context.Context, d QuorumCallData) iter } replies := int(0) + var noResponse responseType - return func(yield func(K protoreflect.ProtoMessage, V error) bool) { + return func(yield func(K responseType, V error) bool) { for { select { case r := <-replyChan: replies++ - if !yield(r.msg, r.err) { + if !yield(r.msg.(responseType), r.err) { return } case <-ctx.Done(): - yield(nil, QuorumCallError{cause: ctx.Err()}) + yield(noResponse, QuorumCallError{cause: ctx.Err()}) return } if replies >= expectedReplies { - yield(nil, QuorumCallError{cause: Incomplete}) + yield(noResponse, QuorumCallError{cause: Incomplete}) return } } } - } From 71bed4a800913aa79e1d100d098ba512a7570529 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Wed, 16 Apr 2025 18:16:53 +0200 Subject: [PATCH 03/27] fix tests and examples --- async.go | 92 ++---- benchmark/benchmark.go | 49 ++-- benchmark/benchmark.pb.go | 12 +- benchmark/benchmark.proto | 4 +- benchmark/benchmark_gorums.pb.go | 220 +++++---------- benchmark/qspec.go | 152 +++++++++- channel.go | 6 +- cmd/benchmark/main.go | 8 +- cmd/protoc-gen-gorums/dev/config.go | 11 +- cmd/protoc-gen-gorums/dev/mgr.go | 29 +- cmd/protoc-gen-gorums/dev/zorums.pb.go | 139 +++------ cmd/protoc-gen-gorums/dev/zorums.proto | 146 ++-------- .../dev/zorums_async_gorums.pb.go | 154 ---------- .../dev/zorums_client_gorums.pb.go | 45 ++- .../dev/zorums_correctable_gorums.pb.go | 263 ------------------ .../dev/zorums_multicast_gorums.pb.go | 8 +- .../dev/zorums_qspec_gorums.pb.go | 199 ------------- .../dev/zorums_quorumcall_gorums.pb.go | 83 ++++-- .../dev/zorums_rpc_gorums.pb.go | 4 +- .../dev/zorums_server_gorums.pb.go | 199 +++---------- .../dev/zorums_types_gorums.pb.go | 157 +---------- .../dev/zorums_unicast_gorums.pb.go | 8 +- cmd/protoc-gen-gorums/gengorums/gorums.go | 59 +--- .../gengorums/gorums_func_map.go | 100 ++----- .../gengorums/template_async.go | 59 ---- .../gengorums/template_client.go | 13 +- .../gengorums/template_correctable.go | 68 ----- .../gengorums/template_datatypes.go | 56 +--- .../gengorums/template_multicast.go | 2 +- .../gengorums/template_qspec.go | 59 ---- .../gengorums/template_quorumcall.go | 13 +- .../gengorums/template_rpc.go | 6 +- .../gengorums/template_server.go | 38 +-- .../gengorums/template_static.go | 40 +-- correctable.go | 124 ++------- encoding.go | 6 +- examples/storage/client.go | 26 +- examples/storage/proto/storage.pb.go | 2 +- examples/storage/proto/storage_gorums.pb.go | 108 ++----- examples/storage/repl.go | 58 +++- gorums.pb.go | 54 +--- gorums.proto | 13 +- internal/correctable/opts.pb.go | 2 +- .../testprotos/calltypes/async/async.proto | 24 -- .../testprotos/calltypes/zorums/zorums.proto | 146 ++-------- iterator.go | 79 ++++++ ordering/ordering.pb.go | 2 +- ordering/ordering_grpc.pb.go | 2 +- quorumcall.go | 42 ++- rpc.go | 6 +- server.go | 4 +- tests/Makefile | 13 +- tests/config/config.pb.go | 91 +++--- tests/config/config_gorums.pb.go | 78 +----- tests/config/config_test.go | 62 ++--- tests/correctable/correctable.pb.go | 67 +++-- tests/correctable/correctable.proto | 4 +- tests/correctable/correctable_gorums.pb.go | 141 ++-------- tests/correctable/correctable_test.go | 66 ++--- tests/dummy/dummy.pb.go | 30 +- tests/dummy/dummy_gorums.pb.go | 46 +-- tests/metadata/metadata.pb.go | 77 ++--- tests/metadata/metadata_gorums.pb.go | 44 +-- tests/metadata/metadata_test.go | 4 +- tests/oneway/oneway.pb.go | 63 +++-- tests/oneway/oneway_gorums.pb.go | 52 +--- tests/oneway/oneway_test.go | 32 +-- tests/ordering/order.pb.go | 87 +++--- tests/ordering/order.proto | 1 - tests/ordering/order_gorums.pb.go | 133 ++------- tests/ordering/order_test.go | 87 +++--- tests/qf/qf.pb.go | 81 +++--- tests/qf/qf_gorums.pb.go | 110 ++------ tests/qf/qf_test.go | 63 ++++- tests/tls/tls.pb.go | 59 ++-- tests/tls/tls_gorums.pb.go | 46 +-- tests/tls/tls_test.go | 4 +- tests/unresponsive/unresponsive.pb.go | 30 +- tests/unresponsive/unresponsive_gorums.pb.go | 46 +-- 79 files changed, 1433 insertions(+), 3383 deletions(-) delete mode 100644 cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go delete mode 100644 cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go delete mode 100644 cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go delete mode 100644 cmd/protoc-gen-gorums/gengorums/template_async.go delete mode 100644 cmd/protoc-gen-gorums/gengorums/template_correctable.go delete mode 100644 cmd/protoc-gen-gorums/gengorums/template_qspec.go delete mode 100644 internal/testprotos/calltypes/async/async.proto create mode 100644 iterator.go diff --git a/async.go b/async.go index 762daf42e..efe8d2a07 100644 --- a/async.go +++ b/async.go @@ -1,31 +1,26 @@ package gorums -import ( - "context" - - "github.com/relab/gorums/ordering" - "google.golang.org/protobuf/reflect/protoreflect" -) +import "google.golang.org/protobuf/proto" // Async encapsulates the state of an asynchronous quorum call, // and has methods for checking the status of the call or waiting for it to complete. // // This struct should only be used by generated code. -type Async struct { - reply protoreflect.ProtoMessage +type Async[resultType any] struct { + reply resultType err error c chan struct{} } // Get returns the reply and any error associated with the called method. // The method blocks until a reply or error is available. -func (f *Async) Get() (protoreflect.ProtoMessage, error) { +func (f *Async[resultType]) Get() (resultType, error) { <-f.c return f.reply, f.err } // Done reports if a reply and/or error is available for the called method. -func (f *Async) Done() bool { +func (f *Async[resultType]) Done() bool { select { case <-f.c: return true @@ -34,74 +29,19 @@ func (f *Async) Done() bool { } } -type asyncCallState struct { - md *ordering.Metadata - data QuorumCallData - replyChan <-chan response - expectedReplies int -} - -// AsyncCall starts an asynchronous quorum call, returning an Async object that can be used to retrieve the results. -// -// This function should only be used by generated code. -func (c RawConfiguration) AsyncCall(ctx context.Context, d QuorumCallData) *Async { - expectedReplies := len(c) - md := ordering.NewGorumsMetadata(ctx, c.getMsgID(), d.Method) - replyChan := make(chan response, expectedReplies) - - for _, n := range c { - msg := d.Message - if d.PerNodeArgFn != nil { - msg = d.PerNodeArgFn(d.Message, n.id) - if !msg.ProtoReflect().IsValid() { - expectedReplies-- - continue // don't send if no msg - } - } - n.channel.enqueue(request{ctx: ctx, msg: &Message{Metadata: md, Message: msg}}, replyChan, false) +func IterAsync[responseType proto.Message, resultType any]( + iter Iterator[responseType], + asyncFunc func(Iterator[responseType]) resultType, +) Async[resultType] { + async := Async[resultType]{ + c: make(chan struct{}), } - fut := &Async{c: make(chan struct{}, 1)} + go func() { + async.reply = asyncFunc(iter) - go c.handleAsyncCall(ctx, fut, asyncCallState{ - md: md, - data: d, - replyChan: replyChan, - expectedReplies: expectedReplies, - }) + close(async.c) + }() - return fut -} - -func (c RawConfiguration) handleAsyncCall(ctx context.Context, fut *Async, state asyncCallState) { - defer close(fut.c) - - var ( - resp protoreflect.ProtoMessage - errs []nodeError - quorum bool - replies = make(map[uint32]protoreflect.ProtoMessage) - ) - - for { - select { - case r := <-state.replyChan: - if r.err != nil { - errs = append(errs, nodeError{nodeID: r.nid, cause: r.err}) - break - } - replies[r.nid] = r.msg - if resp, quorum = state.data.QuorumFunction(state.data.Message, replies); quorum { - fut.reply, fut.err = resp, nil - return - } - case <-ctx.Done(): - fut.reply, fut.err = resp, QuorumCallError{cause: ctx.Err()} - return - } - if len(errs)+len(replies) == state.expectedReplies { - fut.reply, fut.err = resp, QuorumCallError{cause: Incomplete} - return - } - } + return async } diff --git a/benchmark/benchmark.go b/benchmark/benchmark.go index bdc3b96b1..9999ca454 100644 --- a/benchmark/benchmark.go +++ b/benchmark/benchmark.go @@ -8,6 +8,7 @@ import ( "sync/atomic" "time" + gorums "github.com/relab/gorums" "golang.org/x/sync/errgroup" ) @@ -32,12 +33,12 @@ type Bench struct { type ( benchFunc func(Options) (*Result, error) - qcFunc func(context.Context, *Echo) (*Echo, error) - asyncQCFunc func(context.Context, *Echo) *AsyncEcho + qcFunc func(context.Context, *Configuration, QSpec, *Echo) (*Echo, error) + asyncQCFunc func(context.Context, *Echo) *gorums.Iterator[*Echo] serverFunc func(context.Context, *TimedMsg) ) -func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error) { +func runQCBenchmark(opts Options, cfg *Configuration, qspec QSpec, f qcFunc) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() msg := Echo_builder{Payload: make([]byte, opts.Payload)}.Build() @@ -48,7 +49,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error) g.Go(func() error { warmupEnd := time.Now().Add(opts.Warmup) for !time.Now().After(warmupEnd) { - _, err := f(ctx, msg) + _, err := f(ctx, cfg, qspec, msg) if err != nil { return err } @@ -63,7 +64,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error) } if opts.Remote { - _, err := cfg.StartBenchmark(ctx, &StartRequest{}) + _, err := QspecWrapper(cfg, qspec, cfg.StartBenchmark(ctx, &StartRequest{}), &StartRequest{}, StartBenchmarkQF) if err != nil { return nil, err } @@ -75,7 +76,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error) endTime := time.Now().Add(opts.Duration) for !time.Now().After(endTime) { start := time.Now() - _, err := f(ctx, msg) + _, err := f(ctx, cfg, qspec, msg) if err != nil { return err } @@ -93,7 +94,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error) result := s.GetResult() if opts.Remote { - memStats, err := cfg.StopBenchmark(ctx, &StopRequest{}) + memStats, err := QspecWrapper(cfg, qspec, cfg.StopBenchmark(ctx, &StopRequest{}), &StopRequest{}, StopBenchmarkQF) if err != nil { return nil, err } @@ -103,7 +104,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error) return result, nil } -func runAsyncQCBenchmark(opts Options, cfg *Configuration, f asyncQCFunc) (*Result, error) { +func runAsyncQCBenchmark(opts Options, cfg *Configuration, qspec QSpec) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() msg := Echo_builder{Payload: make([]byte, opts.Payload)}.Build() @@ -116,9 +117,9 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, f asyncQCFunc) (*Resu var warmupFunc func() error warmupFunc = func() error { for ; !time.Now().After(warmupEnd) && atomic.LoadUint64(&async) < uint64(opts.MaxAsync); atomic.AddUint64(&async, 1) { - fut := f(ctx, msg) + responses := cfg.AsyncQuorumCall(ctx, msg) g.Go(func() error { - _, err := fut.Get() + _, err := QspecWrapper(cfg, qspec, responses, msg, qf) if err != nil { return err } @@ -139,7 +140,7 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, f asyncQCFunc) (*Resu } if opts.Remote { - _, err := cfg.StartBenchmark(ctx, &StartRequest{}) + _, err := QspecWrapper(cfg, qspec, cfg.StartBenchmark(ctx, &StartRequest{}), &StartRequest{}, StartBenchmarkQF) if err != nil { return nil, err } @@ -150,9 +151,9 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, f asyncQCFunc) (*Resu benchmarkFunc = func() error { for ; !time.Now().After(endTime) && atomic.LoadUint64(&async) < uint64(opts.MaxAsync); atomic.AddUint64(&async, 1) { start := time.Now() - fut := f(ctx, msg) + responses := cfg.AsyncQuorumCall(ctx, msg) g.Go(func() error { - _, err := fut.Get() + _, err := QspecWrapper(cfg, qspec, responses, msg, qf) if err != nil { return err } @@ -177,7 +178,7 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, f asyncQCFunc) (*Resu result := s.GetResult() if opts.Remote { - memStats, err := cfg.StopBenchmark(ctx, &StopRequest{}) + memStats, err := QspecWrapper(cfg, qspec, cfg.StopBenchmark(ctx, &StopRequest{}), &StopRequest{}, StopBenchmarkQF) if err != nil { return nil, err } @@ -187,7 +188,7 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, f asyncQCFunc) (*Resu return result, nil } -func runServerBenchmark(opts Options, cfg *Configuration, f serverFunc) (*Result, error) { +func runServerBenchmark(opts Options, cfg *Configuration, qspec QSpec, f serverFunc) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() payload := make([]byte, opts.Payload) @@ -211,7 +212,7 @@ func runServerBenchmark(opts Options, cfg *Configuration, f serverFunc) (*Result return nil, err } - _, err = cfg.StartServerBenchmark(ctx, &StartRequest{}) + _, err = QspecWrapper(cfg, qspec, cfg.StartServerBenchmark(ctx, &StartRequest{}), &StartRequest{}, StartServerBenchmarkQF) if err != nil { return nil, err } @@ -227,7 +228,7 @@ func runServerBenchmark(opts Options, cfg *Configuration, f serverFunc) (*Result } runtime.ReadMemStats(&end) - resp, err := cfg.StopServerBenchmark(ctx, &StopRequest{}) + resp, err := QspecWrapper(cfg, qspec, cfg.StopServerBenchmark(ctx, &StopRequest{}), &StopRequest{}, StopServerBenchmarkQF) if err != nil { return nil, err } @@ -241,28 +242,28 @@ func runServerBenchmark(opts Options, cfg *Configuration, f serverFunc) (*Result } // GetBenchmarks returns a list of Benchmarks that can be performed on the configuration -func GetBenchmarks(cfg *Configuration) []Bench { +func GetBenchmarks(cfg *Configuration, qspec QSpec) []Bench { m := []Bench{ { Name: "QuorumCall", Description: "NodeStream based quorum call implementation with FIFO ordering", - runBench: func(opts Options) (*Result, error) { return runQCBenchmark(opts, cfg, cfg.QuorumCall) }, + runBench: func(opts Options) (*Result, error) { return runQCBenchmark(opts, cfg, qspec, QuorumCall) }, }, { Name: "AsyncQuorumCall", Description: "NodeStream based async quorum call implementation with FIFO ordering", - runBench: func(opts Options) (*Result, error) { return runAsyncQCBenchmark(opts, cfg, cfg.AsyncQuorumCall) }, + runBench: func(opts Options) (*Result, error) { return runAsyncQCBenchmark(opts, cfg, qspec) }, }, { Name: "SlowServer", Description: "Quorum Call with a 10s processing time on the server", - runBench: func(opts Options) (*Result, error) { return runQCBenchmark(opts, cfg, cfg.SlowServer) }, + runBench: func(opts Options) (*Result, error) { return runQCBenchmark(opts, cfg, qspec, SlowServer) }, }, { Name: "Multicast", Description: "NodeStream based multicast implementation (servers measure latency and throughput)", runBench: func(opts Options) (*Result, error) { - return runServerBenchmark(opts, cfg, func(ctx context.Context, msg *TimedMsg) { cfg.Multicast(ctx, msg) }) + return runServerBenchmark(opts, cfg, qspec, func(ctx context.Context, msg *TimedMsg) { cfg.Multicast(ctx, msg) }) }, }, } @@ -270,8 +271,8 @@ func GetBenchmarks(cfg *Configuration) []Bench { } // RunBenchmarks runs all the benchmarks that match the given regex with the given options -func RunBenchmarks(benchRegex *regexp.Regexp, options Options, cfg *Configuration) ([]*Result, error) { - benchmarks := GetBenchmarks(cfg) +func RunBenchmarks(benchRegex *regexp.Regexp, options Options, cfg *Configuration, qspec QSpec) ([]*Result, error) { + benchmarks := GetBenchmarks(cfg, qspec) var results []*Result for _, b := range benchmarks { if benchRegex.MatchString(b.Name) { diff --git a/benchmark/benchmark.pb.go b/benchmark/benchmark.pb.go index 59ca644a1..946512671 100644 --- a/benchmark/benchmark.pb.go +++ b/benchmark/benchmark.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.2 +// protoc v6.30.2 // source: benchmark/benchmark.proto package benchmark @@ -620,15 +620,15 @@ const file_benchmark_benchmark_proto_rawDesc = "" + "\x06Allocs\x18\x01 \x01(\x04R\x06Allocs\x12\x16\n" + "\x06Memory\x18\x02 \x01(\x04R\x06Memory\"I\n" + "\x0eMemoryStatList\x127\n" + - "\vMemoryStats\x18\x01 \x03(\v2\x15.benchmark.MemoryStatR\vMemoryStats2\xb2\x04\n" + + "\vMemoryStats\x18\x01 \x03(\v2\x15.benchmark.MemoryStatR\vMemoryStats2\x9c\x04\n" + "\tBenchmark\x12O\n" + "\x14StartServerBenchmark\x12\x17.benchmark.StartRequest\x1a\x18.benchmark.StartResponse\"\x04\xa0\xb5\x18\x01\x12F\n" + "\x13StopServerBenchmark\x12\x16.benchmark.StopRequest\x1a\x11.benchmark.Result\"\x04\xa0\xb5\x18\x01\x12I\n" + - "\x0eStartBenchmark\x12\x17.benchmark.StartRequest\x1a\x18.benchmark.StartResponse\"\x04\xa0\xb5\x18\x01\x12V\n" + - "\rStopBenchmark\x12\x16.benchmark.StopRequest\x1a\x15.benchmark.MemoryStat\"\x16\xa0\xb5\x18\x01\xf2\xb6\x18\x0eMemoryStatList\x124\n" + + "\x0eStartBenchmark\x12\x17.benchmark.StartRequest\x1a\x18.benchmark.StartResponse\"\x04\xa0\xb5\x18\x01\x12D\n" + + "\rStopBenchmark\x12\x16.benchmark.StopRequest\x1a\x15.benchmark.MemoryStat\"\x04\xa0\xb5\x18\x01\x124\n" + "\n" + - "QuorumCall\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x12=\n" + - "\x0fAsyncQuorumCall\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\b\xa0\xb5\x18\x01ะต\x18\x01\x124\n" + + "QuorumCall\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x129\n" + + "\x0fAsyncQuorumCall\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x124\n" + "\n" + "SlowServer\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x12>\n" + "\tMulticast\x12\x13.benchmark.TimedMsg\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01B(Z!github.com/relab/gorums/benchmark\x92\x03\x02\b\x02b\beditionsp\xe8\a" diff --git a/benchmark/benchmark.proto b/benchmark/benchmark.proto index d64e5132a..493a5d26d 100644 --- a/benchmark/benchmark.proto +++ b/benchmark/benchmark.proto @@ -60,8 +60,7 @@ service Benchmark { } rpc StopBenchmark(StopRequest) returns (MemoryStat) { - option (gorums.quorumcall) = true; - option (gorums.custom_return_type) = "MemoryStatList"; + option (gorums.quorumcall) = true; } // benchmarks @@ -71,7 +70,6 @@ service Benchmark { rpc AsyncQuorumCall(Echo) returns (Echo) { option (gorums.quorumcall) = true; - option (gorums.async) = true; } rpc SlowServer(Echo) returns (Echo) { diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 06719ad95..97711f2b4 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,19 +1,16 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: benchmark/benchmark.proto package benchmark import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" emptypb "google.golang.org/protobuf/types/known/emptypb" - iter "iter" ) const ( @@ -27,7 +24,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -37,15 +33,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -102,30 +92,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -151,35 +124,21 @@ type Node struct { *gorums.RawNode } -// AsyncQuorumCall asynchronously invokes a quorum call on configuration c -// and returns a AsyncEcho, which can be used to inspect the quorum call -// reply and error when available. -func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) *AsyncEcho { - cd := gorums.QuorumCallData{ - Message: in, - Method: "benchmark.Benchmark.AsyncQuorumCall", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Echo, len(replies)) - for k, v := range replies { - r[k] = v.(*Echo) - } - return c.qspec.AsyncQuorumCallQF(req.(*Echo), r) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncEcho{fut} -} - // BenchmarkClient is the client interface for the Benchmark service. type BenchmarkClient interface { - StartServerBenchmark(ctx context.Context, in *StartRequest) iter.Seq2[*StartResponse, error] - StopServerBenchmark(ctx context.Context, in *StopRequest) iter.Seq2[*Result, error] - StartBenchmark(ctx context.Context, in *StartRequest) iter.Seq2[*StartResponse, error] - StopBenchmark(ctx context.Context, in *StopRequest) iter.Seq2[*MemoryStatList, error] - QuorumCall(ctx context.Context, in *Echo) iter.Seq2[*Echo, error] - AsyncQuorumCall(ctx context.Context, in *Echo) *AsyncEcho - SlowServer(ctx context.Context, in *Echo) iter.Seq2[*Echo, error] + StartServerBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] + + StopServerBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*Result] + + StartBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] + + StopBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*MemoryStat] + + QuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] + + AsyncQuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] + + SlowServer(ctx context.Context, in *Echo) gorums.Iterator[*Echo] Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption) } @@ -190,7 +149,7 @@ var _ BenchmarkClient = (*Configuration)(nil) var _ emptypb.Empty // Multicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (c *Configuration) Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, @@ -200,120 +159,84 @@ func (c *Configuration) Multicast(ctx context.Context, in *TimedMsg, opts ...gor c.RawConfiguration.Multicast(ctx, cd, opts...) } -// QuorumSpec is the interface of quorum functions for Benchmark. -type QuorumSpec interface { - gorums.ConfigOption - - // StartServerBenchmarkQF is the quorum function for the StartServerBenchmark - // quorum call method. The in parameter is the request object - // supplied to the StartServerBenchmark method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *StartRequest'. - StartServerBenchmarkQF(in *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool) - - // StopServerBenchmarkQF is the quorum function for the StopServerBenchmark - // quorum call method. The in parameter is the request object - // supplied to the StopServerBenchmark method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *StopRequest'. - StopServerBenchmarkQF(in *StopRequest, replies map[uint32]*Result) (*Result, bool) - - // StartBenchmarkQF is the quorum function for the StartBenchmark - // quorum call method. The in parameter is the request object - // supplied to the StartBenchmark method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *StartRequest'. - StartBenchmarkQF(in *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool) - - // StopBenchmarkQF is the quorum function for the StopBenchmark - // quorum call method. The in parameter is the request object - // supplied to the StopBenchmark method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *StopRequest'. - StopBenchmarkQF(in *StopRequest, replies map[uint32]*MemoryStat) (*MemoryStatList, bool) - - // QuorumCallQF is the quorum function for the QuorumCall - // quorum call method. The in parameter is the request object - // supplied to the QuorumCall method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Echo'. - QuorumCallQF(in *Echo, replies map[uint32]*Echo) (*Echo, bool) - - // AsyncQuorumCallQF is the quorum function for the AsyncQuorumCall - // asynchronous quorum call method. The in parameter is the request object - // supplied to the AsyncQuorumCall method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Echo'. - AsyncQuorumCallQF(in *Echo, replies map[uint32]*Echo) (*Echo, bool) - - // SlowServerQF is the quorum function for the SlowServer - // quorum call method. The in parameter is the request object - // supplied to the SlowServer method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Echo'. - SlowServerQF(in *Echo, replies map[uint32]*Echo) (*Echo, bool) -} - // StartServerBenchmark is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartRequest) iter.Seq2[*StartResponse, error] { +// with the same argument in, and returns a combined result. test +func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] { cd := gorums.QuorumCallData{ - Message: in, - Method: "benchmark.Benchmark.StartServerBenchmark", + Message: in, + Method: "benchmark.Benchmark.StartServerBenchmark", + ServerStream: false, } return gorums.QuorumCall[*StartResponse](ctx, c.RawConfiguration, cd) } // StopServerBenchmark is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest) iter.Seq2[*Result, error] { +// with the same argument in, and returns a combined result. test +func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*Result] { cd := gorums.QuorumCallData{ - Message: in, - Method: "benchmark.Benchmark.StopServerBenchmark", + Message: in, + Method: "benchmark.Benchmark.StopServerBenchmark", + ServerStream: false, } return gorums.QuorumCall[*Result](ctx, c.RawConfiguration, cd) } // StartBenchmark is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) iter.Seq2[*StartResponse, error] { +// with the same argument in, and returns a combined result. test +func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] { cd := gorums.QuorumCallData{ - Message: in, - Method: "benchmark.Benchmark.StartBenchmark", + Message: in, + Method: "benchmark.Benchmark.StartBenchmark", + ServerStream: false, } return gorums.QuorumCall[*StartResponse](ctx, c.RawConfiguration, cd) } // StopBenchmark is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) iter.Seq2[*MemoryStatList, error] { +// with the same argument in, and returns a combined result. test +func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*MemoryStat] { cd := gorums.QuorumCallData{ - Message: in, - Method: "benchmark.Benchmark.StopBenchmark", + Message: in, + Method: "benchmark.Benchmark.StopBenchmark", + ServerStream: false, } - return gorums.QuorumCall[*MemoryStatList](ctx, c.RawConfiguration, cd) + return gorums.QuorumCall[*MemoryStat](ctx, c.RawConfiguration, cd) } // benchmarks -func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) iter.Seq2[*Echo, error] { +func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] { cd := gorums.QuorumCallData{ - Message: in, - Method: "benchmark.Benchmark.QuorumCall", + Message: in, + Method: "benchmark.Benchmark.QuorumCall", + ServerStream: false, + } + + return gorums.QuorumCall[*Echo](ctx, c.RawConfiguration, cd) +} + +// AsyncQuorumCall is a quorum call invoked on all nodes in configuration c, +// with the same argument in, and returns a combined result. test +func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] { + cd := gorums.QuorumCallData{ + Message: in, + Method: "benchmark.Benchmark.AsyncQuorumCall", + ServerStream: false, } return gorums.QuorumCall[*Echo](ctx, c.RawConfiguration, cd) } // SlowServer is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) SlowServer(ctx context.Context, in *Echo) iter.Seq2[*Echo, error] { +// with the same argument in, and returns a combined result. test +func (c *Configuration) SlowServer(ctx context.Context, in *Echo) gorums.Iterator[*Echo] { cd := gorums.QuorumCallData{ - Message: in, - Method: "benchmark.Benchmark.SlowServer", + Message: in, + Method: "benchmark.Benchmark.SlowServer", + ServerStream: false, } return gorums.QuorumCall[*Echo](ctx, c.RawConfiguration, cd) @@ -404,18 +327,3 @@ type internalStartResponse struct { reply *StartResponse err error } - -// AsyncEcho is a async object for processing replies. -type AsyncEcho struct { - *gorums.Async -} - -// Get returns the reply and any error associated with the called method. -// The method blocks until a reply or error is available. -func (f *AsyncEcho) Get() (*Echo, error) { - resp, err := f.Async.Get() - if err != nil { - return nil, err - } - return resp.(*Echo), err -} diff --git a/benchmark/qspec.go b/benchmark/qspec.go index 8957978d1..1f9538232 100644 --- a/benchmark/qspec.go +++ b/benchmark/qspec.go @@ -1,12 +1,20 @@ package benchmark +import ( + "context" + "errors" + + gorums "github.com/relab/gorums" + "google.golang.org/protobuf/proto" +) + // QSpec is the quorum specification object for the benchmark type QSpec struct { CfgSize int QSize int } -func (qspec *QSpec) qf(replies map[uint32]*Echo) (*Echo, bool) { +func qf(qspec QSpec, _ *Echo, replies []*Echo) (*Echo, bool) { if len(replies) < qspec.QSize { return nil, false } @@ -20,7 +28,7 @@ func (qspec *QSpec) qf(replies map[uint32]*Echo) (*Echo, bool) { // StartServerBenchmarkQF is the quorum function for the StartServerBenchmark quorumcall. // It requires a response from all nodes. -func (qspec *QSpec) StartServerBenchmarkQF(_ *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool) { +func StartServerBenchmarkQF(qspec QSpec, _ *StartRequest, replies []*StartResponse) (*StartResponse, bool) { if len(replies) < qspec.CfgSize { return nil, false } @@ -35,7 +43,7 @@ func (qspec *QSpec) StartServerBenchmarkQF(_ *StartRequest, replies map[uint32]* // StopServerBenchmarkQF is the quorum function for the StopServerBenchmark quorumcall. // It requires a response from all nodes. -func (qspec *QSpec) StopServerBenchmarkQF(_ *StopRequest, replies map[uint32]*Result) (*Result, bool) { +func StopServerBenchmarkQF(qspec QSpec, _ *StopRequest, replies []*Result) (*Result, bool) { if len(replies) < qspec.CfgSize { return nil, false } @@ -67,7 +75,7 @@ func (qspec *QSpec) StopServerBenchmarkQF(_ *StopRequest, replies map[uint32]*Re // StartBenchmarkQF is the quorum function for the StartBenchmark quorumcall. // It requires a response from all nodes. -func (qspec *QSpec) StartBenchmarkQF(_ *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool) { +func StartBenchmarkQF(qspec QSpec, _ *StartRequest, replies []*StartResponse) (*StartResponse, bool) { if len(replies) < qspec.CfgSize { return nil, false } @@ -82,7 +90,7 @@ func (qspec *QSpec) StartBenchmarkQF(_ *StartRequest, replies map[uint32]*StartR // StopBenchmarkQF is the quorum function for the StopBenchmark quorumcall. // It requires a response from all nodes. -func (qspec *QSpec) StopBenchmarkQF(_ *StopRequest, replies map[uint32]*MemoryStat) (*MemoryStatList, bool) { +func StopBenchmarkQF(qspec QSpec, _ *StopRequest, replies []*MemoryStat) (*MemoryStatList, bool) { if len(replies) < qspec.CfgSize { return nil, false } @@ -93,17 +101,141 @@ func (qspec *QSpec) StopBenchmarkQF(_ *StopRequest, replies map[uint32]*MemorySt return MemoryStatList_builder{MemoryStats: replyList}.Build(), true } +func QspecWrapper[ + requestType proto.Message, + replyType proto.Message, + returnType proto.Message, +]( + cfg *Configuration, + qspec QSpec, + iterator gorums.Iterator[replyType], + request requestType, + f func(QSpec, requestType, []replyType) (returnType, bool), +) (returnType, error) { + replies := make([]replyType, 0) + var noResult returnType + for reply := range iterator { + msg, err, _ := reply.Unpack() + replies = append(replies, msg) + if err != nil { + continue + } + result, quorum := f(qspec, request, replies) + if quorum { + return result, nil + } + } + return noResult, errors.New("quorumcall no result") +} + // QuorumCallQF is the quorum function for the QuorumCall quorumcall -func (qspec *QSpec) QuorumCallQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { - return qspec.qf(replies) +func QuorumCall(ctx context.Context, cfg *Configuration, qspec QSpec, request *Echo) (*Echo, error) { + return QspecWrapper(cfg, qspec, cfg.QuorumCall(ctx, request), request, qf) } -// AsyncQuorumCallQF is the quorum function for the AsyncQuorumCall quorumcall -func (qspec *QSpec) AsyncQuorumCallQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { +// SlowServerQF is the quorum function for the SlowServer quorumcall +func SlowServer(ctx context.Context, cfg *Configuration, qspec QSpec, request *Echo) (*Echo, error) { + return QspecWrapper(cfg, qspec, cfg.SlowServer(ctx, request), request, qf) +} + +func (qspec QSpec) qf(replies map[uint32]*Echo) (*Echo, bool) { + if len(replies) < qspec.QSize { + return nil, false + } + var resp *Echo + for _, r := range replies { + resp = r + break + } + return resp, true +} + +// StartServerBenchmarkQF is the quorum function for the StartServerBenchmark quorumcall. +// It requires a response from all nodes. +func (qspec QSpec) StartServerBenchmarkQF(_ *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool) { + if len(replies) < qspec.CfgSize { + return nil, false + } + // return any response + var resp *StartResponse + for _, r := range replies { + resp = r + break + } + return resp, true +} + +// StopServerBenchmarkQF is the quorum function for the StopServerBenchmark quorumcall. +// It requires a response from all nodes. +func (qspec QSpec) StopServerBenchmarkQF(_ *StopRequest, replies map[uint32]*Result) (*Result, bool) { + if len(replies) < qspec.CfgSize { + return nil, false + } + // combine results, calculating averages and pooled variance + resp := &Result{} + for _, reply := range replies { + if resp.GetName() != "" { + resp.SetName(reply.GetName()) + } + resp.SetTotalOps(resp.GetTotalOps() + reply.GetTotalOps()) + resp.SetTotalTime(resp.GetTotalTime() + reply.GetTotalTime()) + resp.SetThroughput(resp.GetThroughput() + reply.GetThroughput()) + resp.SetLatencyAvg(resp.GetLatencyAvg() + reply.GetLatencyAvg()*float64(reply.GetTotalOps())) + resp.SetServerStats(append(resp.GetServerStats(), MemoryStat_builder{ + Allocs: reply.GetAllocsPerOp() * resp.GetTotalOps(), + Memory: reply.GetMemPerOp() * resp.GetTotalOps(), + }.Build())) + } + resp.SetLatencyAvg(resp.GetLatencyAvg() / float64(resp.GetTotalOps())) + for _, reply := range replies { + resp.SetLatencyVar(resp.GetLatencyVar() + float64(reply.GetTotalOps()-1)*reply.GetLatencyVar()) + } + resp.SetLatencyVar(resp.GetLatencyVar() / (float64(resp.GetTotalOps()) - float64(len(replies)))) + resp.SetTotalOps(resp.GetTotalOps() / uint64(len(replies))) + resp.SetTotalTime(resp.GetTotalTime() / int64(len(replies))) + resp.SetThroughput(resp.GetThroughput() / float64(len(replies))) + return resp, true +} + +// StartBenchmarkQF is the quorum function for the StartBenchmark quorumcall. +// It requires a response from all nodes. +func (qspec QSpec) StartBenchmarkQF(_ *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool) { + if len(replies) < qspec.CfgSize { + return nil, false + } + // return any response + var resp *StartResponse + for _, r := range replies { + resp = r + break + } + return resp, true +} + +// StopBenchmarkQF is the quorum function for the StopBenchmark quorumcall. +// It requires a response from all nodes. +func (qspec QSpec) StopBenchmarkQF(_ *StopRequest, replies map[uint32]*MemoryStat) (*MemoryStatList, bool) { + if len(replies) < qspec.CfgSize { + return nil, false + } + replyList := make([]*MemoryStat, 0, len(replies)) + for _, v := range replies { + replyList = append(replyList, v) + } + return MemoryStatList_builder{MemoryStats: replyList}.Build(), true +} + +// QuorumCallQF is the quorum function for the QuorumCall quorumcall +func (qspec QSpec) QuorumCallQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { return qspec.qf(replies) } // SlowServerQF is the quorum function for the SlowServer quorumcall -func (qspec *QSpec) SlowServerQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { +func (qspec QSpec) SlowServerQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { + return qspec.qf(replies) +} + +// AsyncQuorumCallQF is the quorum function for the AsyncQuorumCall quorumcall +func (qspec QSpec) AsyncQuorumCallQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { return qspec.qf(replies) } diff --git a/channel.go b/channel.go index 5edf88715..071b74365 100644 --- a/channel.go +++ b/channel.go @@ -14,7 +14,7 @@ import ( "google.golang.org/grpc/backoff" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/proto" ) var streamDownErr = status.Error(codes.Unavailable, "stream is down") @@ -32,7 +32,7 @@ func (req request) waitForSend() bool { type response struct { nid uint32 - msg protoreflect.ProtoMessage + msg proto.Message err error } @@ -50,7 +50,7 @@ type channel struct { backoffCfg backoff.Config rand *rand.Rand gorumsClient ordering.GorumsClient - gorumsStream ordering.Gorums_NodeStreamClient + gorumsStream grpc.BidiStreamingClient[ordering.Metadata, ordering.Metadata] streamMut sync.RWMutex streamBroken atomicFlag connEstablished atomicFlag diff --git a/cmd/benchmark/main.go b/cmd/benchmark/main.go index 9a97b85bc..bf10610fd 100644 --- a/cmd/benchmark/main.go +++ b/cmd/benchmark/main.go @@ -58,7 +58,7 @@ func (f *listFlag) Get() []string { func listBenchmarks() { tw := tabwriter.NewWriter(os.Stdout, 0, 0, 4, ' ', 0) - benchmarks := benchmark.GetBenchmarks(nil) + benchmarks := benchmark.GetBenchmarks(nil, benchmark.QSpec{}) for _, b := range benchmarks { fmt.Fprintf(tw, "%s:\t%s\n", b.Name, b.Description) } @@ -199,15 +199,15 @@ func main() { mgr := benchmark.NewManager(mgrOpts...) defer mgr.Close() - qspec := &benchmark.QSpec{ + qspec := benchmark.QSpec{ QSize: options.QuorumSize, CfgSize: options.NumNodes, } - cfg, err := mgr.NewConfiguration(qspec, gorums.WithNodeList(remotes[:options.NumNodes])) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(remotes[:options.NumNodes])) checkf("Failed to create configuration: %v", err) - results, err := benchmark.RunBenchmarks(benchReg, options, cfg) + results, err := benchmark.RunBenchmarks(benchReg, options, cfg, qspec) checkf("Error running benchmarks: %v", err) printResults(results, options, *serverStats) diff --git a/cmd/protoc-gen-gorums/dev/config.go b/cmd/protoc-gen-gorums/dev/config.go index 3ec3d3df2..18e7d9dcd 100644 --- a/cmd/protoc-gen-gorums/dev/config.go +++ b/cmd/protoc-gen-gorums/dev/config.go @@ -1,8 +1,6 @@ package dev import ( - "fmt" - "github.com/relab/gorums" ) @@ -10,7 +8,6 @@ import ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -20,15 +17,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) diff --git a/cmd/protoc-gen-gorums/dev/mgr.go b/cmd/protoc-gen-gorums/dev/mgr.go index fc603ac45..7b0ab5232 100644 --- a/cmd/protoc-gen-gorums/dev/mgr.go +++ b/cmd/protoc-gen-gorums/dev/mgr.go @@ -1,8 +1,6 @@ package dev import ( - "fmt" - "github.com/relab/gorums" "google.golang.org/grpc/encoding" ) @@ -35,30 +33,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { diff --git a/cmd/protoc-gen-gorums/dev/zorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums.pb.go index 3a206f53d..52c8d2571 100644 --- a/cmd/protoc-gen-gorums/dev/zorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.2 +// protoc v6.30.2 // source: zorums.proto package dev @@ -204,18 +204,18 @@ const file_zorums_proto_rawDesc = "" + "\x06Result\x18\x01 \x01(\x03R\x06Result\"\"\n" + "\n" + "MyResponse\x12\x14\n" + - "\x05Value\x18\x01 \x01(\tR\x05Value2\x86\x11\n" + + "\x05Value\x18\x01 \x01(\tR\x05Value2\xbd\a\n" + "\rZorumsService\x12)\n" + "\bGRPCCall\x12\f.dev.Request\x1a\r.dev.Response\"\x00\x12/\n" + "\n" + "QuorumCall\x12\f.dev.Request\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x01\x12=\n" + - "\x14QuorumCallPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01\xa0\xb6\x18\x01\x12M\n" + - "\x1aQuorumCallCustomReturnType\x12\f.dev.Request\x1a\r.dev.Response\"\x12\xa0\xb5\x18\x01\xf2\xb6\x18\n" + - "MyResponse\x12F\n" + - "\x0fQuorumCallCombo\x12\f.dev.Request\x1a\r.dev.Response\"\x16\xa0\xb5\x18\x01\xa0\xb6\x18\x01\xf2\xb6\x18\n" + - "MyResponse\x12>\n" + + "\x14QuorumCallPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01\xa0\xb6\x18\x01\x12>\n" + "\x0fQuorumCallEmpty\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x01\x12>\n" + - "\x10QuorumCallEmpty2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa0\xb5\x18\x01\x12.\n" + + "\x10QuorumCallEmpty2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa0\xb5\x18\x01\x127\n" + + "\x10QuorumCallStream\x12\f.dev.Request\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x010\x01\x12E\n" + + "\x1aQuorumCallStreamPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01\xa0\xb6\x18\x010\x01\x12F\n" + + "\x15QuorumCallStreamEmpty\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x010\x01\x12F\n" + + "\x16QuorumCallStreamEmpty2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa0\xb5\x18\x010\x01\x12.\n" + "\tMulticast\x12\f.dev.Request\x1a\r.dev.Response\"\x04\x98\xb5\x18\x01\x12<\n" + "\x13MulticastPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\x98\xb5\x18\x01\xa0\xb6\x18\x01\x12/\n" + "\n" + @@ -223,32 +223,7 @@ const file_zorums_proto_rawDesc = "" + "\n" + "Multicast3\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01\x12B\n" + "\n" + - "Multicast4\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01\x128\n" + - "\x0fQuorumCallAsync\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01ะต\x18\x01\x12F\n" + - "\x19QuorumCallAsyncPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\f\xa0\xb5\x18\x01ะต\x18\x01\xa0\xb6\x18\x01\x12V\n" + - "\x1fQuorumCallAsyncCustomReturnType\x12\f.dev.Request\x1a\r.dev.Response\"\x16\xa0\xb5\x18\x01ะต\x18\x01\xf2\xb6\x18\n" + - "MyResponse\x12O\n" + - "\x14QuorumCallAsyncCombo\x12\f.dev.Request\x1a\r.dev.Response\"\x1a\xa0\xb5\x18\x01ะต\x18\x01\xa0\xb6\x18\x01\xf2\xb6\x18\n" + - "MyResponse\x129\n" + - "\x10QuorumCallAsync2\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01ะต\x18\x01\x12F\n" + - "\x14QuorumCallAsyncEmpty\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\b\xa0\xb5\x18\x01ะต\x18\x01\x12H\n" + - "\x15QuorumCallAsyncEmpty2\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01ะต\x18\x01\x120\n" + - "\vCorrectable\x12\f.dev.Request\x1a\r.dev.Response\"\x04\xa8\xb5\x18\x01\x12>\n" + - "\x15CorrectablePerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa8\xb5\x18\x01\xa0\xb6\x18\x01\x12N\n" + - "\x1bCorrectableCustomReturnType\x12\f.dev.Request\x1a\r.dev.Response\"\x12\xa8\xb5\x18\x01\xf2\xb6\x18\n" + - "MyResponse\x12G\n" + - "\x10CorrectableCombo\x12\f.dev.Request\x1a\r.dev.Response\"\x16\xa8\xb5\x18\x01\xa0\xb6\x18\x01\xf2\xb6\x18\n" + - "MyResponse\x12>\n" + - "\x10CorrectableEmpty\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa8\xb5\x18\x01\x12@\n" + - "\x11CorrectableEmpty2\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\x04\xa8\xb5\x18\x01\x128\n" + - "\x11CorrectableStream\x12\f.dev.Request\x1a\r.dev.Response\"\x04\xa8\xb5\x18\x010\x01\x12F\n" + - "\x1bCorrectableStreamPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa8\xb5\x18\x01\xa0\xb6\x18\x010\x01\x12V\n" + - "!CorrectableStreamCustomReturnType\x12\f.dev.Request\x1a\r.dev.Response\"\x12\xa8\xb5\x18\x01\xf2\xb6\x18\n" + - "MyResponse0\x01\x12O\n" + - "\x16CorrectableStreamCombo\x12\f.dev.Request\x1a\r.dev.Response\"\x16\xa8\xb5\x18\x01\xa0\xb6\x18\x01\xf2\xb6\x18\n" + - "MyResponse0\x01\x12F\n" + - "\x16CorrectableStreamEmpty\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa8\xb5\x18\x010\x01\x12H\n" + - "\x17CorrectableStreamEmpty2\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\x04\xa8\xb5\x18\x010\x01\x12,\n" + + "Multicast4\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01\x12,\n" + "\aUnicast\x12\f.dev.Request\x1a\r.dev.Response\"\x04\x90\xb5\x18\x01\x126\n" + "\bUnicast2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\x90\xb5\x18\x01B Z\x19cmd/protoc-gen-gorums/dev\x92\x03\x02\b\x02b\beditionsp\xe8\a" @@ -263,71 +238,37 @@ var file_zorums_proto_depIdxs = []int32{ 0, // 0: dev.ZorumsService.GRPCCall:input_type -> dev.Request 0, // 1: dev.ZorumsService.QuorumCall:input_type -> dev.Request 0, // 2: dev.ZorumsService.QuorumCallPerNodeArg:input_type -> dev.Request - 0, // 3: dev.ZorumsService.QuorumCallCustomReturnType:input_type -> dev.Request - 0, // 4: dev.ZorumsService.QuorumCallCombo:input_type -> dev.Request - 3, // 5: dev.ZorumsService.QuorumCallEmpty:input_type -> google.protobuf.Empty - 0, // 6: dev.ZorumsService.QuorumCallEmpty2:input_type -> dev.Request - 0, // 7: dev.ZorumsService.Multicast:input_type -> dev.Request - 0, // 8: dev.ZorumsService.MulticastPerNodeArg:input_type -> dev.Request - 0, // 9: dev.ZorumsService.Multicast2:input_type -> dev.Request - 0, // 10: dev.ZorumsService.Multicast3:input_type -> dev.Request - 3, // 11: dev.ZorumsService.Multicast4:input_type -> google.protobuf.Empty - 0, // 12: dev.ZorumsService.QuorumCallAsync:input_type -> dev.Request - 0, // 13: dev.ZorumsService.QuorumCallAsyncPerNodeArg:input_type -> dev.Request - 0, // 14: dev.ZorumsService.QuorumCallAsyncCustomReturnType:input_type -> dev.Request - 0, // 15: dev.ZorumsService.QuorumCallAsyncCombo:input_type -> dev.Request - 0, // 16: dev.ZorumsService.QuorumCallAsync2:input_type -> dev.Request - 0, // 17: dev.ZorumsService.QuorumCallAsyncEmpty:input_type -> dev.Request - 3, // 18: dev.ZorumsService.QuorumCallAsyncEmpty2:input_type -> google.protobuf.Empty - 0, // 19: dev.ZorumsService.Correctable:input_type -> dev.Request - 0, // 20: dev.ZorumsService.CorrectablePerNodeArg:input_type -> dev.Request - 0, // 21: dev.ZorumsService.CorrectableCustomReturnType:input_type -> dev.Request - 0, // 22: dev.ZorumsService.CorrectableCombo:input_type -> dev.Request - 0, // 23: dev.ZorumsService.CorrectableEmpty:input_type -> dev.Request - 3, // 24: dev.ZorumsService.CorrectableEmpty2:input_type -> google.protobuf.Empty - 0, // 25: dev.ZorumsService.CorrectableStream:input_type -> dev.Request - 0, // 26: dev.ZorumsService.CorrectableStreamPerNodeArg:input_type -> dev.Request - 0, // 27: dev.ZorumsService.CorrectableStreamCustomReturnType:input_type -> dev.Request - 0, // 28: dev.ZorumsService.CorrectableStreamCombo:input_type -> dev.Request - 0, // 29: dev.ZorumsService.CorrectableStreamEmpty:input_type -> dev.Request - 3, // 30: dev.ZorumsService.CorrectableStreamEmpty2:input_type -> google.protobuf.Empty - 0, // 31: dev.ZorumsService.Unicast:input_type -> dev.Request - 0, // 32: dev.ZorumsService.Unicast2:input_type -> dev.Request - 1, // 33: dev.ZorumsService.GRPCCall:output_type -> dev.Response - 1, // 34: dev.ZorumsService.QuorumCall:output_type -> dev.Response - 1, // 35: dev.ZorumsService.QuorumCallPerNodeArg:output_type -> dev.Response - 1, // 36: dev.ZorumsService.QuorumCallCustomReturnType:output_type -> dev.Response - 1, // 37: dev.ZorumsService.QuorumCallCombo:output_type -> dev.Response - 1, // 38: dev.ZorumsService.QuorumCallEmpty:output_type -> dev.Response - 3, // 39: dev.ZorumsService.QuorumCallEmpty2:output_type -> google.protobuf.Empty - 1, // 40: dev.ZorumsService.Multicast:output_type -> dev.Response - 1, // 41: dev.ZorumsService.MulticastPerNodeArg:output_type -> dev.Response - 1, // 42: dev.ZorumsService.Multicast2:output_type -> dev.Response - 3, // 43: dev.ZorumsService.Multicast3:output_type -> google.protobuf.Empty - 3, // 44: dev.ZorumsService.Multicast4:output_type -> google.protobuf.Empty - 1, // 45: dev.ZorumsService.QuorumCallAsync:output_type -> dev.Response - 1, // 46: dev.ZorumsService.QuorumCallAsyncPerNodeArg:output_type -> dev.Response - 1, // 47: dev.ZorumsService.QuorumCallAsyncCustomReturnType:output_type -> dev.Response - 1, // 48: dev.ZorumsService.QuorumCallAsyncCombo:output_type -> dev.Response - 1, // 49: dev.ZorumsService.QuorumCallAsync2:output_type -> dev.Response - 3, // 50: dev.ZorumsService.QuorumCallAsyncEmpty:output_type -> google.protobuf.Empty - 1, // 51: dev.ZorumsService.QuorumCallAsyncEmpty2:output_type -> dev.Response - 1, // 52: dev.ZorumsService.Correctable:output_type -> dev.Response - 1, // 53: dev.ZorumsService.CorrectablePerNodeArg:output_type -> dev.Response - 1, // 54: dev.ZorumsService.CorrectableCustomReturnType:output_type -> dev.Response - 1, // 55: dev.ZorumsService.CorrectableCombo:output_type -> dev.Response - 3, // 56: dev.ZorumsService.CorrectableEmpty:output_type -> google.protobuf.Empty - 1, // 57: dev.ZorumsService.CorrectableEmpty2:output_type -> dev.Response - 1, // 58: dev.ZorumsService.CorrectableStream:output_type -> dev.Response - 1, // 59: dev.ZorumsService.CorrectableStreamPerNodeArg:output_type -> dev.Response - 1, // 60: dev.ZorumsService.CorrectableStreamCustomReturnType:output_type -> dev.Response - 1, // 61: dev.ZorumsService.CorrectableStreamCombo:output_type -> dev.Response - 3, // 62: dev.ZorumsService.CorrectableStreamEmpty:output_type -> google.protobuf.Empty - 1, // 63: dev.ZorumsService.CorrectableStreamEmpty2:output_type -> dev.Response - 1, // 64: dev.ZorumsService.Unicast:output_type -> dev.Response - 3, // 65: dev.ZorumsService.Unicast2:output_type -> google.protobuf.Empty - 33, // [33:66] is the sub-list for method output_type - 0, // [0:33] is the sub-list for method input_type + 3, // 3: dev.ZorumsService.QuorumCallEmpty:input_type -> google.protobuf.Empty + 0, // 4: dev.ZorumsService.QuorumCallEmpty2:input_type -> dev.Request + 0, // 5: dev.ZorumsService.QuorumCallStream:input_type -> dev.Request + 0, // 6: dev.ZorumsService.QuorumCallStreamPerNodeArg:input_type -> dev.Request + 3, // 7: dev.ZorumsService.QuorumCallStreamEmpty:input_type -> google.protobuf.Empty + 0, // 8: dev.ZorumsService.QuorumCallStreamEmpty2:input_type -> dev.Request + 0, // 9: dev.ZorumsService.Multicast:input_type -> dev.Request + 0, // 10: dev.ZorumsService.MulticastPerNodeArg:input_type -> dev.Request + 0, // 11: dev.ZorumsService.Multicast2:input_type -> dev.Request + 0, // 12: dev.ZorumsService.Multicast3:input_type -> dev.Request + 3, // 13: dev.ZorumsService.Multicast4:input_type -> google.protobuf.Empty + 0, // 14: dev.ZorumsService.Unicast:input_type -> dev.Request + 0, // 15: dev.ZorumsService.Unicast2:input_type -> dev.Request + 1, // 16: dev.ZorumsService.GRPCCall:output_type -> dev.Response + 1, // 17: dev.ZorumsService.QuorumCall:output_type -> dev.Response + 1, // 18: dev.ZorumsService.QuorumCallPerNodeArg:output_type -> dev.Response + 1, // 19: dev.ZorumsService.QuorumCallEmpty:output_type -> dev.Response + 3, // 20: dev.ZorumsService.QuorumCallEmpty2:output_type -> google.protobuf.Empty + 1, // 21: dev.ZorumsService.QuorumCallStream:output_type -> dev.Response + 1, // 22: dev.ZorumsService.QuorumCallStreamPerNodeArg:output_type -> dev.Response + 1, // 23: dev.ZorumsService.QuorumCallStreamEmpty:output_type -> dev.Response + 3, // 24: dev.ZorumsService.QuorumCallStreamEmpty2:output_type -> google.protobuf.Empty + 1, // 25: dev.ZorumsService.Multicast:output_type -> dev.Response + 1, // 26: dev.ZorumsService.MulticastPerNodeArg:output_type -> dev.Response + 1, // 27: dev.ZorumsService.Multicast2:output_type -> dev.Response + 3, // 28: dev.ZorumsService.Multicast3:output_type -> google.protobuf.Empty + 3, // 29: dev.ZorumsService.Multicast4:output_type -> google.protobuf.Empty + 1, // 30: dev.ZorumsService.Unicast:output_type -> dev.Response + 3, // 31: dev.ZorumsService.Unicast2:output_type -> google.protobuf.Empty + 16, // [16:32] is the sub-list for method output_type + 0, // [0:16] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name diff --git a/cmd/protoc-gen-gorums/dev/zorums.proto b/cmd/protoc-gen-gorums/dev/zorums.proto index b0019447f..59ffdca48 100644 --- a/cmd/protoc-gen-gorums/dev/zorums.proto +++ b/cmd/protoc-gen-gorums/dev/zorums.proto @@ -45,17 +45,6 @@ service ZorumsService { option (gorums.quorumcall) = true; option (gorums.per_node_arg) = true; } - // QuorumCall with custom_return_type option. - rpc QuorumCallCustomReturnType(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // QuorumCallCombo with all supported options. - rpc QuorumCallCombo(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.per_node_arg) = true; - option (gorums.custom_return_type) = "MyResponse"; - } // QuorumCallEmpty for testing imported message type. rpc QuorumCallEmpty(google.protobuf.Empty) returns (Response) { option (gorums.quorumcall) = true; @@ -65,6 +54,28 @@ service ZorumsService { option (gorums.quorumcall) = true; } + // --------------------------------------------------------------- + // QuorumCall stream variants + // --------------------------------------------------------------- + + // QuorumCall plain. + rpc QuorumCallStream(Request) returns (stream Response) { + option (gorums.quorumcall) = true; + } + // QuorumCall with per_node_arg option. + rpc QuorumCallStreamPerNodeArg(Request) returns (stream Response) { + option (gorums.quorumcall) = true; + option (gorums.per_node_arg) = true; + } + // QuorumCallEmpty for testing imported message type. + rpc QuorumCallStreamEmpty(google.protobuf.Empty) returns (stream Response) { + option (gorums.quorumcall) = true; + } + // QuorumCallEmpty2 for testing imported message type. + rpc QuorumCallStreamEmpty2(Request) returns (stream google.protobuf.Empty) { + option (gorums.quorumcall) = true; + } + // ------------------------------------------------------------------ // Multicast variants // The multicast call type does not support the 'custom_return_type' @@ -94,119 +105,6 @@ service ZorumsService { option (gorums.multicast) = true; } - // --------------------------------------------------------------- - // Async variants - // --------------------------------------------------------------- - - // QuorumCallAsync plain. - rpc QuorumCallAsync(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } - // QuorumCallAsyncPerNodeArg with per_node_arg option. - rpc QuorumCallAsyncPerNodeArg(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - option (gorums.per_node_arg) = true; - } - // QuorumCallAsyncCustomReturnType with custom_return_type option. - rpc QuorumCallAsyncCustomReturnType(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // QuorumCallAsyncCombo with all supported options. - rpc QuorumCallAsyncCombo(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - option (gorums.per_node_arg) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // QuorumCallAsync2 plain; with same return type: Response. - rpc QuorumCallAsync2(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } - // QuorumCallAsyncEmpty for testing imported message type. - rpc QuorumCallAsyncEmpty(Request) returns (google.protobuf.Empty) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } - // QuorumCallAsyncEmpty2 for testing imported message type; with same return - // type as QuorumCallAsync: Response. - rpc QuorumCallAsyncEmpty2(google.protobuf.Empty) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } - - // --------------------------------------------------------------- - // Correctable variants - // --------------------------------------------------------------- - - // Correctable plain. - rpc Correctable(Request) returns (Response) { - option (gorums.correctable) = true; - } - // CorrectablePerNodeArg with per_node_arg option. - rpc CorrectablePerNodeArg(Request) returns (Response) { - option (gorums.correctable) = true; - option (gorums.per_node_arg) = true; - } - // CorrectableCustomReturnType with custom_return_type option. - rpc CorrectableCustomReturnType(Request) returns (Response) { - option (gorums.correctable) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // CorrectableCombo with all supported options. - rpc CorrectableCombo(Request) returns (Response) { - option (gorums.correctable) = true; - option (gorums.per_node_arg) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // CorrectableEmpty for testing imported message type. - rpc CorrectableEmpty(Request) returns (google.protobuf.Empty) { - option (gorums.correctable) = true; - } - // CorrectableEmpty2 for testing imported message type; with same return - // type as Correctable: Response. - rpc CorrectableEmpty2(google.protobuf.Empty) returns (Response) { - option (gorums.correctable) = true; - } - - // --------------------------------------------------------------- - // CorrectableStream variants - // --------------------------------------------------------------- - - // CorrectableStream plain. - rpc CorrectableStream(Request) returns (stream Response) { - option (gorums.correctable) = true; - } - // CorrectablePerNodeArg with per_node_arg option. - rpc CorrectableStreamPerNodeArg(Request) returns (stream Response) { - option (gorums.correctable) = true; - option (gorums.per_node_arg) = true; - } - // CorrectableCustomReturnType with custom_return_type option. - rpc CorrectableStreamCustomReturnType(Request) returns (stream Response) { - option (gorums.correctable) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // CorrectableCombo with all supported options. - rpc CorrectableStreamCombo(Request) returns (stream Response) { - option (gorums.correctable) = true; - option (gorums.per_node_arg) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // CorrectableEmpty for testing imported message type. - rpc CorrectableStreamEmpty(Request) returns (stream google.protobuf.Empty) { - option (gorums.correctable) = true; - } - // CorrectableEmpty2 for testing imported message type; with same return - // type as Correctable: Response. - rpc CorrectableStreamEmpty2(google.protobuf.Empty) returns (stream Response) { - option (gorums.correctable) = true; - } - // --------------------------------------------------------------- // Unicast // --------------------------------------------------------------- diff --git a/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go deleted file mode 100644 index 9d3b267d1..000000000 --- a/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by protoc-gen-gorums. DO NOT EDIT. -// versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 -// source: zorums.proto - -package dev - -import ( - context "context" - gorums "github.com/relab/gorums" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - emptypb "google.golang.org/protobuf/types/known/emptypb" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = gorums.EnforceVersion(9 - gorums.MinVersion) - // Verify that the gorums runtime is sufficiently up-to-date. - _ = gorums.EnforceVersion(gorums.MaxVersion - 9) -) - -// QuorumCallAsync plain. -func (c *Configuration) QuorumCallAsync(ctx context.Context, in *Request) *AsyncResponse { - cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallAsync", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallAsyncQF(req.(*Request), r) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncResponse{fut} -} - -// QuorumCallAsyncPerNodeArg with per_node_arg option. -func (c *Configuration) QuorumCallAsyncPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *AsyncResponse { - cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallAsyncPerNodeArg", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallAsyncPerNodeArgQF(req.(*Request), r) - } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { - return f(req.(*Request), nid) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncResponse{fut} -} - -// QuorumCallAsyncCustomReturnType with custom_return_type option. -func (c *Configuration) QuorumCallAsyncCustomReturnType(ctx context.Context, in *Request) *AsyncMyResponse { - cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallAsyncCustomReturnType", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallAsyncCustomReturnTypeQF(req.(*Request), r) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncMyResponse{fut} -} - -// QuorumCallAsyncCombo with all supported options. -func (c *Configuration) QuorumCallAsyncCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *AsyncMyResponse { - cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallAsyncCombo", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallAsyncComboQF(req.(*Request), r) - } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { - return f(req.(*Request), nid) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncMyResponse{fut} -} - -// QuorumCallAsync2 plain; with same return type: Response. -func (c *Configuration) QuorumCallAsync2(ctx context.Context, in *Request) *AsyncResponse { - cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallAsync2", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallAsync2QF(req.(*Request), r) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncResponse{fut} -} - -// QuorumCallAsyncEmpty for testing imported message type. -func (c *Configuration) QuorumCallAsyncEmpty(ctx context.Context, in *Request) *AsyncEmpty { - cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallAsyncEmpty", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*emptypb.Empty, len(replies)) - for k, v := range replies { - r[k] = v.(*emptypb.Empty) - } - return c.qspec.QuorumCallAsyncEmptyQF(req.(*Request), r) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncEmpty{fut} -} - -// QuorumCallAsyncEmpty2 for testing imported message type; with same return -// type as QuorumCallAsync: Response. -func (c *Configuration) QuorumCallAsyncEmpty2(ctx context.Context, in *emptypb.Empty) *AsyncResponse { - cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallAsyncEmpty2", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QuorumCallAsyncEmpty2QF(req.(*emptypb.Empty), r) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncResponse{fut} -} diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index 9bfb61546..b22b715df 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: zorums.proto package dev @@ -10,7 +10,6 @@ import ( context "context" gorums "github.com/relab/gorums" emptypb "google.golang.org/protobuf/types/known/emptypb" - iter "iter" ) const ( @@ -22,36 +21,26 @@ const ( // ZorumsServiceClient is the client interface for the ZorumsService service. type ZorumsServiceClient interface { - QuorumCall(ctx context.Context, in *Request) iter.Seq2[*Response, error] - QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) iter.Seq2[*Response, error] - QuorumCallCustomReturnType(ctx context.Context, in *Request) iter.Seq2[*MyResponse, error] - QuorumCallCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) iter.Seq2[*MyResponse, error] - QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) iter.Seq2[*Response, error] - QuorumCallEmpty2(ctx context.Context, in *Request) iter.Seq2[*emptypb.Empty, error] + QuorumCall(ctx context.Context, in *Request) gorums.Iterator[*Response] + + QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] + + QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] + + QuorumCallEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] + + QuorumCallStream(ctx context.Context, in *Request) gorums.Iterator[*Response] + + QuorumCallStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] + + QuorumCallStreamEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] + + QuorumCallStreamEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) MulticastPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) Multicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) Multicast3(ctx context.Context, in *Request, opts ...gorums.CallOption) Multicast4(ctx context.Context, in *emptypb.Empty, opts ...gorums.CallOption) - QuorumCallAsync(ctx context.Context, in *Request) *AsyncResponse - QuorumCallAsyncPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *AsyncResponse - QuorumCallAsyncCustomReturnType(ctx context.Context, in *Request) *AsyncMyResponse - QuorumCallAsyncCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *AsyncMyResponse - QuorumCallAsync2(ctx context.Context, in *Request) *AsyncResponse - QuorumCallAsyncEmpty(ctx context.Context, in *Request) *AsyncEmpty - QuorumCallAsyncEmpty2(ctx context.Context, in *emptypb.Empty) *AsyncResponse - Correctable(ctx context.Context, in *Request) *CorrectableResponse - CorrectablePerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableResponse - CorrectableCustomReturnType(ctx context.Context, in *Request) *CorrectableMyResponse - CorrectableCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableMyResponse - CorrectableEmpty(ctx context.Context, in *Request) *CorrectableEmpty - CorrectableEmpty2(ctx context.Context, in *emptypb.Empty) *CorrectableResponse - CorrectableStream(ctx context.Context, in *Request) *CorrectableStreamResponse - CorrectableStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableStreamResponse - CorrectableStreamCustomReturnType(ctx context.Context, in *Request) *CorrectableStreamMyResponse - CorrectableStreamCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableStreamMyResponse - CorrectableStreamEmpty(ctx context.Context, in *Request) *CorrectableStreamEmpty - CorrectableStreamEmpty2(ctx context.Context, in *emptypb.Empty) *CorrectableStreamResponse } // enforce interface compliance diff --git a/cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go deleted file mode 100644 index 4be8d5b57..000000000 --- a/cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go +++ /dev/null @@ -1,263 +0,0 @@ -// Code generated by protoc-gen-gorums. DO NOT EDIT. -// versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 -// source: zorums.proto - -package dev - -import ( - context "context" - gorums "github.com/relab/gorums" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - emptypb "google.golang.org/protobuf/types/known/emptypb" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = gorums.EnforceVersion(9 - gorums.MinVersion) - // Verify that the gorums runtime is sufficiently up-to-date. - _ = gorums.EnforceVersion(gorums.MaxVersion - 9) -) - -// Correctable plain. -func (c *Configuration) Correctable(ctx context.Context, in *Request) *CorrectableResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.Correctable", - ServerStream: false, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableQF(req.(*Request), r) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableResponse{corr} -} - -// CorrectablePerNodeArg with per_node_arg option. -func (c *Configuration) CorrectablePerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectablePerNodeArg", - ServerStream: false, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectablePerNodeArgQF(req.(*Request), r) - } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { - return f(req.(*Request), nid) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableResponse{corr} -} - -// CorrectableCustomReturnType with custom_return_type option. -func (c *Configuration) CorrectableCustomReturnType(ctx context.Context, in *Request) *CorrectableMyResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableCustomReturnType", - ServerStream: false, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableCustomReturnTypeQF(req.(*Request), r) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableMyResponse{corr} -} - -// CorrectableCombo with all supported options. -func (c *Configuration) CorrectableCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableMyResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableCombo", - ServerStream: false, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableComboQF(req.(*Request), r) - } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { - return f(req.(*Request), nid) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableMyResponse{corr} -} - -// CorrectableEmpty for testing imported message type. -func (c *Configuration) CorrectableEmpty(ctx context.Context, in *Request) *CorrectableEmpty { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableEmpty", - ServerStream: false, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*emptypb.Empty, len(replies)) - for k, v := range replies { - r[k] = v.(*emptypb.Empty) - } - return c.qspec.CorrectableEmptyQF(req.(*Request), r) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableEmpty{corr} -} - -// CorrectableEmpty2 for testing imported message type; with same return -// type as Correctable: Response. -func (c *Configuration) CorrectableEmpty2(ctx context.Context, in *emptypb.Empty) *CorrectableResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableEmpty2", - ServerStream: false, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableEmpty2QF(req.(*emptypb.Empty), r) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableResponse{corr} -} - -// CorrectableStream plain. -func (c *Configuration) CorrectableStream(ctx context.Context, in *Request) *CorrectableStreamResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableStream", - ServerStream: true, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableStreamQF(req.(*Request), r) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableStreamResponse{corr} -} - -// CorrectablePerNodeArg with per_node_arg option. -func (c *Configuration) CorrectableStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableStreamResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableStreamPerNodeArg", - ServerStream: true, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableStreamPerNodeArgQF(req.(*Request), r) - } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { - return f(req.(*Request), nid) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableStreamResponse{corr} -} - -// CorrectableCustomReturnType with custom_return_type option. -func (c *Configuration) CorrectableStreamCustomReturnType(ctx context.Context, in *Request) *CorrectableStreamMyResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableStreamCustomReturnType", - ServerStream: true, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableStreamCustomReturnTypeQF(req.(*Request), r) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableStreamMyResponse{corr} -} - -// CorrectableCombo with all supported options. -func (c *Configuration) CorrectableStreamCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableStreamMyResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableStreamCombo", - ServerStream: true, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableStreamComboQF(req.(*Request), r) - } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { - return f(req.(*Request), nid) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableStreamMyResponse{corr} -} - -// CorrectableEmpty for testing imported message type. -func (c *Configuration) CorrectableStreamEmpty(ctx context.Context, in *Request) *CorrectableStreamEmpty { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableStreamEmpty", - ServerStream: true, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*emptypb.Empty, len(replies)) - for k, v := range replies { - r[k] = v.(*emptypb.Empty) - } - return c.qspec.CorrectableStreamEmptyQF(req.(*Request), r) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableStreamEmpty{corr} -} - -// CorrectableEmpty2 for testing imported message type; with same return -// type as Correctable: Response. -func (c *Configuration) CorrectableStreamEmpty2(ctx context.Context, in *emptypb.Empty) *CorrectableStreamResponse { - cd := gorums.CorrectableCallData{ - Message: in, - Method: "dev.ZorumsService.CorrectableStreamEmpty2", - ServerStream: true, - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.CorrectableStreamEmpty2QF(req.(*emptypb.Empty), r) - } - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableStreamResponse{corr} -} diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index b5c5ba474..00068a9af 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: zorums.proto package dev @@ -9,7 +9,7 @@ package dev import ( context "context" gorums "github.com/relab/gorums" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" + proto "google.golang.org/protobuf/proto" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -37,7 +37,7 @@ func (c *Configuration) MulticastPerNodeArg(ctx context.Context, in *Request, f Method: "dev.ZorumsService.MulticastPerNodeArg", } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { + cd.PerNodeArgFn = func(req proto.Message, nid uint32) proto.Message { return f(req.(*Request), nid) } diff --git a/cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go deleted file mode 100644 index 6d028d34a..000000000 --- a/cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go +++ /dev/null @@ -1,199 +0,0 @@ -// Code generated by protoc-gen-gorums. DO NOT EDIT. -// versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 -// source: zorums.proto - -package dev - -import ( - gorums "github.com/relab/gorums" - emptypb "google.golang.org/protobuf/types/known/emptypb" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = gorums.EnforceVersion(9 - gorums.MinVersion) - // Verify that the gorums runtime is sufficiently up-to-date. - _ = gorums.EnforceVersion(gorums.MaxVersion - 9) -) - -// QuorumSpec is the interface of quorum functions for ZorumsService. -type QuorumSpec interface { - gorums.ConfigOption - - // QuorumCallQF is the quorum function for the QuorumCall - // quorum call method. The in parameter is the request object - // supplied to the QuorumCall method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallQF(in *Request, replies map[uint32]*Response) (*Response, bool) - - // QuorumCallPerNodeArgQF is the quorum function for the QuorumCallPerNodeArg - // quorum call method. The in parameter is the request object - // supplied to the QuorumCallPerNodeArg method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallPerNodeArgQF(in *Request, replies map[uint32]*Response) (*Response, bool) - - // QuorumCallCustomReturnTypeQF is the quorum function for the QuorumCallCustomReturnType - // quorum call method. The in parameter is the request object - // supplied to the QuorumCallCustomReturnType method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallCustomReturnTypeQF(in *Request, replies map[uint32]*Response) (*MyResponse, bool) - - // QuorumCallComboQF is the quorum function for the QuorumCallCombo - // quorum call method. The in parameter is the request object - // supplied to the QuorumCallCombo method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallComboQF(in *Request, replies map[uint32]*Response) (*MyResponse, bool) - - // QuorumCallEmptyQF is the quorum function for the QuorumCallEmpty - // quorum call method. The in parameter is the request object - // supplied to the QuorumCallEmpty method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *emptypb.Empty'. - QuorumCallEmptyQF(in *emptypb.Empty, replies map[uint32]*Response) (*Response, bool) - - // QuorumCallEmpty2QF is the quorum function for the QuorumCallEmpty2 - // quorum call method. The in parameter is the request object - // supplied to the QuorumCallEmpty2 method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallEmpty2QF(in *Request, replies map[uint32]*emptypb.Empty) (*emptypb.Empty, bool) - - // QuorumCallAsyncQF is the quorum function for the QuorumCallAsync - // asynchronous quorum call method. The in parameter is the request object - // supplied to the QuorumCallAsync method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallAsyncQF(in *Request, replies map[uint32]*Response) (*Response, bool) - - // QuorumCallAsyncPerNodeArgQF is the quorum function for the QuorumCallAsyncPerNodeArg - // asynchronous quorum call method. The in parameter is the request object - // supplied to the QuorumCallAsyncPerNodeArg method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallAsyncPerNodeArgQF(in *Request, replies map[uint32]*Response) (*Response, bool) - - // QuorumCallAsyncCustomReturnTypeQF is the quorum function for the QuorumCallAsyncCustomReturnType - // asynchronous quorum call method. The in parameter is the request object - // supplied to the QuorumCallAsyncCustomReturnType method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallAsyncCustomReturnTypeQF(in *Request, replies map[uint32]*Response) (*MyResponse, bool) - - // QuorumCallAsyncComboQF is the quorum function for the QuorumCallAsyncCombo - // asynchronous quorum call method. The in parameter is the request object - // supplied to the QuorumCallAsyncCombo method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallAsyncComboQF(in *Request, replies map[uint32]*Response) (*MyResponse, bool) - - // QuorumCallAsync2QF is the quorum function for the QuorumCallAsync2 - // asynchronous quorum call method. The in parameter is the request object - // supplied to the QuorumCallAsync2 method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallAsync2QF(in *Request, replies map[uint32]*Response) (*Response, bool) - - // QuorumCallAsyncEmptyQF is the quorum function for the QuorumCallAsyncEmpty - // asynchronous quorum call method. The in parameter is the request object - // supplied to the QuorumCallAsyncEmpty method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QuorumCallAsyncEmptyQF(in *Request, replies map[uint32]*emptypb.Empty) (*emptypb.Empty, bool) - - // QuorumCallAsyncEmpty2QF is the quorum function for the QuorumCallAsyncEmpty2 - // asynchronous quorum call method. The in parameter is the request object - // supplied to the QuorumCallAsyncEmpty2 method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *emptypb.Empty'. - QuorumCallAsyncEmpty2QF(in *emptypb.Empty, replies map[uint32]*Response) (*Response, bool) - - // CorrectableQF is the quorum function for the Correctable - // correctable quorum call method. The in parameter is the request object - // supplied to the Correctable method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableQF(in *Request, replies map[uint32]*Response) (*Response, int, bool) - - // CorrectablePerNodeArgQF is the quorum function for the CorrectablePerNodeArg - // correctable quorum call method. The in parameter is the request object - // supplied to the CorrectablePerNodeArg method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectablePerNodeArgQF(in *Request, replies map[uint32]*Response) (*Response, int, bool) - - // CorrectableCustomReturnTypeQF is the quorum function for the CorrectableCustomReturnType - // correctable quorum call method. The in parameter is the request object - // supplied to the CorrectableCustomReturnType method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableCustomReturnTypeQF(in *Request, replies map[uint32]*Response) (*MyResponse, int, bool) - - // CorrectableComboQF is the quorum function for the CorrectableCombo - // correctable quorum call method. The in parameter is the request object - // supplied to the CorrectableCombo method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableComboQF(in *Request, replies map[uint32]*Response) (*MyResponse, int, bool) - - // CorrectableEmptyQF is the quorum function for the CorrectableEmpty - // correctable quorum call method. The in parameter is the request object - // supplied to the CorrectableEmpty method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableEmptyQF(in *Request, replies map[uint32]*emptypb.Empty) (*emptypb.Empty, int, bool) - - // CorrectableEmpty2QF is the quorum function for the CorrectableEmpty2 - // correctable quorum call method. The in parameter is the request object - // supplied to the CorrectableEmpty2 method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *emptypb.Empty'. - CorrectableEmpty2QF(in *emptypb.Empty, replies map[uint32]*Response) (*Response, int, bool) - - // CorrectableStreamQF is the quorum function for the CorrectableStream - // correctable stream quorum call method. The in parameter is the request object - // supplied to the CorrectableStream method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableStreamQF(in *Request, replies map[uint32]*Response) (*Response, int, bool) - - // CorrectableStreamPerNodeArgQF is the quorum function for the CorrectableStreamPerNodeArg - // correctable stream quorum call method. The in parameter is the request object - // supplied to the CorrectableStreamPerNodeArg method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableStreamPerNodeArgQF(in *Request, replies map[uint32]*Response) (*Response, int, bool) - - // CorrectableStreamCustomReturnTypeQF is the quorum function for the CorrectableStreamCustomReturnType - // correctable stream quorum call method. The in parameter is the request object - // supplied to the CorrectableStreamCustomReturnType method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableStreamCustomReturnTypeQF(in *Request, replies map[uint32]*Response) (*MyResponse, int, bool) - - // CorrectableStreamComboQF is the quorum function for the CorrectableStreamCombo - // correctable stream quorum call method. The in parameter is the request object - // supplied to the CorrectableStreamCombo method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableStreamComboQF(in *Request, replies map[uint32]*Response) (*MyResponse, int, bool) - - // CorrectableStreamEmptyQF is the quorum function for the CorrectableStreamEmpty - // correctable stream quorum call method. The in parameter is the request object - // supplied to the CorrectableStreamEmpty method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - CorrectableStreamEmptyQF(in *Request, replies map[uint32]*emptypb.Empty) (*emptypb.Empty, int, bool) - - // CorrectableStreamEmpty2QF is the quorum function for the CorrectableStreamEmpty2 - // correctable stream quorum call method. The in parameter is the request object - // supplied to the CorrectableStreamEmpty2 method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *emptypb.Empty'. - CorrectableStreamEmpty2QF(in *emptypb.Empty, replies map[uint32]*Response) (*Response, int, bool) -} diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index c6e7f7fe5..be49475f3 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: zorums.proto package dev @@ -9,9 +9,8 @@ package dev import ( context "context" gorums "github.com/relab/gorums" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" + proto "google.golang.org/protobuf/proto" emptypb "google.golang.org/protobuf/types/known/emptypb" - iter "iter" ) const ( @@ -22,66 +21,94 @@ const ( ) // QuorumCall plain. -func (c *Configuration) QuorumCall(ctx context.Context, in *Request) iter.Seq2[*Response, error] { +func (c *Configuration) QuorumCall(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCall", + Message: in, + Method: "dev.ZorumsService.QuorumCall", + ServerStream: false, } return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // QuorumCall with per_node_arg option. -func (c *Configuration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) iter.Seq2[*Response, error] { +func (c *Configuration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallPerNodeArg", + Message: in, + Method: "dev.ZorumsService.QuorumCallPerNodeArg", + ServerStream: false, } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { + cd.PerNodeArgFn = func(req proto.Message, nid uint32) proto.Message { return f(req.(*Request), nid) } return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } -// QuorumCall with custom_return_type option. -func (c *Configuration) QuorumCallCustomReturnType(ctx context.Context, in *Request) iter.Seq2[*MyResponse, error] { +// QuorumCallEmpty for testing imported message type. +func (c *Configuration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] { + cd := gorums.QuorumCallData{ + Message: in, + Method: "dev.ZorumsService.QuorumCallEmpty", + ServerStream: false, + } + + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) +} + +// QuorumCallEmpty2 for testing imported message type. +func (c *Configuration) QuorumCallEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] { + cd := gorums.QuorumCallData{ + Message: in, + Method: "dev.ZorumsService.QuorumCallEmpty2", + ServerStream: false, + } + + return gorums.QuorumCall[*emptypb.Empty](ctx, c.RawConfiguration, cd) +} + +// QuorumCall plain. +func (c *Configuration) QuorumCallStream(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallCustomReturnType", + Message: in, + Method: "dev.ZorumsService.QuorumCallStream", + ServerStream: true, } - return gorums.QuorumCall[*MyResponse](ctx, c.RawConfiguration, cd) + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } -// QuorumCallCombo with all supported options. -func (c *Configuration) QuorumCallCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) iter.Seq2[*MyResponse, error] { +// QuorumCall with per_node_arg option. +func (c *Configuration) QuorumCallStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallCombo", + Message: in, + Method: "dev.ZorumsService.QuorumCallStreamPerNodeArg", + ServerStream: true, } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { + cd.PerNodeArgFn = func(req proto.Message, nid uint32) proto.Message { return f(req.(*Request), nid) } - return gorums.QuorumCall[*MyResponse](ctx, c.RawConfiguration, cd) + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // QuorumCallEmpty for testing imported message type. -func (c *Configuration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) iter.Seq2[*Response, error] { +func (c *Configuration) QuorumCallStreamEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallEmpty", + Message: in, + Method: "dev.ZorumsService.QuorumCallStreamEmpty", + ServerStream: true, } return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // QuorumCallEmpty2 for testing imported message type. -func (c *Configuration) QuorumCallEmpty2(ctx context.Context, in *Request) iter.Seq2[*emptypb.Empty, error] { +func (c *Configuration) QuorumCallStreamEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] { cd := gorums.QuorumCallData{ - Message: in, - Method: "dev.ZorumsService.QuorumCallEmpty2", + Message: in, + Method: "dev.ZorumsService.QuorumCallStreamEmpty2", + ServerStream: true, } return gorums.QuorumCall[*emptypb.Empty](ctx, c.RawConfiguration, cd) diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index f077df916..d7a7944ae 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index e37076a6b..81cec0653 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: zorums.proto package dev @@ -25,34 +25,17 @@ type ZorumsServiceServer interface { GRPCCall(ctx gorums.ServerCtx, request *Request) (response *Response, err error) QuorumCall(ctx gorums.ServerCtx, request *Request) (response *Response, err error) QuorumCallPerNodeArg(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - QuorumCallCustomReturnType(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - QuorumCallCombo(ctx gorums.ServerCtx, request *Request) (response *Response, err error) QuorumCallEmpty(ctx gorums.ServerCtx, request *emptypb.Empty) (response *Response, err error) QuorumCallEmpty2(ctx gorums.ServerCtx, request *Request) (response *emptypb.Empty, err error) + QuorumCallStream(ctx gorums.ServerCtx, request *Request, send func(response *Response) error) error + QuorumCallStreamPerNodeArg(ctx gorums.ServerCtx, request *Request, send func(response *Response) error) error + QuorumCallStreamEmpty(ctx gorums.ServerCtx, request *emptypb.Empty, send func(response *Response) error) error + QuorumCallStreamEmpty2(ctx gorums.ServerCtx, request *Request, send func(response *emptypb.Empty) error) error Multicast(ctx gorums.ServerCtx, request *Request) MulticastPerNodeArg(ctx gorums.ServerCtx, request *Request) Multicast2(ctx gorums.ServerCtx, request *Request) Multicast3(ctx gorums.ServerCtx, request *Request) Multicast4(ctx gorums.ServerCtx, request *emptypb.Empty) - QuorumCallAsync(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - QuorumCallAsyncPerNodeArg(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - QuorumCallAsyncCustomReturnType(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - QuorumCallAsyncCombo(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - QuorumCallAsync2(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - QuorumCallAsyncEmpty(ctx gorums.ServerCtx, request *Request) (response *emptypb.Empty, err error) - QuorumCallAsyncEmpty2(ctx gorums.ServerCtx, request *emptypb.Empty) (response *Response, err error) - Correctable(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - CorrectablePerNodeArg(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - CorrectableCustomReturnType(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - CorrectableCombo(ctx gorums.ServerCtx, request *Request) (response *Response, err error) - CorrectableEmpty(ctx gorums.ServerCtx, request *Request) (response *emptypb.Empty, err error) - CorrectableEmpty2(ctx gorums.ServerCtx, request *emptypb.Empty) (response *Response, err error) - CorrectableStream(ctx gorums.ServerCtx, request *Request, send func(response *Response) error) error - CorrectableStreamPerNodeArg(ctx gorums.ServerCtx, request *Request, send func(response *Response) error) error - CorrectableStreamCustomReturnType(ctx gorums.ServerCtx, request *Request, send func(response *Response) error) error - CorrectableStreamCombo(ctx gorums.ServerCtx, request *Request, send func(response *Response) error) error - CorrectableStreamEmpty(ctx gorums.ServerCtx, request *Request, send func(response *emptypb.Empty) error) error - CorrectableStreamEmpty2(ctx gorums.ServerCtx, request *emptypb.Empty, send func(response *Response) error) error Unicast(ctx gorums.ServerCtx, request *Request) Unicast2(ctx gorums.ServerCtx, request *Request) } @@ -76,18 +59,6 @@ func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { resp, err := impl.QuorumCallPerNodeArg(ctx, req) gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallCustomReturnType", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.QuorumCallCustomReturnType(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallCombo", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.QuorumCallCombo(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) srv.RegisterHandler("dev.ZorumsService.QuorumCallEmpty", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*emptypb.Empty) defer ctx.Release() @@ -100,113 +71,10 @@ func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { resp, err := impl.QuorumCallEmpty2(ctx, req) gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) }) - srv.RegisterHandler("dev.ZorumsService.Multicast", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - impl.Multicast(ctx, req) - }) - srv.RegisterHandler("dev.ZorumsService.MulticastPerNodeArg", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - impl.MulticastPerNodeArg(ctx, req) - }) - srv.RegisterHandler("dev.ZorumsService.Multicast2", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - impl.Multicast2(ctx, req) - }) - srv.RegisterHandler("dev.ZorumsService.Multicast3", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - impl.Multicast3(ctx, req) - }) - srv.RegisterHandler("dev.ZorumsService.Multicast4", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { - req := in.Message.(*emptypb.Empty) - defer ctx.Release() - impl.Multicast4(ctx, req) - }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallAsync", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.QuorumCallAsync(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallAsyncPerNodeArg", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.QuorumCallAsyncPerNodeArg(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallAsyncCustomReturnType", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.QuorumCallAsyncCustomReturnType(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallAsyncCombo", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.QuorumCallAsyncCombo(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallAsync2", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.QuorumCallAsync2(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallAsyncEmpty", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.QuorumCallAsyncEmpty(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.QuorumCallAsyncEmpty2", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*emptypb.Empty) - defer ctx.Release() - resp, err := impl.QuorumCallAsyncEmpty2(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.Correctable", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.Correctable(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.CorrectablePerNodeArg", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.CorrectablePerNodeArg(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.CorrectableCustomReturnType", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.CorrectableCustomReturnType(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.CorrectableCombo", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.CorrectableCombo(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.CorrectableEmpty", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + srv.RegisterHandler("dev.ZorumsService.QuorumCallStream", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) defer ctx.Release() - resp, err := impl.CorrectableEmpty(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.CorrectableEmpty2", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*emptypb.Empty) - defer ctx.Release() - resp, err := impl.CorrectableEmpty2(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("dev.ZorumsService.CorrectableStream", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - err := impl.CorrectableStream(ctx, req, func(resp *Response) error { + err := impl.QuorumCallStream(ctx, req, func(resp *Response) error { // create a copy of the metadata, to avoid a data race between WrapMessage and SendMsg md := proto.Clone(in.Metadata) return gorums.SendMessage(ctx, finished, gorums.WrapMessage(md.(*ordering.Metadata), resp, nil)) @@ -215,10 +83,10 @@ func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, nil, err)) } }) - srv.RegisterHandler("dev.ZorumsService.CorrectableStreamPerNodeArg", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + srv.RegisterHandler("dev.ZorumsService.QuorumCallStreamPerNodeArg", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) defer ctx.Release() - err := impl.CorrectableStreamPerNodeArg(ctx, req, func(resp *Response) error { + err := impl.QuorumCallStreamPerNodeArg(ctx, req, func(resp *Response) error { // create a copy of the metadata, to avoid a data race between WrapMessage and SendMsg md := proto.Clone(in.Metadata) return gorums.SendMessage(ctx, finished, gorums.WrapMessage(md.(*ordering.Metadata), resp, nil)) @@ -227,10 +95,10 @@ func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, nil, err)) } }) - srv.RegisterHandler("dev.ZorumsService.CorrectableStreamCustomReturnType", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) + srv.RegisterHandler("dev.ZorumsService.QuorumCallStreamEmpty", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*emptypb.Empty) defer ctx.Release() - err := impl.CorrectableStreamCustomReturnType(ctx, req, func(resp *Response) error { + err := impl.QuorumCallStreamEmpty(ctx, req, func(resp *Response) error { // create a copy of the metadata, to avoid a data race between WrapMessage and SendMsg md := proto.Clone(in.Metadata) return gorums.SendMessage(ctx, finished, gorums.WrapMessage(md.(*ordering.Metadata), resp, nil)) @@ -239,10 +107,10 @@ func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, nil, err)) } }) - srv.RegisterHandler("dev.ZorumsService.CorrectableStreamCombo", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + srv.RegisterHandler("dev.ZorumsService.QuorumCallStreamEmpty2", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) defer ctx.Release() - err := impl.CorrectableStreamCombo(ctx, req, func(resp *Response) error { + err := impl.QuorumCallStreamEmpty2(ctx, req, func(resp *emptypb.Empty) error { // create a copy of the metadata, to avoid a data race between WrapMessage and SendMsg md := proto.Clone(in.Metadata) return gorums.SendMessage(ctx, finished, gorums.WrapMessage(md.(*ordering.Metadata), resp, nil)) @@ -251,29 +119,30 @@ func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, nil, err)) } }) - srv.RegisterHandler("dev.ZorumsService.CorrectableStreamEmpty", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + srv.RegisterHandler("dev.ZorumsService.Multicast", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { req := in.Message.(*Request) defer ctx.Release() - err := impl.CorrectableStreamEmpty(ctx, req, func(resp *emptypb.Empty) error { - // create a copy of the metadata, to avoid a data race between WrapMessage and SendMsg - md := proto.Clone(in.Metadata) - return gorums.SendMessage(ctx, finished, gorums.WrapMessage(md.(*ordering.Metadata), resp, nil)) - }) - if err != nil { - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, nil, err)) - } + impl.Multicast(ctx, req) + }) + srv.RegisterHandler("dev.ZorumsService.MulticastPerNodeArg", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { + req := in.Message.(*Request) + defer ctx.Release() + impl.MulticastPerNodeArg(ctx, req) + }) + srv.RegisterHandler("dev.ZorumsService.Multicast2", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { + req := in.Message.(*Request) + defer ctx.Release() + impl.Multicast2(ctx, req) + }) + srv.RegisterHandler("dev.ZorumsService.Multicast3", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { + req := in.Message.(*Request) + defer ctx.Release() + impl.Multicast3(ctx, req) }) - srv.RegisterHandler("dev.ZorumsService.CorrectableStreamEmpty2", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + srv.RegisterHandler("dev.ZorumsService.Multicast4", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { req := in.Message.(*emptypb.Empty) defer ctx.Release() - err := impl.CorrectableStreamEmpty2(ctx, req, func(resp *Response) error { - // create a copy of the metadata, to avoid a data race between WrapMessage and SendMsg - md := proto.Clone(in.Metadata) - return gorums.SendMessage(ctx, finished, gorums.WrapMessage(md.(*ordering.Metadata), resp, nil)) - }) - if err != nil { - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, nil, err)) - } + impl.Multicast4(ctx, req) }) srv.RegisterHandler("dev.ZorumsService.Unicast", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { req := in.Message.(*Request) diff --git a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go index 1ee4d28d8..c6b213d78 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: zorums.proto package dev @@ -29,156 +29,3 @@ type internalResponse struct { reply *Response err error } - -// AsyncEmpty is a async object for processing replies. -type AsyncEmpty struct { - *gorums.Async -} - -// Get returns the reply and any error associated with the called method. -// The method blocks until a reply or error is available. -func (f *AsyncEmpty) Get() (*emptypb.Empty, error) { - resp, err := f.Async.Get() - if err != nil { - return nil, err - } - return resp.(*emptypb.Empty), err -} - -// AsyncMyResponse is a async object for processing replies. -type AsyncMyResponse struct { - *gorums.Async -} - -// Get returns the reply and any error associated with the called method. -// The method blocks until a reply or error is available. -func (f *AsyncMyResponse) Get() (*MyResponse, error) { - resp, err := f.Async.Get() - if err != nil { - return nil, err - } - return resp.(*MyResponse), err -} - -// AsyncResponse is a async object for processing replies. -type AsyncResponse struct { - *gorums.Async -} - -// Get returns the reply and any error associated with the called method. -// The method blocks until a reply or error is available. -func (f *AsyncResponse) Get() (*Response, error) { - resp, err := f.Async.Get() - if err != nil { - return nil, err - } - return resp.(*Response), err -} - -// CorrectableEmpty is a correctable object for processing replies. -type CorrectableEmpty struct { - *gorums.Correctable -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *CorrectableEmpty) Get() (*emptypb.Empty, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*emptypb.Empty), level, err -} - -// CorrectableMyResponse is a correctable object for processing replies. -type CorrectableMyResponse struct { - *gorums.Correctable -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *CorrectableMyResponse) Get() (*MyResponse, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*MyResponse), level, err -} - -// CorrectableResponse is a correctable object for processing replies. -type CorrectableResponse struct { - *gorums.Correctable -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *CorrectableResponse) Get() (*Response, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*Response), level, err -} - -// CorrectableStreamEmpty is a correctable object for processing replies. -type CorrectableStreamEmpty struct { - *gorums.Correctable -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *CorrectableStreamEmpty) Get() (*emptypb.Empty, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*emptypb.Empty), level, err -} - -// CorrectableStreamMyResponse is a correctable object for processing replies. -type CorrectableStreamMyResponse struct { - *gorums.Correctable -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *CorrectableStreamMyResponse) Get() (*MyResponse, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*MyResponse), level, err -} - -// CorrectableStreamResponse is a correctable object for processing replies. -type CorrectableStreamResponse struct { - *gorums.Correctable -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *CorrectableStreamResponse) Get() (*Response, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*Response), level, err -} diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index 25f93e195..052ad8622 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0b7a5ba9 -// protoc v5.29.2 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: zorums.proto package dev @@ -20,7 +20,7 @@ const ( ) // Unicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (n *Node) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, @@ -34,7 +34,7 @@ func (n *Node) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOpti var _ emptypb.Empty // Unicast2 is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (n *Node) Unicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, diff --git a/cmd/protoc-gen-gorums/gengorums/gorums.go b/cmd/protoc-gen-gorums/gengorums/gorums.go index 2c80786e0..4e2929718 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -8,7 +8,6 @@ import ( "strings" "github.com/relab/gorums" - "github.com/relab/gorums/internal/correctable" "github.com/relab/gorums/internal/version" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/proto" @@ -239,7 +238,6 @@ func callTypeName(ext *protoimpl.ExtensionInfo) string { // The entries in this map is used to generate dev/zorums_{type}.pb.go // files for the different keys. var gorumsCallTypesInfo = map[string]*callTypeInfo{ - "qspec": {template: qspecInterface}, "types": {template: dataTypes}, "server": {template: server}, "client": {template: client}, @@ -257,42 +255,7 @@ var gorumsCallTypesInfo = map[string]*callTypeInfo{ docName: "quorum", template: quorumCall, chkFn: func(m *protogen.Method) bool { - return hasMethodOption(m, gorums.E_Quorumcall) && !hasMethodOption(m, gorums.E_Async) - }, - }, - callTypeName(gorums.E_Async): { - extInfo: gorums.E_Async, - docName: "asynchronous quorum", - template: asyncCall, - outPrefix: "Async", - chkFn: func(m *protogen.Method) bool { - return hasAllMethodOption(m, gorums.E_Quorumcall, gorums.E_Async) - }, - }, - callTypeName(gorums.E_Correctable): { - extInfo: gorums.E_Correctable, - chkFn: func(m *protogen.Method) bool { - return hasMethodOption(m, gorums.E_Correctable) - }, - nestedCallType: map[string]*callTypeInfo{ - callTypeName(correctable.E_Correctable): { - extInfo: correctable.E_Correctable, - docName: "correctable quorum", - template: correctableCall, - outPrefix: "Correctable", - chkFn: func(m *protogen.Method) bool { - return hasMethodOption(m, gorums.E_Correctable) && !m.Desc.IsStreamingServer() - }, - }, - callTypeName(correctable.E_CorrectableStream): { - extInfo: correctable.E_CorrectableStream, - docName: "correctable stream quorum", - template: correctableCall, - outPrefix: "CorrectableStream", - chkFn: func(m *protogen.Method) bool { - return hasMethodOption(m, gorums.E_Correctable) && m.Desc.IsStreamingServer() - }, - }, + return hasMethodOption(m, gorums.E_Quorumcall) }, }, callTypeName(gorums.E_Multicast): { @@ -317,8 +280,6 @@ var gorumsCallTypesInfo = map[string]*callTypeInfo{ // These are considered mutually incompatible. var gorumsCallTypes = []*protoimpl.ExtensionInfo{ gorums.E_Quorumcall, - gorums.E_Async, - gorums.E_Correctable, gorums.E_Multicast, gorums.E_Unicast, } @@ -328,15 +289,6 @@ var gorumsCallTypes = []*protoimpl.ExtensionInfo{ // the return type with additional information. var callTypesWithInternal = []*protoimpl.ExtensionInfo{ gorums.E_Quorumcall, - gorums.E_Async, - gorums.E_Correctable, -} - -// callTypesWithPromiseObject lists all call types that returns -// a promise (async or correctable) object. -var callTypesWithPromiseObject = []*protoimpl.ExtensionInfo{ - gorums.E_Async, - gorums.E_Correctable, } // hasGorumsCallType returns true if the given method has specified @@ -375,17 +327,8 @@ func hasAllMethodOption(method *protogen.Method, methodOptions ...*protoimpl.Ext // for the provided method are incompatible. func validateOptions(method *protogen.Method) error { switch { - case hasMethodOption(method, gorums.E_Async) && !hasMethodOption(method, gorums.E_Quorumcall): - return optionErrorf("is required for async methods", method, gorums.E_Quorumcall) - case !hasMethodOption(method, gorums.E_Multicast) && method.Desc.IsStreamingClient(): return optionErrorf("is required for client-server stream methods", method, gorums.E_Multicast) - - case !hasMethodOption(method, gorums.E_Correctable) && method.Desc.IsStreamingServer(): - return optionErrorf("is required for server-client stream methods", method, gorums.E_Correctable) - - case hasMethodOption(method, gorums.E_Correctable) && method.Desc.IsStreamingClient(): - return optionErrorf("is only valid for server-client stream methods", method, gorums.E_Correctable) } return nil } diff --git a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go index e30141241..d34185a26 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go @@ -8,32 +8,29 @@ import ( "github.com/relab/gorums" "google.golang.org/protobuf/compiler/protogen" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/runtime/protoimpl" ) // importMap holds the mapping between short-hand import name // and full import path for the default package. var importMap = map[string]protogen.GoImportPath{ - "io": protogen.GoImportPath("io"), - "time": protogen.GoImportPath("time"), - "fmt": protogen.GoImportPath("fmt"), - "log": protogen.GoImportPath("log"), - "math": protogen.GoImportPath("math"), - "rand": protogen.GoImportPath("math/rand"), - "sync": protogen.GoImportPath("sync"), - "iter": protogen.GoImportPath("iter"), - "atomic": protogen.GoImportPath("sync/atomic"), - "context": protogen.GoImportPath("context"), - "trace": protogen.GoImportPath("golang.org/x/net/trace"), - "grpc": protogen.GoImportPath("google.golang.org/grpc"), - "codes": protogen.GoImportPath("google.golang.org/grpc/codes"), - "status": protogen.GoImportPath("google.golang.org/grpc/status"), - "backoff": protogen.GoImportPath("google.golang.org/grpc/backoff"), - "proto": protogen.GoImportPath("google.golang.org/protobuf/proto"), - "gorums": protogen.GoImportPath("github.com/relab/gorums"), - "ordering": protogen.GoImportPath("github.com/relab/gorums/ordering"), - "protoreflect": protogen.GoImportPath("google.golang.org/protobuf/reflect/protoreflect"), + "io": protogen.GoImportPath("io"), + "time": protogen.GoImportPath("time"), + "fmt": protogen.GoImportPath("fmt"), + "iter": protogen.GoImportPath("iter"), + "log": protogen.GoImportPath("log"), + "math": protogen.GoImportPath("math"), + "rand": protogen.GoImportPath("math/rand"), + "sync": protogen.GoImportPath("sync"), + "atomic": protogen.GoImportPath("sync/atomic"), + "context": protogen.GoImportPath("context"), + "trace": protogen.GoImportPath("golang.org/x/net/trace"), + "grpc": protogen.GoImportPath("google.golang.org/grpc"), + "codes": protogen.GoImportPath("google.golang.org/grpc/codes"), + "status": protogen.GoImportPath("google.golang.org/grpc/status"), + "backoff": protogen.GoImportPath("google.golang.org/grpc/backoff"), + "proto": protogen.GoImportPath("google.golang.org/protobuf/proto"), + "gorums": protogen.GoImportPath("github.com/relab/gorums"), + "ordering": protogen.GoImportPath("github.com/relab/gorums/ordering"), } func addImport(path, ident string, g *protogen.GeneratedFile) string { @@ -77,23 +74,8 @@ var funcMap = template.FuncMap{ } return "" }, - "correctableStream": func(method *protogen.Method) bool { - return hasMethodOption(method, gorums.E_Correctable) && method.Desc.IsStreamingServer() - }, - "isCorrectable": func(method *protogen.Method) bool { - return hasMethodOption(method, gorums.E_Correctable) - }, - "withCorrectable": func(method *protogen.Method, arg string) string { - if hasMethodOption(method, gorums.E_Correctable) { - return arg - } - return "" - }, - "withPromise": func(method *protogen.Method, arg string) string { - if hasMethodOption(method, callTypesWithPromiseObject...) { - return arg - } - return "" + "isStream": func(method *protogen.Method) bool { + return method.Desc.IsStreamingServer() }, "docName": func(method *protogen.Method) string { return callType(method).docName @@ -110,18 +92,10 @@ var funcMap = template.FuncMap{ "isOneway": func(method *protogen.Method) bool { return hasMethodOption(method, gorums.E_Multicast, gorums.E_Unicast) }, - "isAsync": func(method *protogen.Method) bool { - return hasMethodOption(method, gorums.E_Async) - }, "out": out, "outType": outType, "internalOut": internalOut, - "customOut": customOut, "mapInternalOutType": mapInternalOutType, - "mapCorrectableOutType": mapCorrectableOutType, - "mapAsyncOutType": mapAsyncOutType, - "qspecMethods": qspecMethods, - "qspecServices": qspecServices, "unexport": unexport, "contains": strings.Contains, "field": field, @@ -156,20 +130,6 @@ func internalOut(out string) string { return fmt.Sprintf("internal%s", field(out)) } -// customOut returns the output type to be used for the given method. -// This may be the output type specified in the rpc line, -// or if a custom_return_type option is provided for the method, -// this provided custom type will be returned. -func customOut(g *protogen.GeneratedFile, method *protogen.Method) string { - ext := protoimpl.X.MessageOf(method.Desc.Options()).Interface() - customOutType := fmt.Sprintf("%v", proto.GetExtension(ext, gorums.E_CustomReturnType)) - outType := method.Output.GoIdent - if customOutType != "" { - outType.GoName = customOutType - } - return g.QualifiedGoIdent(outType) -} - func mapInternalOutType(g *protogen.GeneratedFile, services []*protogen.Service) (s map[string]string) { return mapType(g, services, func(g *protogen.GeneratedFile, method *protogen.Method, s map[string]string) { if hasMethodOption(method, callTypesWithInternal...) { @@ -180,26 +140,6 @@ func mapInternalOutType(g *protogen.GeneratedFile, services []*protogen.Service) }) } -func mapAsyncOutType(g *protogen.GeneratedFile, services []*protogen.Service) (s map[string]string) { - return mapType(g, services, func(g *protogen.GeneratedFile, method *protogen.Method, s map[string]string) { - if hasAllMethodOption(method, gorums.E_Quorumcall, gorums.E_Async) { - out := customOut(g, method) - futOut := outType(method, out) - s[futOut] = out - } - }) -} - -func mapCorrectableOutType(g *protogen.GeneratedFile, services []*protogen.Service) (s map[string]string) { - return mapType(g, services, func(g *protogen.GeneratedFile, method *protogen.Method, s map[string]string) { - if hasMethodOption(method, gorums.E_Correctable) { - out := customOut(g, method) - corrOut := outType(method, out) - s[corrOut] = out - } - }) -} - // field derives an embedded field name from the given typeName. // If typeName contains a package, this will be removed. func field(typeName string) string { diff --git a/cmd/protoc-gen-gorums/gengorums/template_async.go b/cmd/protoc-gen-gorums/gengorums/template_async.go deleted file mode 100644 index fa6e842dd..000000000 --- a/cmd/protoc-gen-gorums/gengorums/template_async.go +++ /dev/null @@ -1,59 +0,0 @@ -package gengorums - -var asyncCallComment = ` -{{$comments := .Method.Comments.Leading}} -{{if ne $comments ""}} -{{$comments -}} -{{else}} -{{if hasPerNodeArg .Method}} -// {{$method}} asynchronously invokes a quorum call on each node in -// configuration c, with the argument returned by the provided function f -// and returns the result as a {{$asyncOut}}, which can be used to inspect -// the quorum call reply and error when available. -// The provide per node function f takes the provided {{$in}} argument -// and returns an {{$out}} object to be passed to the given nodeID. -// The per node function f should be thread-safe. -{{else}} -// {{$method}} asynchronously invokes a quorum call on configuration c -// and returns a {{$asyncOut}}, which can be used to inspect the quorum call -// reply and error when available. -{{end -}} -{{end -}} -` - -var asyncSignature = `func (c *Configuration) {{$method}}(` + - `ctx {{$context}}, in *{{$in}}` + - `{{perNodeFnType .GenFile .Method ", f"}}) ` + - `*{{$asyncOut}} {` - -var asyncVar = qcVar + ` -{{$asyncOut := outType .Method $customOut}} -` - -var asyncBody = ` cd := {{$callData}}{ - Message: in, - Method: "{{$fullName}}", - } - cd.QuorumFunction = func(req {{$protoMessage}}, replies map[uint32]{{$protoMessage}}) ({{$protoMessage}}, bool) { - r := make(map[uint32]*{{$out}}, len(replies)) - for k, v := range replies { - r[k] = v.(*{{$out}}) - } - return c.qspec.{{$method}}QF(req.(*{{$in}}), r) - } -{{- if hasPerNodeArg .Method}} - cd.PerNodeArgFn = func(req {{$protoMessage}}, nid uint32) {{$protoMessage}} { - return f(req.(*{{$in}}), nid) - } -{{- end}} - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &{{$asyncOut}}{fut} -} -` - -var asyncCall = commonVariables + - asyncVar + - asyncCallComment + - asyncSignature + - asyncBody diff --git a/cmd/protoc-gen-gorums/gengorums/template_client.go b/cmd/protoc-gen-gorums/gengorums/template_client.go index ee0c0dc7c..bf4682c6b 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_client.go +++ b/cmd/protoc-gen-gorums/gengorums/template_client.go @@ -9,7 +9,6 @@ var clientVariables = ` {{$context := use "context.Context" .GenFile}} {{$_ := use "gorums.EnforceVersion" .GenFile}} {{$callOpt := use "gorums.CallOption" .GenFile}} -{{$iterator := use "iter.Seq2" .GenFile}} ` var clientConfigurationInterface = ` @@ -23,12 +22,10 @@ var clientConfigurationInterface = ` {{- $method := .GoName}} {{- if isOneway .}} {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}, opts ...{{$callOpt}}) - {{- else if or (isCorrectable .) (isAsync .)}} - {{- $customOut := outType . (customOut $genFile .)}} - {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) *{{$customOut}} {{- else}} - {{- $customOut := customOut $genFile .}} - {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) {{$iterator}}[*{{$customOut}}, error] + {{- $out := out $genFile .}} + {{$iterator := use "gorums.Iterator" $genFile}} + {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) {{$iterator}}[*{{$out}}] {{- end}} {{- end}} } @@ -49,8 +46,8 @@ var clientNodeInterface = ` {{- if isOneway .}} {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}, opts ...{{$callOpt}}) {{- else}} - {{- $customOut := customOut $genFile .}} - {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) (resp *{{$customOut}}, err error) + {{- $out := out $genFile .}} + {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) (resp *{{$out}}, err error) {{- end}} {{- end}} } diff --git a/cmd/protoc-gen-gorums/gengorums/template_correctable.go b/cmd/protoc-gen-gorums/gengorums/template_correctable.go deleted file mode 100644 index d480de1e5..000000000 --- a/cmd/protoc-gen-gorums/gengorums/template_correctable.go +++ /dev/null @@ -1,68 +0,0 @@ -package gengorums - -var correctableCallComment = ` -{{$comments := .Method.Comments.Leading}} -{{if ne $comments ""}} -{{$comments -}} -{{else}} -{{if hasPerNodeArg .Method}} -// {{$method}} asynchronously invokes a correctable quorum call on each node -// in configuration c, with the argument returned by the provided function f -// and returns a {{$correctableOut}}, which can be used to inspect -// the reply and error when available. -// The provide per node function f takes the provided {{$in}} argument -// and returns an {{$out}} object to be passed to the given nodeID. -// The per node function f should be thread-safe. -{{else}} -// {{$method}} asynchronously invokes a correctable quorum call on each node -// in configuration c and returns a {{$correctableOut}}, which can be used -// to inspect any replies or errors when available. -{{if correctableStream .Method -}} -// This method supports server-side preliminary replies (correctable stream). -{{end -}} -{{end -}} -{{end -}} -` - -var correctableVar = ` -{{$correctableOut := outType .Method $customOut}} -{{$protoMessage := use "protoreflect.ProtoMessage" .GenFile}} -{{$callData := use "gorums.CorrectableCallData" .GenFile}} -{{$genFile := .GenFile}} -{{$unexportMethod := unexport .Method.GoName}} -{{$context := use "context.Context" .GenFile}} -` - -var correctableSignature = `func (c *Configuration) {{$method}}(` + - `ctx {{$context}}, in *{{$in}}` + - `{{perNodeFnType .GenFile .Method ", f"}}) ` + - `*{{$correctableOut}} {` - -var correctableBody = ` cd := {{$callData}}{ - Message: in, - Method: "{{$fullName}}", - ServerStream: {{correctableStream .Method}}, - } - cd.QuorumFunction = func(req {{$protoMessage}}, replies map[uint32]{{$protoMessage}}) ({{$protoMessage}}, int, bool) { - r := make(map[uint32]*{{$out}}, len(replies)) - for k, v := range replies { - r[k] = v.(*{{$out}}) - } - return c.qspec.{{$method}}QF(req.(*{{$in}}), r) - } -{{- if hasPerNodeArg .Method}} - cd.PerNodeArgFn = func(req {{$protoMessage}}, nid uint32) {{$protoMessage}} { - return f(req.(*{{$in}}), nid) - } -{{- end}} - - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &{{$correctableOut}}{corr} -} -` - -var correctableCall = commonVariables + - correctableVar + - correctableCallComment + - correctableSignature + - correctableBody diff --git a/cmd/protoc-gen-gorums/gengorums/template_datatypes.go b/cmd/protoc-gen-gorums/gengorums/template_datatypes.go index ccb1badba..1e96e4acf 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_datatypes.go +++ b/cmd/protoc-gen-gorums/gengorums/template_datatypes.go @@ -1,6 +1,7 @@ package gengorums var internalOutDataType = ` +{{$_ := use "gorums.EnforceVersion" .GenFile}} {{range $intOut, $out := mapInternalOutType .GenFile .Services}} type {{$intOut}} struct { nid uint32 @@ -10,57 +11,4 @@ type {{$intOut}} struct { {{end}} ` -// This struct and API functions are generated only once per return type -// for a async call type. That is, if multiple async calls use the same -// return type, this struct and associated methods are only generated once. -var asyncDataType = ` -{{$async := use "gorums.Async" .GenFile}} -{{range $asyncOut, $customOut := mapAsyncOutType .GenFile .Services}} -{{$customOutField := field $customOut}} -// {{$asyncOut}} is a async object for processing replies. -type {{$asyncOut}} struct { - *{{$async}} -} - -// Get returns the reply and any error associated with the called method. -// The method blocks until a reply or error is available. -func (f *{{$asyncOut}}) Get() (*{{$customOut}}, error) { - resp, err := f.Async.Get() - if err != nil { - return nil, err - } - return resp.(*{{$customOut}}), err -} -{{end}} -` - -// This struct and API functions are generated only once per return type -// for a correctable call type. That is, if multiple correctable calls use the same -// return type, this struct and associated methods are only generated once. -var correctableDataType = ` -{{$correctable := use "gorums.Correctable" .GenFile}} -{{range $correctableOut, $customOut := mapCorrectableOutType .GenFile .Services}} -{{$customOutField := field $customOut}} -// {{$correctableOut}} is a correctable object for processing replies. -type {{$correctableOut}} struct { - *{{$correctable}} -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *{{$correctableOut}}) Get() (*{{$customOut}}, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*{{$customOut}}), level, err -} -{{- end -}} -` - -var dataTypes = internalOutDataType + - asyncDataType + - correctableDataType +var dataTypes = internalOutDataType diff --git a/cmd/protoc-gen-gorums/gengorums/template_multicast.go b/cmd/protoc-gen-gorums/gengorums/template_multicast.go index 40b40c199..f433ea6a0 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_multicast.go +++ b/cmd/protoc-gen-gorums/gengorums/template_multicast.go @@ -26,7 +26,7 @@ var multicastBody = ` cd := {{$callData}}{ Method: "{{$fullName}}", } {{- if hasPerNodeArg .Method}} -{{$protoMessage := use "protoreflect.ProtoMessage" .GenFile}} +{{$protoMessage := use "proto.Message" .GenFile}} cd.PerNodeArgFn = func(req {{$protoMessage}}, nid uint32) {{$protoMessage}} { return f(req.(*{{$in}}), nid) } diff --git a/cmd/protoc-gen-gorums/gengorums/template_qspec.go b/cmd/protoc-gen-gorums/gengorums/template_qspec.go deleted file mode 100644 index 3afa740cf..000000000 --- a/cmd/protoc-gen-gorums/gengorums/template_qspec.go +++ /dev/null @@ -1,59 +0,0 @@ -package gengorums - -import ( - "github.com/relab/gorums" - "google.golang.org/protobuf/compiler/protogen" -) - -var qspecInterface = ` -{{$genFile := .GenFile}} -{{$configOpt := use "gorums.ConfigOption" .GenFile}} -{{- $services := qspecServices .Services}} -{{- if eq (len $services) 0}} - // There are no quorum calls. - type QuorumSpec interface{} -{{- end}} -{{- range $services}} - // QuorumSpec is the interface of quorum functions for {{.GoName}}. - type QuorumSpec interface { - {{$configOpt}} - - {{range qspecMethods .Methods -}} - {{/* Below . is the method object */}} - {{$method := .GoName}} - {{$in := in $genFile .}} - {{$out := out $genFile .}} - {{$customOut := customOut $genFile .}} - // {{$method}}QF is the quorum function for the {{$method}} - // {{docName .}} call method. The in parameter is the request object - // supplied to the {{$method}} method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *{{$in}}'. - {{$method}}QF(in *{{$in}}, replies map[uint32]*{{$out}}) (*{{$customOut}}{{withCorrectable . ", int"}}, bool) - {{end}} - } -{{end}} -` - -// qspecMethods returns all Gorums methods that require -// a quorum function; that is, all except multicast, unicast and plain gRPC methods. -func qspecMethods(methods []*protogen.Method) (s []*protogen.Method) { - for _, method := range methods { - if hasMethodOption(method, gorums.E_Multicast, gorums.E_Unicast) || !hasGorumsCallType(method) { - // ignore multicast, unicast and non-Gorums methods - continue - } - s = append(s, method) - } - return s -} - -// qspecServices returns all services that have qspec methods. -func qspecServices(services []*protogen.Service) (s []*protogen.Service) { - for _, service := range services { - if len(qspecMethods(service.Methods)) > 0 { - s = append(s, service) - } - } - return s -} diff --git a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go index 7e08a4806..e205bde0d 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go +++ b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go @@ -7,14 +7,12 @@ var commonVariables = ` {{$in := in .GenFile .Method}} {{$out := out .GenFile .Method}} {{$intOut := internalOut $out}} -{{$customOut := customOut .GenFile .Method}} -{{$customOutField := field $customOut}} {{$unexportOutput := unexport .Method.Output.GoIdent.GoName}} ` // Common variables used in several template functions. var quorumCallVariables = ` -{{$iterator := use "iter.Seq2" .GenFile}} +{{$iterator := use "gorums.Iterator" .GenFile}} ` var quorumCallComment = ` @@ -30,7 +28,7 @@ var quorumCallComment = ` // The function f must be thread-safe. {{else}} // {{$method}} is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test {{end -}} {{end -}} ` @@ -38,11 +36,10 @@ var quorumCallComment = ` var quorumCallSignature = `func (c *Configuration) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}})` + - `{{$iterator}}[*{{$customOut}}, error] { + `{{$iterator}}[*{{$out}}] { ` var qcVar = ` -{{$protoMessage := use "protoreflect.ProtoMessage" .GenFile}} {{$callData := use "gorums.QuorumCallData" .GenFile}} {{$genFile := .GenFile}} {{$unexportMethod := unexport .Method.GoName}} @@ -52,14 +49,16 @@ var qcVar = ` var quorumCallBody = ` cd := {{$callData}}{ Message: in, Method: "{{$fullName}}", + ServerStream: {{isStream .Method}}, } {{- if hasPerNodeArg .Method}} + {{- $protoMessage := use "proto.Message" .GenFile}} cd.PerNodeArgFn = func(req {{$protoMessage}}, nid uint32) {{$protoMessage}} { return f(req.(*{{$in}}), nid) } {{- end}} - return gorums.QuorumCall[*{{$customOut}}](ctx, c.RawConfiguration, cd) + return gorums.QuorumCall[*{{$out}}](ctx, c.RawConfiguration, cd) } ` diff --git a/cmd/protoc-gen-gorums/gengorums/template_rpc.go b/cmd/protoc-gen-gorums/gengorums/template_rpc.go index ae22a4c7f..83783a92a 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_rpc.go +++ b/cmd/protoc-gen-gorums/gengorums/template_rpc.go @@ -2,7 +2,7 @@ package gengorums var rpcSignature = `func (n *Node) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + - `{{perNodeFnType .GenFile .Method ", f"}}) (resp *{{$customOut}}, err error) { + `{{perNodeFnType .GenFile .Method ", f"}}) (resp *{{$out}}, err error) { ` var rpcVar = ` @@ -17,7 +17,7 @@ var rpcBody = ` cd := {{$callData}}{ Method: "{{$fullName}}", } {{- if hasPerNodeArg .Method}} - {{$protoMessage := use "protoreflect.ProtoMessage" $genFile}} + {{$protoMessage := use "proto.Message" $genFile}} cd.PerNodeArgFn = func(req {{$protoMessage}}, nid uint32) {{$protoMessage}} { return f(req.(*{{$in}}), nid) } @@ -27,7 +27,7 @@ var rpcBody = ` cd := {{$callData}}{ if err != nil { return nil, err } - return res.(*{{$customOut}}), err + return res.(*{{$out}}), err } ` diff --git a/cmd/protoc-gen-gorums/gengorums/template_server.go b/cmd/protoc-gen-gorums/gengorums/template_server.go index 4a1cae4e3..c513aab9a 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_server.go +++ b/cmd/protoc-gen-gorums/gengorums/template_server.go @@ -11,13 +11,13 @@ var serverInterface = ` // {{$service}} is the server-side API for the {{$service}} Service type {{$service}}Server interface { {{- range .Methods}} - {{- if isOneway .}} - {{.GoName}}(ctx {{$context}}, request *{{in $genFile .}}) - {{- else if correctableStream .}} - {{.GoName}}(ctx {{$context}}, request *{{in $genFile .}}, send func(response *{{out $genFile .}}) error) error - {{- else}} - {{.GoName}}(ctx {{$context}}, request *{{in $genFile .}}) (response *{{out $genFile .}}, err error) - {{- end}} + {{- if isOneway .}} + {{.GoName}}(ctx {{$context}}, request *{{in $genFile .}}) + {{- else if isStream .}} + {{.GoName}}(ctx {{$context}}, request *{{in $genFile .}}, send func(response *{{out $genFile .}}) error) error + {{- else}} + {{.GoName}}(ctx {{$context}}, request *{{in $genFile .}}) (response *{{out $genFile .}}, err error) + {{- end}} {{- end}} } {{- end}} @@ -36,19 +36,19 @@ func Register{{$service}}Server(srv *{{use "gorums.Server" $genFile}}, impl {{$s req := in.Message.(*{{in $genFile .}}) defer ctx.Release() {{- if isOneway .}} - impl.{{.GoName}}(ctx, req) - {{- else if correctableStream .}} - err := impl.{{.GoName}}(ctx, req, func(resp *{{out $genFile .}}) error { - // create a copy of the metadata, to avoid a data race between WrapMessage and SendMsg - md := {{use "proto.Clone" $genFile}}(in.Metadata) - return {{$sendMessage}}(ctx, finished, {{$wrapMessage}}(md.(*{{use "ordering.Metadata" $genFile}}), resp, nil)) - }) - if err != nil { - {{$sendMessage}}(ctx, finished, {{$wrapMessage}}(in.Metadata, nil, err)) - } + impl.{{.GoName}}(ctx, req) + {{- else if isStream .}} + err := impl.{{.GoName}}(ctx, req, func(resp *{{out $genFile .}}) error { + // create a copy of the metadata, to avoid a data race between WrapMessage and SendMsg + md := {{use "proto.Clone" $genFile}}(in.Metadata) + return {{$sendMessage}}(ctx, finished, {{$wrapMessage}}(md.(*{{use "ordering.Metadata" $genFile}}), resp, nil)) + }) + if err != nil { + {{$sendMessage}}(ctx, finished, {{$wrapMessage}}(in.Metadata, nil, err)) + } {{- else }} - resp, err := impl.{{.GoName}}(ctx, req) - {{$sendMessage}}(ctx, finished, {{$wrapMessage}}(in.Metadata, resp, err)) + resp, err := impl.{{.GoName}}(ctx, req) + {{$sendMessage}}(ctx, finished, {{$wrapMessage}}(in.Metadata, resp, err)) {{- end}} }) {{- end}} diff --git a/cmd/protoc-gen-gorums/gengorums/template_static.go b/cmd/protoc-gen-gorums/gengorums/template_static.go index 970445260..db2fe6231 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_static.go +++ b/cmd/protoc-gen-gorums/gengorums/template_static.go @@ -5,17 +5,16 @@ package gengorums // pkgIdentMap maps from package name to one of the package's identifiers. // These identifiers are used by the Gorums protoc plugin to generate import statements. -var pkgIdentMap = map[string]string{"fmt": "Errorf", "github.com/relab/gorums": "ConfigOption", "google.golang.org/grpc/encoding": "GetCodec"} +var pkgIdentMap = map[string]string{"github.com/relab/gorums": "ContentSubtype", "google.golang.org/grpc/encoding": "GetCodec"} // reservedIdents holds the set of Gorums reserved identifiers. // These identifiers cannot be used to define message types in a proto file. -var reservedIdents = []string{"Configuration", "Manager", "Node", "QuorumSpec"} +var reservedIdents = []string{"Configuration", "Manager", "Node"} var staticCode = `// A Configuration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -25,15 +24,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -90,30 +83,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { diff --git a/correctable.go b/correctable.go index 5e98cc25a..7619f11d2 100644 --- a/correctable.go +++ b/correctable.go @@ -1,11 +1,10 @@ package gorums import ( - "context" + "iter" "sync" - "github.com/relab/gorums/ordering" - "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/proto" ) // LevelNotSet is the zero value level used to indicate that no level (and @@ -20,9 +19,9 @@ type watcher struct { // Correctable encapsulates the state of a correctable quorum call. // // This struct should be used by generated code only. -type Correctable struct { +type Correctable[resultType any] struct { mu sync.Mutex - reply protoreflect.ProtoMessage + reply resultType level int err error done bool @@ -31,19 +30,19 @@ type Correctable struct { } // Get returns the latest response, the current level, and the last error. -func (c *Correctable) Get() (protoreflect.ProtoMessage, int, error) { +func (c *Correctable[resultType]) Get() (resultType, int, error) { c.mu.Lock() defer c.mu.Unlock() return c.reply, c.level, c.err } // Done returns a channel that will close when the correctable call is completed. -func (c *Correctable) Done() <-chan struct{} { +func (c *Correctable[resultType]) Done() <-chan struct{} { return c.donech } // Watch returns a channel that will close when the correctable call has reached a specified level. -func (c *Correctable) Watch(level int) <-chan struct{} { +func (c *Correctable[resultType]) Watch(level int) <-chan struct{} { ch := make(chan struct{}) c.mu.Lock() defer c.mu.Unlock() @@ -55,7 +54,7 @@ func (c *Correctable) Watch(level int) <-chan struct{} { return ch } -func (c *Correctable) set(reply protoreflect.ProtoMessage, level int, err error, done bool) { +func (c *Correctable[resultType]) set(reply resultType, level int, err error, done bool) { c.mu.Lock() defer c.mu.Unlock() if c.done { @@ -79,98 +78,23 @@ func (c *Correctable) set(reply protoreflect.ProtoMessage, level int, err error, } } -// CorrectableCallData contains data for making a correctable quorum call. -// -// This struct should only be used by generated code. -type CorrectableCallData struct { - Message protoreflect.ProtoMessage - Method string - PerNodeArgFn func(protoreflect.ProtoMessage, uint32) protoreflect.ProtoMessage - QuorumFunction func(protoreflect.ProtoMessage, map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) - ServerStream bool -} - -type correctableCallState struct { - md *ordering.Metadata - data CorrectableCallData - replyChan <-chan response - expectedReplies int -} - -// CorrectableCall starts a new correctable quorum call and returns a new Correctable object. -// -// This method should only be used by generated code. -func (c RawConfiguration) CorrectableCall(ctx context.Context, d CorrectableCallData) *Correctable { - expectedReplies := len(c) - md := ordering.NewGorumsMetadata(ctx, c.getMsgID(), d.Method) - - replyChan := make(chan response, expectedReplies) - for _, n := range c { - msg := d.Message - if d.PerNodeArgFn != nil { - msg = d.PerNodeArgFn(d.Message, n.id) - if !msg.ProtoReflect().IsValid() { - expectedReplies-- - continue // don't send if no msg - } +func IterToCorrectable[responseType proto.Message, dataType any, resultType any]( + iter Iterator[responseType], + data dataType, + corrFunction func(Iterator[responseType], dataType) iter.Seq2[resultType, int], +) *Correctable[resultType] { + corr := &Correctable[resultType]{donech: make(chan struct{}, 1)} + go func() { + for result, level := range corrFunction(iter, data) { + corr.set(result, level, nil, false) } - n.channel.enqueue(request{ctx: ctx, msg: &Message{Metadata: md, Message: msg}}, replyChan, d.ServerStream) - } - - corr := &Correctable{donech: make(chan struct{}, 1)} - - go c.handleCorrectableCall(ctx, corr, correctableCallState{ - md: md, - data: d, - replyChan: replyChan, - expectedReplies: expectedReplies, - }) - - return corr -} - -func (c RawConfiguration) handleCorrectableCall(ctx context.Context, corr *Correctable, state correctableCallState) { - var ( - resp protoreflect.ProtoMessage - errs []nodeError - rlevel int - clevel = LevelNotSet - quorum bool - replies = make(map[uint32]protoreflect.ProtoMessage) - ) - - if state.data.ServerStream { - for _, n := range c { - defer n.channel.deleteRouter(state.md.GetMessageID()) - } - } - - for { - select { - case r := <-state.replyChan: - if r.err != nil { - errs = append(errs, nodeError{nodeID: r.nid, cause: r.err}) - break - } - replies[r.nid] = r.msg - if resp, rlevel, quorum = state.data.QuorumFunction(state.data.Message, replies); quorum { - if quorum { - corr.set(r.msg, rlevel, nil, true) - return - } - if rlevel > clevel { - clevel = rlevel - corr.set(r.msg, rlevel, nil, false) - } + corr.done = true + close(corr.donech) + for _, watcher := range corr.watchers { + if watcher != nil { + close(watcher.ch) } - case <-ctx.Done(): - corr.set(resp, clevel, QuorumCallError{cause: ctx.Err()}, true) - return } - if (state.data.ServerStream && len(errs) == state.expectedReplies) || - (!state.data.ServerStream && len(errs)+len(replies) == state.expectedReplies) { - corr.set(resp, clevel, QuorumCallError{cause: Incomplete}, true) - return - } - } + }() + return corr } diff --git a/encoding.go b/encoding.go index b68bee3df..d3844fc03 100644 --- a/encoding.go +++ b/encoding.go @@ -25,7 +25,7 @@ const ( // This struct should be used by generated code only. type Message struct { Metadata *ordering.Metadata - Message protoreflect.ProtoMessage + Message proto.Message msgType gorumsMsgType } @@ -63,7 +63,7 @@ func (c Codec) Marshal(m any) (b []byte, err error) { switch msg := m.(type) { case *Message: return c.gorumsMarshal(msg) - case protoreflect.ProtoMessage: + case proto.Message: return c.marshaler.Marshal(msg) default: return nil, fmt.Errorf("gorums: cannot marshal message of type '%T'", m) @@ -93,7 +93,7 @@ func (c Codec) Unmarshal(b []byte, m any) (err error) { switch msg := m.(type) { case *Message: return c.gorumsUnmarshal(b, msg) - case protoreflect.ProtoMessage: + case proto.Message: return c.unmarshaler.Unmarshal(b, msg) default: return fmt.Errorf("gorums: cannot unmarshal message of type '%T'", m) diff --git a/examples/storage/client.go b/examples/storage/client.go index cde90ebfe..4418517f2 100644 --- a/examples/storage/client.go +++ b/examples/storage/client.go @@ -21,7 +21,7 @@ func runClient(addresses []string) error { ), ) // create configuration containing all nodes - cfg, err := mgr.NewConfiguration(&qspec{cfgSize: len(addresses)}, gorums.WithNodeList(addresses)) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(addresses)) if err != nil { log.Fatal(err) } @@ -38,7 +38,10 @@ type qspec struct { // supplied to the ReadQC method at call time, and may or may not // be used by the quorum function. If the in parameter is not needed // you should implement your quorum function with '_ *ReadRequest'. -func (q qspec) ReadQCQF(_ *proto.ReadRequest, replies map[uint32]*proto.ReadResponse) (*proto.ReadResponse, bool) { +func (q qspec) ReadQCQF( + _ *proto.ReadRequest, + replies map[uint32]*proto.ReadResponse, +) (*proto.ReadResponse, bool) { // wait until at least half of the replicas have responded if len(replies) <= q.cfgSize/2 { return nil, false @@ -79,6 +82,25 @@ func newestValue(values map[uint32]*proto.ReadResponse) *proto.ReadResponse { return newest } +// newestValue returns the reply that had the most recent timestamp +func newestValueOfTwo(v1, v2 *proto.ReadResponse) *proto.ReadResponse { + if v1 == nil { + return v2 + } else if v2 == nil { + return v1 + } + if v1.GetTime().AsTime().After(v2.GetTime().AsTime()) { + return v1 + } else { + return v2 + } +} + +// numUpdated returns the number of replicas that updated their value +func isUpdated(r *proto.WriteResponse) bool { + return r.GetNew() +} + // numUpdated returns the number of replicas that updated their value func numUpdated(replies map[uint32]*proto.WriteResponse) int { count := 0 diff --git a/examples/storage/proto/storage.pb.go b/examples/storage/proto/storage.pb.go index 1cbca30bc..6f7d7721b 100644 --- a/examples/storage/proto/storage.pb.go +++ b/examples/storage/proto/storage.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: storage/proto/storage.proto package proto diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index ac6fe7308..c1dff503b 100644 --- a/examples/storage/proto/storage_gorums.pb.go +++ b/examples/storage/proto/storage_gorums.pb.go @@ -1,17 +1,15 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+903a0213 -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: storage/proto/storage.proto package proto import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -26,7 +24,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -36,15 +33,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test interface{} = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -101,30 +92,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test interface{} = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -152,8 +126,9 @@ type Node struct { // StorageClient is the client interface for the Storage service. type StorageClient interface { - ReadQC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error) - WriteQC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error) + ReadQC(ctx context.Context, in *ReadRequest) gorums.Iterator[*ReadResponse] + + WriteQC(ctx context.Context, in *WriteRequest) gorums.Iterator[*WriteResponse] WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) } @@ -173,7 +148,7 @@ var _ StorageNodeClient = (*Node)(nil) var _ emptypb.Empty // WriteMulticast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (c *Configuration) WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, @@ -183,67 +158,28 @@ func (c *Configuration) WriteMulticast(ctx context.Context, in *WriteRequest, op c.RawConfiguration.Multicast(ctx, cd, opts...) } -// QuorumSpec is the interface of quorum functions for Storage. -type QuorumSpec interface { - gorums.ConfigOption - - // ReadQCQF is the quorum function for the ReadQC - // quorum call method. The in parameter is the request object - // supplied to the ReadQC method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *ReadRequest'. - ReadQCQF(in *ReadRequest, replies map[uint32]*ReadResponse) (*ReadResponse, bool) - - // WriteQCQF is the quorum function for the WriteQC - // quorum call method. The in parameter is the request object - // supplied to the WriteQC method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *WriteRequest'. - WriteQCQF(in *WriteRequest, replies map[uint32]*WriteResponse) (*WriteResponse, bool) -} - // ReadQC executes the Read Quorum Call on a configuration // of Nodes and returns the most recent value. -func (c *Configuration) ReadQC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error) { +func (c *Configuration) ReadQC(ctx context.Context, in *ReadRequest) gorums.Iterator[*ReadResponse] { cd := gorums.QuorumCallData{ - Message: in, - Method: "storage.Storage.ReadQC", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*ReadResponse, len(replies)) - for k, v := range replies { - r[k] = v.(*ReadResponse) - } - return c.qspec.ReadQCQF(req.(*ReadRequest), r) + Message: in, + Method: "storage.Storage.ReadQC", + ServerStream: false, } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*ReadResponse), err + return gorums.QuorumCall[*ReadResponse](ctx, c.RawConfiguration, cd) } // WriteQC executes the Write Quorum Call on a configuration // of Nodes and returns true if a majority of Nodes were updated. -func (c *Configuration) WriteQC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error) { +func (c *Configuration) WriteQC(ctx context.Context, in *WriteRequest) gorums.Iterator[*WriteResponse] { cd := gorums.QuorumCallData{ - Message: in, - Method: "storage.Storage.WriteQC", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*WriteResponse, len(replies)) - for k, v := range replies { - r[k] = v.(*WriteResponse) - } - return c.qspec.WriteQCQF(req.(*WriteRequest), r) + Message: in, + Method: "storage.Storage.WriteQC", + ServerStream: false, } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*WriteResponse), err + return gorums.QuorumCall[*WriteResponse](ctx, c.RawConfiguration, cd) } // ReadRPC executes the Read RPC on a single Node diff --git a/examples/storage/repl.go b/examples/storage/repl.go index a939013c3..43929a822 100644 --- a/examples/storage/repl.go +++ b/examples/storage/repl.go @@ -12,6 +12,7 @@ import ( "github.com/google/shlex" "github.com/relab/gorums" + "github.com/relab/gorums/examples/storage/proto" pb "github.com/relab/gorums/examples/storage/proto" "golang.org/x/term" "google.golang.org/protobuf/types/known/timestamppb" @@ -248,13 +249,35 @@ func (repl) writeRPC(args []string, node *pb.Node) { fmt.Println("Write OK") } +func readqc(cfg *pb.Configuration, ctx context.Context, req *pb.ReadRequest) (*pb.ReadResponse, error) { + cfgSize := cfg.Size() + + var newest *pb.ReadResponse + replies := int(0) + for response := range cfg.ReadQC(ctx, req) { + msg, err, _ := response.Unpack() + if err != nil { + return nil, err + } + replies++ + newest = newestValueOfTwo(msg, newest) + if replies <= cfgSize/2 { + continue + } + return newest, nil + } + return nil, errors.New("storage.readqc: Error unreachable") +} + func (repl) readQC(args []string, cfg *pb.Configuration) { if len(args) < 1 { fmt.Println("Read requires a key to read.") return } ctx, cancel := context.WithTimeout(context.Background(), time.Second) - resp, err := cfg.ReadQC(ctx, pb.ReadRequest_builder{Key: args[0]}.Build()) + + resp, err := readqc(cfg, ctx, pb.ReadRequest_builder{Key: args[0]}.Build()) + cancel() if err != nil { fmt.Printf("Read RPC finished with error: %v\n", err) @@ -267,13 +290,40 @@ func (repl) readQC(args []string, cfg *pb.Configuration) { fmt.Printf("%s = %s\n", args[0], resp.GetValue()) } +func writeqc(cfg *pb.Configuration, ctx context.Context, req *pb.WriteRequest) (*pb.WriteResponse, error) { + cfgSize := cfg.Size() + + replies := int(0) + updated := int(0) + for response := range cfg.WriteQC(ctx, req) { + msg, err, _ := response.Unpack() + + if err != nil { + return nil, err + } + replies++ + if isUpdated(msg) { + updated++ + } + if updated > cfgSize/2 { + return proto.WriteResponse_builder{New: true}.Build(), nil + } + // if all replicas have responded, there must have been another write before ours + // that had a newer timestamp + if replies == cfgSize { + return proto.WriteResponse_builder{New: false}.Build(), nil + } + } + return nil, errors.New("storage.writeqc: Error unreachable") +} + func (repl) writeQC(args []string, cfg *pb.Configuration) { if len(args) < 2 { fmt.Println("Write requires a key and a value to write.") return } ctx, cancel := context.WithTimeout(context.Background(), time.Second) - resp, err := cfg.WriteQC(ctx, pb.WriteRequest_builder{Key: args[0], Value: args[1], Time: timestamppb.Now()}.Build()) + resp, err := writeqc(cfg, ctx, pb.WriteRequest_builder{Key: args[0], Value: args[1], Time: timestamppb.Now()}.Build()) cancel() if err != nil { fmt.Printf("Write RPC finished with error: %v\n", err) @@ -318,7 +368,7 @@ func (r repl) parseConfiguration(cfgStr string) (cfg *pb.Configuration) { for _, node := range r.mgr.Nodes()[start:stop] { nodes = append(nodes, node.Address()) } - cfg, err = r.mgr.NewConfiguration(&qspec{cfgSize: stop - start}, gorums.WithNodeList(nodes)) + cfg, err = r.mgr.NewConfiguration(gorums.WithNodeList(nodes)) if err != nil { fmt.Printf("Failed to create configuration: %v\n", err) return nil @@ -341,7 +391,7 @@ func (r repl) parseConfiguration(cfgStr string) (cfg *pb.Configuration) { } selectedNodes = append(selectedNodes, nodes[i].Address()) } - cfg, err := r.mgr.NewConfiguration(&qspec{cfgSize: len(selectedNodes)}, gorums.WithNodeList(selectedNodes)) + cfg, err := r.mgr.NewConfiguration(gorums.WithNodeList(selectedNodes)) if err != nil { fmt.Printf("Failed to create configuration: %v\n", err) return nil diff --git a/gorums.pb.go b/gorums.pb.go index ca92169b4..062b1b324 100644 --- a/gorums.pb.go +++ b/gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.2 +// protoc v6.30.2 // source: gorums.proto package gorums @@ -54,22 +54,6 @@ var file_gorums_proto_extTypes = []protoimpl.ExtensionInfo{ Tag: "varint,50004,opt,name=quorumcall", Filename: "gorums.proto", }, - { - ExtendedType: (*descriptorpb.MethodOptions)(nil), - ExtensionType: (*bool)(nil), - Field: 50005, - Name: "gorums.correctable", - Tag: "varint,50005,opt,name=correctable", - Filename: "gorums.proto", - }, - { - ExtendedType: (*descriptorpb.MethodOptions)(nil), - ExtensionType: (*bool)(nil), - Field: 50010, - Name: "gorums.async", - Tag: "varint,50010,opt,name=async", - Filename: "gorums.proto", - }, { ExtendedType: (*descriptorpb.MethodOptions)(nil), ExtensionType: (*bool)(nil), @@ -78,14 +62,6 @@ var file_gorums_proto_extTypes = []protoimpl.ExtensionInfo{ Tag: "varint,50020,opt,name=per_node_arg", Filename: "gorums.proto", }, - { - ExtendedType: (*descriptorpb.MethodOptions)(nil), - ExtensionType: (*string)(nil), - Field: 50030, - Name: "gorums.custom_return_type", - Tag: "bytes,50030,opt,name=custom_return_type", - Filename: "gorums.proto", - }, } // Extension fields to descriptorpb.MethodOptions. @@ -100,16 +76,10 @@ var ( E_Multicast = &file_gorums_proto_extTypes[2] // optional bool quorumcall = 50004; E_Quorumcall = &file_gorums_proto_extTypes[3] - // optional bool correctable = 50005; - E_Correctable = &file_gorums_proto_extTypes[4] // options for call types // - // optional bool async = 50010; - E_Async = &file_gorums_proto_extTypes[5] // optional bool per_node_arg = 50020; - E_PerNodeArg = &file_gorums_proto_extTypes[6] - // optional string custom_return_type = 50030; - E_CustomReturnType = &file_gorums_proto_extTypes[7] + E_PerNodeArg = &file_gorums_proto_extTypes[4] ) var File_gorums_proto protoreflect.FileDescriptor @@ -123,11 +93,8 @@ const file_gorums_proto_rawDesc = "" + "\n" + "quorumcall\x12\x1e.google.protobuf.MethodOptions\x18ิ†\x03 \x01(\bR\n" + "quorumcall:B\n" + - "\vcorrectable\x12\x1e.google.protobuf.MethodOptions\x18ี†\x03 \x01(\bR\vcorrectable:6\n" + - "\x05async\x12\x1e.google.protobuf.MethodOptions\x18ฺ†\x03 \x01(\bR\x05async:B\n" + "\fper_node_arg\x12\x1e.google.protobuf.MethodOptions\x18\xe4\x86\x03 \x01(\bR\n" + - "perNodeArg:N\n" + - "\x12custom_return_type\x12\x1e.google.protobuf.MethodOptions\x18\xee\x86\x03 \x01(\tR\x10customReturnTypeB\x1eZ\x17github.com/relab/gorums\x92\x03\x02\b\x02b\beditionsp\xe8\a" + "perNodeArgB\x1eZ\x17github.com/relab/gorums\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_gorums_proto_goTypes = []any{ (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions @@ -137,14 +104,11 @@ var file_gorums_proto_depIdxs = []int32{ 0, // 1: gorums.unicast:extendee -> google.protobuf.MethodOptions 0, // 2: gorums.multicast:extendee -> google.protobuf.MethodOptions 0, // 3: gorums.quorumcall:extendee -> google.protobuf.MethodOptions - 0, // 4: gorums.correctable:extendee -> google.protobuf.MethodOptions - 0, // 5: gorums.async:extendee -> google.protobuf.MethodOptions - 0, // 6: gorums.per_node_arg:extendee -> google.protobuf.MethodOptions - 0, // 7: gorums.custom_return_type:extendee -> google.protobuf.MethodOptions - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 0, // [0:8] is the sub-list for extension extendee + 0, // 4: gorums.per_node_arg:extendee -> google.protobuf.MethodOptions + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 0, // [0:5] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } @@ -160,7 +124,7 @@ func file_gorums_proto_init() { RawDescriptor: unsafe.Slice(unsafe.StringData(file_gorums_proto_rawDesc), len(file_gorums_proto_rawDesc)), NumEnums: 0, NumMessages: 0, - NumExtensions: 8, + NumExtensions: 5, NumServices: 0, }, GoTypes: file_gorums_proto_goTypes, diff --git a/gorums.proto b/gorums.proto index 45d9f19dd..a352ecd43 100644 --- a/gorums.proto +++ b/gorums.proto @@ -9,13 +9,10 @@ import "google/protobuf/descriptor.proto"; extend google.protobuf.MethodOptions { // call types - bool rpc = 50001; - bool unicast = 50002; - bool multicast = 50003; - bool quorumcall = 50004; - bool correctable = 50005; + bool rpc = 50001; + bool unicast = 50002; + bool multicast = 50003; + bool quorumcall = 50004; // options for call types - bool async = 50010; - bool per_node_arg = 50020; - string custom_return_type = 50030; + bool per_node_arg = 50020; } diff --git a/internal/correctable/opts.pb.go b/internal/correctable/opts.pb.go index a68225dc0..d5b8e7053 100644 --- a/internal/correctable/opts.pb.go +++ b/internal/correctable/opts.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.2 +// protoc v6.30.2 // source: internal/correctable/opts.proto package correctable diff --git a/internal/testprotos/calltypes/async/async.proto b/internal/testprotos/calltypes/async/async.proto deleted file mode 100644 index 784ee150c..000000000 --- a/internal/testprotos/calltypes/async/async.proto +++ /dev/null @@ -1,24 +0,0 @@ -// Test that Gorums can generate a single asynchronous quorum call method. - -edition = "2023"; - -package gorums.testprotos.calltypes.async; -option go_package = "github.com/relab/gorums/internal/testprotos/calltypes/async"; - -option features.field_presence = IMPLICIT; - -import "gorums.proto"; - -service AsyncQuorumCall { - rpc AsyncQuorumCall(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } -} - -message Request { - string Value = 1; -} -message Response { - int64 Result = 1; -} diff --git a/internal/testprotos/calltypes/zorums/zorums.proto b/internal/testprotos/calltypes/zorums/zorums.proto index e8823953c..962109972 100644 --- a/internal/testprotos/calltypes/zorums/zorums.proto +++ b/internal/testprotos/calltypes/zorums/zorums.proto @@ -46,17 +46,6 @@ service ZorumsService { option (gorums.quorumcall) = true; option (gorums.per_node_arg) = true; } - // QuorumCall with custom_return_type option. - rpc QuorumCallCustomReturnType(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // QuorumCallCombo with all supported options. - rpc QuorumCallCombo(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.per_node_arg) = true; - option (gorums.custom_return_type) = "MyResponse"; - } // QuorumCallEmpty for testing imported message type. rpc QuorumCallEmpty(google.protobuf.Empty) returns (Response) { option (gorums.quorumcall) = true; @@ -66,6 +55,28 @@ service ZorumsService { option (gorums.quorumcall) = true; } + // --------------------------------------------------------------- + // QuorumCallStream variants + // --------------------------------------------------------------- + + // QuorumCall plain. + rpc QuorumCallStream(Request) returns (stream Response) { + option (gorums.quorumcall) = true; + } + // QuorumCall with per_node_arg option. + rpc QuorumCallPerNodeArgStream(Request) returns (stream Response) { + option (gorums.quorumcall) = true; + option (gorums.per_node_arg) = true; + } + // QuorumCallEmpty for testing imported message type. + rpc QuorumCallEmptyStream(google.protobuf.Empty) returns (stream Response) { + option (gorums.quorumcall) = true; + } + // QuorumCallEmpty2 for testing imported message type. + rpc QuorumCallEmpty2Stream(Request) returns (stream google.protobuf.Empty) { + option (gorums.quorumcall) = true; + } + // ------------------------------------------------------------------ // Multicast variants // The multicast call type does not support the 'custom_return_type' @@ -95,119 +106,6 @@ service ZorumsService { option (gorums.multicast) = true; } - // --------------------------------------------------------------- - // Async variants - // --------------------------------------------------------------- - - // QuorumCallAsync plain. - rpc QuorumCallAsync(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } - // QuorumCallAsyncPerNodeArg with per_node_arg option. - rpc QuorumCallAsyncPerNodeArg(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - option (gorums.per_node_arg) = true; - } - // QuorumCallAsyncCustomReturnType with custom_return_type option. - rpc QuorumCallAsyncCustomReturnType(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // QuorumCallAsyncCombo with all supported options. - rpc QuorumCallAsyncCombo(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - option (gorums.per_node_arg) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // QuorumCallAsync2 plain; with same return type: Response. - rpc QuorumCallAsync2(Request) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } - // QuorumCallAsyncEmpty for testing imported message type. - rpc QuorumCallAsyncEmpty(Request) returns (google.protobuf.Empty) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } - // QuorumCallAsyncEmpty2 for testing imported message type; with same return - // type as QuorumCallAsync: Response. - rpc QuorumCallAsyncEmpty2(google.protobuf.Empty) returns (Response) { - option (gorums.quorumcall) = true; - option (gorums.async) = true; - } - - // --------------------------------------------------------------- - // Correctable variants - // --------------------------------------------------------------- - - // Correctable plain. - rpc Correctable(Request) returns (Response) { - option (gorums.correctable) = true; - } - // CorrectablePerNodeArg with per_node_arg option. - rpc CorrectablePerNodeArg(Request) returns (Response) { - option (gorums.correctable) = true; - option (gorums.per_node_arg) = true; - } - // CorrectableCustomReturnType with custom_return_type option. - rpc CorrectableCustomReturnType(Request) returns (Response) { - option (gorums.correctable) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // CorrectableCombo with all supported options. - rpc CorrectableCombo(Request) returns (Response) { - option (gorums.correctable) = true; - option (gorums.per_node_arg) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // CorrectableEmpty for testing imported message type. - rpc CorrectableEmpty(Request) returns (google.protobuf.Empty) { - option (gorums.correctable) = true; - } - // CorrectableEmpty2 for testing imported message type; with same return - // type as Correctable: Response. - rpc CorrectableEmpty2(google.protobuf.Empty) returns (Response) { - option (gorums.correctable) = true; - } - - // --------------------------------------------------------------- - // CorrectableStream variants - // --------------------------------------------------------------- - - // CorrectableStream plain. - rpc CorrectableStream(Request) returns (stream Response) { - option (gorums.correctable) = true; - } - // CorrectablePerNodeArg with per_node_arg option. - rpc CorrectableStreamPerNodeArg(Request) returns (stream Response) { - option (gorums.correctable) = true; - option (gorums.per_node_arg) = true; - } - // CorrectableCustomReturnType with custom_return_type option. - rpc CorrectableStreamCustomReturnType(Request) returns (stream Response) { - option (gorums.correctable) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // CorrectableCombo with all supported options. - rpc CorrectableStreamCombo(Request) returns (stream Response) { - option (gorums.correctable) = true; - option (gorums.per_node_arg) = true; - option (gorums.custom_return_type) = "MyResponse"; - } - // CorrectableEmpty for testing imported message type. - rpc CorrectableStreamEmpty(Request) returns (stream google.protobuf.Empty) { - option (gorums.correctable) = true; - } - // CorrectableEmpty2 for testing imported message type; with same return - // type as Correctable: Response. - rpc CorrectableStreamEmpty2(google.protobuf.Empty) returns (stream Response) { - option (gorums.correctable) = true; - } - // --------------------------------------------------------------- // Unicast // --------------------------------------------------------------- diff --git a/iterator.go b/iterator.go new file mode 100644 index 000000000..4cab49ee5 --- /dev/null +++ b/iterator.go @@ -0,0 +1,79 @@ +package gorums + +import ( + "errors" + "iter" + + "google.golang.org/protobuf/proto" +) + +// Response contains the values returned from a quorum call +// Msg is the proto message returned by the server +// Nid is the node id of the server +// Err may contain an error +type Response[messageType proto.Message] struct { + Msg messageType + Err error + Nid uint32 +} + +// NewResponse initialized a response struct without needing to specify the message type +func NewResponse[messageType proto.Message](msg messageType, err error, nid uint32) Response[messageType] { + return Response[messageType]{ + Msg: msg, + Err: err, + Nid: nid, + } +} + +// The Unpack methods lets you destructure the response in a single line +func (r Response[messageType]) Unpack() (messageType, error, uint32) { + return r.Msg, r.Err, r.Nid +} + +type Iterator[messageType proto.Message] iter.Seq[Response[messageType]] + +// this method uses a function to keep/remove messages from a quorum call +// this can be used to verify the responses from servers before any further computation +func (iterator Iterator[messageType]) Filter(forward func(Response[messageType]) bool) Iterator[messageType] { + return func(yield func(Response[messageType]) bool) { + for resp := range iterator { + if forward(resp) { + if !yield(resp) { + return + } + } + } + } +} + +// If you expect all servers to send the same reply, +// you can use GetQuorum to find the first message to occur +// a specified amount of times +func (iterator Iterator[messageType]) GetQuorum(quorum int) (messageType, error) { + type replyFreq struct { + val messageType + freq int + } + + replyFreqs := make([]replyFreq, 0) + + for resp := range iterator { + for i, replyFreq := range replyFreqs { + if proto.Equal(replyFreq.val, resp.Msg) { + replyFreqs[i].freq++ + if replyFreqs[i].freq >= quorum { + return resp.Msg, nil + } + } + } + + if quorum <= 1 { + return resp.Msg, nil + } + replyFreqs = append(replyFreqs, replyFreq{resp.Msg, 1}) + } + + var noReply messageType + return noReply, errors.New("quorum not found") +} diff --git a/ordering/ordering.pb.go b/ordering/ordering.pb.go index a9323e7ec..489bf8de8 100644 --- a/ordering/ordering.pb.go +++ b/ordering/ordering.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.2 +// protoc v6.30.2 // source: ordering/ordering.proto package ordering diff --git a/ordering/ordering_grpc.pb.go b/ordering/ordering_grpc.pb.go index 385adba95..351b84c48 100644 --- a/ordering/ordering_grpc.pb.go +++ b/ordering/ordering_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.29.2 +// - protoc v6.30.2 // source: ordering/ordering.proto package ordering diff --git a/quorumcall.go b/quorumcall.go index cb2eefe72..fce3d36b9 100644 --- a/quorumcall.go +++ b/quorumcall.go @@ -2,10 +2,9 @@ package gorums import ( "context" - "iter" "github.com/relab/gorums/ordering" - "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/proto" ) // QuorumCallData holds the message, destination nodes, method identifier, @@ -14,20 +13,25 @@ import ( // // This struct should be used by generated code only. type QuorumCallData struct { - Message protoreflect.ProtoMessage - Method string - PerNodeArgFn func(protoreflect.ProtoMessage, uint32) protoreflect.ProtoMessage - QuorumFunction func(protoreflect.ProtoMessage, map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) + Message proto.Message + Method string + PerNodeArgFn func(proto.Message, uint32) proto.Message + ServerStream bool } // QuorumCall performs a quorum call on the configuration. // // This method should be used by generated code only. -func QuorumCall[responseType protoreflect.ProtoMessage](ctx context.Context, c RawConfiguration, d QuorumCallData) iter.Seq2[responseType, error] { +func QuorumCall[responseType proto.Message]( + ctx context.Context, + c RawConfiguration, + d QuorumCallData, +) Iterator[responseType] { expectedReplies := len(c) md := ordering.NewGorumsMetadata(ctx, c.getMsgID(), d.Method) replyChan := make(chan response, expectedReplies) + for _, n := range c { msg := d.Message if d.PerNodeArgFn != nil { @@ -37,26 +41,36 @@ func QuorumCall[responseType protoreflect.ProtoMessage](ctx context.Context, c R continue // don't send if no msg } } - n.channel.enqueue(request{ctx: ctx, msg: &Message{Metadata: md, Message: msg}}, replyChan, false) + n.channel.enqueue( + request{ + ctx: ctx, + msg: &Message{Metadata: md, Message: msg}, + }, + replyChan, d.ServerStream, + ) + } + + if d.ServerStream { + for _, n := range c { + defer n.channel.deleteRouter(md.GetMessageID()) + } } replies := int(0) - var noResponse responseType - return func(yield func(K responseType, V error) bool) { + return func(yield func(Response[responseType]) bool) { for { select { case r := <-replyChan: replies++ - if !yield(r.msg.(responseType), r.err) { + if !yield(NewResponse(r.msg.(responseType), r.err, r.nid)) { return } case <-ctx.Done(): - yield(noResponse, QuorumCallError{cause: ctx.Err()}) return } - if replies >= expectedReplies { - yield(noResponse, QuorumCallError{cause: Incomplete}) + // for streaming just wait for context timeout/cancel + if d.ServerStream && replies >= expectedReplies { return } } diff --git a/rpc.go b/rpc.go index 7cb20c804..c37070a6d 100644 --- a/rpc.go +++ b/rpc.go @@ -4,21 +4,21 @@ import ( "context" "github.com/relab/gorums/ordering" - "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/proto" ) // CallData contains data needed to make a remote procedure call. // // This struct should be used by generated code only. type CallData struct { - Message protoreflect.ProtoMessage + Message proto.Message Method string } // RPCCall executes a remote procedure call on the node. // // This method should be used by generated code only. -func (n *RawNode) RPCCall(ctx context.Context, d CallData) (protoreflect.ProtoMessage, error) { +func (n *RawNode) RPCCall(ctx context.Context, d CallData) (proto.Message, error) { md := ordering.NewGorumsMetadata(ctx, n.mgr.getMsgID(), d.Method) replyChan := make(chan response, 1) n.channel.enqueue(request{ctx: ctx, msg: &Message{Metadata: md, Message: d.Message}}, replyChan, false) diff --git a/server.go b/server.go index d5601f97f..ac4a650c3 100644 --- a/server.go +++ b/server.go @@ -9,7 +9,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/proto" ) // requestHandler is used to fetch a response message based on the request. @@ -47,7 +47,7 @@ func SendMessage(ctx context.Context, c chan<- *Message, msg *Message) error { // WrapMessage wraps the metadata, response and error status in a gorumsMessage // // This function should be used by generated code only. -func WrapMessage(md *ordering.Metadata, resp protoreflect.ProtoMessage, err error) *Message { +func WrapMessage(md *ordering.Metadata, resp proto.Message, err error) *Message { errStatus, ok := status.FromError(err) if !ok { errStatus = status.New(codes.Unknown, err.Error()) diff --git a/tests/Makefile b/tests/Makefile index 5b8f51ca4..846f967ed 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -24,13 +24,20 @@ config: config/config.pb.go config/config_gorums.pb.go correctable: correctable/correctable.pb.go correctable/correctable_gorums.pb.go %.pb.go : %.proto - @protoc -I=..:. --go_out=paths=source_relative:. $< + @protoc -I=..:. \ + --go_out=paths=source_relative:. \ + --go_opt=default_api_level=API_OPAQUE \ + $< %_grpc.pb.go : %.proto - @protoc -I=..:. --go-grpc_out=paths=source_relative:. $< + @protoc -I=..:. \ + --go-grpc_out=paths=source_relative:. \ + $< %_gorums.pb.go : %.proto - @protoc -I=..:. --gorums_out=paths=source_relative:. $< + @protoc -I=..:. \ + --gorums_out=paths=source_relative:. \ + $< clean: find . -name '*.pb.go' -exec rm {} \; diff --git a/tests/config/config.pb.go b/tests/config/config.pb.go index d6766dccf..845e635c9 100644 --- a/tests/config/config.pb.go +++ b/tests/config/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: config/config.proto package config @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -23,10 +22,10 @@ const ( ) type Request struct { - state protoimpl.MessageState `protogen:"open.v1"` - Num uint64 `protobuf:"varint,1,opt,name=Num" json:"Num,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Num uint64 `protobuf:"varint,1,opt,name=Num"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Request) Reset() { @@ -54,24 +53,37 @@ func (x *Request) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_config_config_proto_rawDescGZIP(), []int{0} -} - func (x *Request) GetNum() uint64 { if x != nil { - return x.Num + return x.xxx_hidden_Num } return 0 } +func (x *Request) SetNum(v uint64) { + x.xxx_hidden_Num = v +} + +type Request_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Num uint64 +} + +func (b0 Request_builder) Build() *Request { + m0 := &Request{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Num = b.Num + return m0 +} + type Response struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=Name" json:"Name,omitempty"` - Num uint64 `protobuf:"varint,2,opt,name=Num" json:"Num,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Name string `protobuf:"bytes,1,opt,name=Name"` + xxx_hidden_Num uint64 `protobuf:"varint,2,opt,name=Num"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Response) Reset() { @@ -99,25 +111,44 @@ func (x *Response) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_config_config_proto_rawDescGZIP(), []int{1} -} - func (x *Response) GetName() string { if x != nil { - return x.Name + return x.xxx_hidden_Name } return "" } func (x *Response) GetNum() uint64 { if x != nil { - return x.Num + return x.xxx_hidden_Num } return 0 } +func (x *Response) SetName(v string) { + x.xxx_hidden_Name = v +} + +func (x *Response) SetNum(v uint64) { + x.xxx_hidden_Num = v +} + +type Response_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Name string + Num uint64 +} + +func (b0 Response_builder) Build() *Response { + m0 := &Response{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Name = b.Name + x.xxx_hidden_Num = b.Num + return m0 +} + var File_config_config_proto protoreflect.FileDescriptor const file_config_config_proto_rawDesc = "" + @@ -132,18 +163,6 @@ const file_config_config_proto_rawDesc = "" + "ConfigTest\x121\n" + "\x06Config\x12\x0f.config.Request\x1a\x10.config.Response\"\x04\xa0\xb5\x18\x01B+Z$github.com/relab/gorums/tests/config\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var ( - file_config_config_proto_rawDescOnce sync.Once - file_config_config_proto_rawDescData []byte -) - -func file_config_config_proto_rawDescGZIP() []byte { - file_config_config_proto_rawDescOnce.Do(func() { - file_config_config_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_config_config_proto_rawDesc), len(file_config_config_proto_rawDesc))) - }) - return file_config_config_proto_rawDescData -} - var file_config_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_config_config_proto_goTypes = []any{ (*Request)(nil), // 0: config.Request diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index 310ff6949..413aaa387 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,17 +1,15 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: config/config.proto package config import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) const ( @@ -25,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -35,15 +32,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -100,30 +91,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -151,44 +125,22 @@ type Node struct { // ConfigTestClient is the client interface for the ConfigTest service. type ConfigTestClient interface { - Config(ctx context.Context, in *Request) (resp *Response, err error) + Config(ctx context.Context, in *Request) gorums.Iterator[*Response] } // enforce interface compliance var _ ConfigTestClient = (*Configuration)(nil) -// QuorumSpec is the interface of quorum functions for ConfigTest. -type QuorumSpec interface { - gorums.ConfigOption - - // ConfigQF is the quorum function for the Config - // quorum call method. The in parameter is the request object - // supplied to the Config method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - ConfigQF(in *Request, replies map[uint32]*Response) (*Response, bool) -} - // Config is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) Config(ctx context.Context, in *Request) (resp *Response, err error) { +// with the same argument in, and returns a combined result. test +func (c *Configuration) Config(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "config.ConfigTest.Config", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.ConfigQF(req.(*Request), r) + Message: in, + Method: "config.ConfigTest.Config", + ServerStream: false, } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Response), err + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // ConfigTest is the server-side API for the ConfigTest Service diff --git a/tests/config/config_test.go b/tests/config/config_test.go index 12a7cbfa9..7eb9cc8d0 100644 --- a/tests/config/config_test.go +++ b/tests/config/config_test.go @@ -2,6 +2,7 @@ package config import ( "context" + "errors" fmt "fmt" "testing" @@ -10,36 +11,15 @@ import ( "google.golang.org/grpc/credentials/insecure" ) -type ( - cfgSrv struct { - name string - } - cfgQSpec struct { - quorum int - } -) +type cfgSrv struct { + name string +} func (srv cfgSrv) Config(ctx gorums.ServerCtx, req *Request) (resp *Response, err error) { - return &Response{ + return Response_builder{ Name: srv.name, Num: req.GetNum(), - }, nil -} - -func newQSpec(cfgSize int) *cfgQSpec { - return &cfgQSpec{quorum: cfgSize/2 + 1} -} - -func (q cfgQSpec) ConfigQF(_ *Request, replies map[uint32]*Response) (*Response, bool) { - if len(replies) < q.quorum { - return nil, false - } - var reply *Response - for _, r := range replies { - reply = r - break - } - return reply, true + }.Build(), nil } // setup returns a new configuration of cfgSize and a corresponding teardown function. @@ -59,7 +39,7 @@ func setup(t *testing.T, mgr *Manager, cfgSize int) (cfg *Configuration, teardow for i := range srvs { srvs[i].name = addrs[i] } - cfg, err := mgr.NewConfiguration(newQSpec(cfgSize), gorums.WithNodeList(addrs)) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(addrs)) if err != nil { t.Fatal(err) } @@ -70,16 +50,30 @@ func setup(t *testing.T, mgr *Manager, cfgSize int) (cfg *Configuration, teardow return cfg, teardown } +func configQF(cfg *Configuration, req *Request) (*Response, error) { + quorum := cfg.Size()/2 + 1 + replies := int(0) + responses := cfg.Config(context.Background(), req) + for response := range responses { + msg, _, _ := response.Unpack() + replies++ + if replies >= quorum { + return msg, nil + } + } + return nil, errors.New("configQF: no quorum") +} + // TestConfig creates and combines multiple configurations and invokes the Config RPC // method on the different configurations created below. func TestConfig(t *testing.T) { callRPC := func(cfg *Configuration) { for i := range 5 { - resp, err := cfg.Config(context.Background(), &Request{Num: uint64(i)}) + reply, err := configQF(cfg, Request_builder{Num: uint64(i)}.Build()) if err != nil { t.Fatal(err) } - if resp == nil { + if reply == nil { t.Fatal("Got nil response") } } @@ -100,10 +94,7 @@ func TestConfig(t *testing.T) { callRPC(c2) newNodeList := c1.And(c2) - c3, err := mgr.NewConfiguration( - newQSpec(c1.Size()+c2.Size()), - newNodeList, - ) + c3, err := mgr.NewConfiguration(newNodeList) if err != nil { t.Fatal(err) } @@ -111,10 +102,7 @@ func TestConfig(t *testing.T) { callRPC(c3) rmNodeList := c3.Except(c1) - c4, err := mgr.NewConfiguration( - newQSpec(c2.Size()), - rmNodeList, - ) + c4, err := mgr.NewConfiguration(rmNodeList) if err != nil { t.Fatal(err) } diff --git a/tests/correctable/correctable.pb.go b/tests/correctable/correctable.pb.go index 79aebc46d..4c0057287 100644 --- a/tests/correctable/correctable.pb.go +++ b/tests/correctable/correctable.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: correctable/correctable.proto package correctable @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -23,7 +22,7 @@ const ( ) type CorrectableRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState `protogen:"opaque.v1"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -53,16 +52,23 @@ func (x *CorrectableRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CorrectableRequest.ProtoReflect.Descriptor instead. -func (*CorrectableRequest) Descriptor() ([]byte, []int) { - return file_correctable_correctable_proto_rawDescGZIP(), []int{0} +type CorrectableRequest_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 CorrectableRequest_builder) Build() *CorrectableRequest { + m0 := &CorrectableRequest{} + b, x := &b0, m0 + _, _ = b, x + return m0 } type CorrectableResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Level int32 `protobuf:"varint,1,opt,name=Level" json:"Level,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Level int32 `protobuf:"varint,1,opt,name=Level"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CorrectableResponse) Reset() { @@ -90,18 +96,31 @@ func (x *CorrectableResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CorrectableResponse.ProtoReflect.Descriptor instead. -func (*CorrectableResponse) Descriptor() ([]byte, []int) { - return file_correctable_correctable_proto_rawDescGZIP(), []int{1} -} - func (x *CorrectableResponse) GetLevel() int32 { if x != nil { - return x.Level + return x.xxx_hidden_Level } return 0 } +func (x *CorrectableResponse) SetLevel(v int32) { + x.xxx_hidden_Level = v +} + +type CorrectableResponse_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Level int32 +} + +func (b0 CorrectableResponse_builder) Build() *CorrectableResponse { + m0 := &CorrectableResponse{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Level = b.Level + return m0 +} + var File_correctable_correctable_proto protoreflect.FileDescriptor const file_correctable_correctable_proto_rawDesc = "" + @@ -111,20 +130,8 @@ const file_correctable_correctable_proto_rawDesc = "" + "\x13CorrectableResponse\x12\x14\n" + "\x05Level\x18\x01 \x01(\x05R\x05Level2\xc9\x01\n" + "\x0fCorrectableTest\x12V\n" + - "\vCorrectable\x12\x1f.correctable.CorrectableRequest\x1a .correctable.CorrectableResponse\"\x04\xa8\xb5\x18\x01\x12^\n" + - "\x11CorrectableStream\x12\x1f.correctable.CorrectableRequest\x1a .correctable.CorrectableResponse\"\x04\xa8\xb5\x18\x010\x01B0Z)github.com/relab/gorums/tests/correctable\x92\x03\x02\b\x02b\beditionsp\xe8\a" - -var ( - file_correctable_correctable_proto_rawDescOnce sync.Once - file_correctable_correctable_proto_rawDescData []byte -) - -func file_correctable_correctable_proto_rawDescGZIP() []byte { - file_correctable_correctable_proto_rawDescOnce.Do(func() { - file_correctable_correctable_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_correctable_correctable_proto_rawDesc), len(file_correctable_correctable_proto_rawDesc))) - }) - return file_correctable_correctable_proto_rawDescData -} + "\vCorrectable\x12\x1f.correctable.CorrectableRequest\x1a .correctable.CorrectableResponse\"\x04\xa0\xb5\x18\x01\x12^\n" + + "\x11CorrectableStream\x12\x1f.correctable.CorrectableRequest\x1a .correctable.CorrectableResponse\"\x04\xa0\xb5\x18\x010\x01B0Z)github.com/relab/gorums/tests/correctable\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_correctable_correctable_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_correctable_correctable_proto_goTypes = []any{ diff --git a/tests/correctable/correctable.proto b/tests/correctable/correctable.proto index 6bae791f7..edf8e1a6c 100644 --- a/tests/correctable/correctable.proto +++ b/tests/correctable/correctable.proto @@ -10,10 +10,10 @@ import "gorums.proto"; service CorrectableTest { rpc Correctable(CorrectableRequest) returns (CorrectableResponse) { - option (gorums.correctable) = true; + option (gorums.quorumcall) = true; } rpc CorrectableStream(CorrectableRequest) returns (stream CorrectableResponse) { - option (gorums.correctable) = true; + option (gorums.quorumcall) = true; } } diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 28a68324b..5d81423ff 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,19 +1,17 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: correctable/correctable.proto package correctable import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" ordering "github.com/relab/gorums/ordering" encoding "google.golang.org/grpc/encoding" proto "google.golang.org/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) const ( @@ -27,7 +25,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -37,15 +34,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -102,30 +93,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -153,73 +127,36 @@ type Node struct { // CorrectableTestClient is the client interface for the CorrectableTest service. type CorrectableTestClient interface { - Correctable(ctx context.Context, in *CorrectableRequest) *CorrectableCorrectableResponse - CorrectableStream(ctx context.Context, in *CorrectableRequest) *CorrectableStreamCorrectableResponse + Correctable(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] + + CorrectableStream(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] } // enforce interface compliance var _ CorrectableTestClient = (*Configuration)(nil) -// Correctable asynchronously invokes a correctable quorum call on each node -// in configuration c and returns a CorrectableCorrectableResponse, which can be used -// to inspect any replies or errors when available. -func (c *Configuration) Correctable(ctx context.Context, in *CorrectableRequest) *CorrectableCorrectableResponse { - cd := gorums.CorrectableCallData{ +// Correctable is a quorum call invoked on all nodes in configuration c, +// with the same argument in, and returns a combined result. test +func (c *Configuration) Correctable(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] { + cd := gorums.QuorumCallData{ Message: in, Method: "correctable.CorrectableTest.Correctable", ServerStream: false, } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*CorrectableResponse, len(replies)) - for k, v := range replies { - r[k] = v.(*CorrectableResponse) - } - return c.qspec.CorrectableQF(req.(*CorrectableRequest), r) - } - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableCorrectableResponse{corr} + return gorums.QuorumCall[*CorrectableResponse](ctx, c.RawConfiguration, cd) } -// CorrectableStream asynchronously invokes a correctable quorum call on each node -// in configuration c and returns a CorrectableStreamCorrectableResponse, which can be used -// to inspect any replies or errors when available. -// This method supports server-side preliminary replies (correctable stream). -func (c *Configuration) CorrectableStream(ctx context.Context, in *CorrectableRequest) *CorrectableStreamCorrectableResponse { - cd := gorums.CorrectableCallData{ +// CorrectableStream is a quorum call invoked on all nodes in configuration c, +// with the same argument in, and returns a combined result. test +func (c *Configuration) CorrectableStream(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] { + cd := gorums.QuorumCallData{ Message: in, Method: "correctable.CorrectableTest.CorrectableStream", ServerStream: true, } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, int, bool) { - r := make(map[uint32]*CorrectableResponse, len(replies)) - for k, v := range replies { - r[k] = v.(*CorrectableResponse) - } - return c.qspec.CorrectableStreamQF(req.(*CorrectableRequest), r) - } - corr := c.RawConfiguration.CorrectableCall(ctx, cd) - return &CorrectableStreamCorrectableResponse{corr} -} - -// QuorumSpec is the interface of quorum functions for CorrectableTest. -type QuorumSpec interface { - gorums.ConfigOption - - // CorrectableQF is the quorum function for the Correctable - // correctable quorum call method. The in parameter is the request object - // supplied to the Correctable method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *CorrectableRequest'. - CorrectableQF(in *CorrectableRequest, replies map[uint32]*CorrectableResponse) (*CorrectableResponse, int, bool) - - // CorrectableStreamQF is the quorum function for the CorrectableStream - // correctable stream quorum call method. The in parameter is the request object - // supplied to the CorrectableStream method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *CorrectableRequest'. - CorrectableStreamQF(in *CorrectableRequest, replies map[uint32]*CorrectableResponse) (*CorrectableResponse, int, bool) + return gorums.QuorumCall[*CorrectableResponse](ctx, c.RawConfiguration, cd) } // CorrectableTest is the server-side API for the CorrectableTest Service @@ -254,39 +191,3 @@ type internalCorrectableResponse struct { reply *CorrectableResponse err error } - -// CorrectableCorrectableResponse is a correctable object for processing replies. -type CorrectableCorrectableResponse struct { - *gorums.Correctable -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *CorrectableCorrectableResponse) Get() (*CorrectableResponse, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*CorrectableResponse), level, err -} - -// CorrectableStreamCorrectableResponse is a correctable object for processing replies. -type CorrectableStreamCorrectableResponse struct { - *gorums.Correctable -} - -// Get returns the reply, level and any error associated with the -// called method. The method does not block until a (possibly -// intermediate) reply or error is available. Level is set to LevelNotSet if no -// reply has yet been received. The Done or Watch methods should be used to -// ensure that a reply is available. -func (c *CorrectableStreamCorrectableResponse) Get() (*CorrectableResponse, int, error) { - resp, level, err := c.Correctable.Get() - if err != nil { - return nil, level, err - } - return resp.(*CorrectableResponse), level, err -} diff --git a/tests/correctable/correctable_test.go b/tests/correctable/correctable_test.go index 711a5bc82..309689f2e 100644 --- a/tests/correctable/correctable_test.go +++ b/tests/correctable/correctable_test.go @@ -2,6 +2,7 @@ package correctable import ( "context" + "iter" "testing" "time" @@ -14,7 +15,7 @@ import ( // n is the number of replicas, and div is a divider. // the target level is n, and the level is calculated by the quorum function // by dividing the sum of levels from the servers with the divider. -func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration) *gorums.Correctable) { +func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration, int, int) *gorums.Correctable[int]) { addrs, teardown := gorums.TestSetup(t, n, func(i int) gorums.ServerIface { gorumsSrv := gorums.NewServer() RegisterCorrectableTestServer(gorumsSrv, &testSrv{n}) @@ -28,14 +29,14 @@ func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration ), ) - cfg, err := mgr.NewConfiguration(qspec{div, n}, gorums.WithNodeList(addrs)) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(addrs)) if err != nil { t.Fatal(err) } ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) defer cancel() - res := corr(ctx, cfg) + res := corr(ctx, cfg, n, div) donech := res.Done() @@ -54,17 +55,37 @@ func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration } } +func qcorr(responses gorums.Iterator[*CorrectableResponse], q qspec) iter.Seq2[int, int] { + return func(yield func(int, int) bool) { + sum := 0 + for response := range responses { + reply, err, _ := response.Unpack() + if err != nil { + continue + } + sum += int(reply.GetLevel()) + level := sum / q.div + if !yield(level, level) { + return + } + if level >= q.doneLevel { + return + } + } + } +} + func TestCorrectable(t *testing.T) { - run(t, 4, 1, func(ctx context.Context, c *Configuration) *gorums.Correctable { + run(t, 4, 1, func(ctx context.Context, c *Configuration, n int, div int) *gorums.Correctable[int] { corr := c.Correctable(ctx, &CorrectableRequest{}) - return corr.Correctable + return gorums.IterToCorrectable(corr, qspec{div, n}, qcorr) }) } func TestCorrectableStream(t *testing.T) { - run(t, 4, 4, func(ctx context.Context, c *Configuration) *gorums.Correctable { + run(t, 4, 4, func(ctx context.Context, c *Configuration, n int, div int) *gorums.Correctable[int] { corr := c.CorrectableStream(ctx, &CorrectableRequest{}) - return corr.Correctable + return gorums.IterToCorrectable(corr, qspec{div, n}, qcorr) }) } @@ -73,40 +94,13 @@ type qspec struct { doneLevel int } -func (q qspec) q(replies map[uint32]*CorrectableResponse) (*CorrectableResponse, int, bool) { - sum := 0 - for _, reply := range replies { - sum += int(reply.Level) - } - level := sum / q.div - return &CorrectableResponse{Level: int32(level)}, level, level >= q.doneLevel -} - -// CorrectableStreamQF is the quorum function for the CorrectableStream -// correctable stream quorum call method. The in parameter is the request object -// supplied to the CorrectableStream method at call time, and may or may not -// be used by the quorum function. If the in parameter is not needed -// you should implement your quorum function with '_ *CorrectableRequest'. -func (q qspec) CorrectableStreamQF(_ *CorrectableRequest, replies map[uint32]*CorrectableResponse) (*CorrectableResponse, int, bool) { - return q.q(replies) -} - -// CorrectableQF is the quorum function for the Correctable -// correctable quorum call method. The in parameter is the request object -// supplied to the Correctable method at call time, and may or may not -// be used by the quorum function. If the in parameter is not needed -// you should implement your quorum function with '_ *CorrectableRequest'. -func (q qspec) CorrectableQF(_ *CorrectableRequest, replies map[uint32]*CorrectableResponse) (*CorrectableResponse, int, bool) { - return q.q(replies) -} - type testSrv struct { n int } func (srv testSrv) CorrectableStream(_ gorums.ServerCtx, request *CorrectableRequest, send func(response *CorrectableResponse) error) error { for i := range srv.n { - err := send(&CorrectableResponse{Level: int32(i + 1)}) + err := send(CorrectableResponse_builder{Level: int32(i + 1)}.Build()) if err != nil { return err } @@ -115,5 +109,5 @@ func (srv testSrv) CorrectableStream(_ gorums.ServerCtx, request *CorrectableReq } func (srv testSrv) Correctable(_ gorums.ServerCtx, request *CorrectableRequest) (response *CorrectableResponse, err error) { - return &CorrectableResponse{Level: 1}, nil + return CorrectableResponse_builder{Level: 1}.Build(), nil } diff --git a/tests/dummy/dummy.pb.go b/tests/dummy/dummy.pb.go index 5be06a6b1..ef88427fa 100644 --- a/tests/dummy/dummy.pb.go +++ b/tests/dummy/dummy.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: dummy/dummy.proto package dummy @@ -10,7 +10,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -22,7 +21,7 @@ const ( ) type Empty struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState `protogen:"opaque.v1"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -52,9 +51,16 @@ func (x *Empty) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Empty.ProtoReflect.Descriptor instead. -func (*Empty) Descriptor() ([]byte, []int) { - return file_dummy_dummy_proto_rawDescGZIP(), []int{0} +type Empty_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 Empty_builder) Build() *Empty { + m0 := &Empty{} + b, x := &b0, m0 + _, _ = b, x + return m0 } var File_dummy_dummy_proto protoreflect.FileDescriptor @@ -66,18 +72,6 @@ const file_dummy_dummy_proto_rawDesc = "" + "\x05Dummy\x12$\n" + "\x04Test\x12\f.dummy.Empty\x1a\f.dummy.Empty\"\x00B*Z#github.com/relab/gorums/tests/dummy\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var ( - file_dummy_dummy_proto_rawDescOnce sync.Once - file_dummy_dummy_proto_rawDescData []byte -) - -func file_dummy_dummy_proto_rawDescGZIP() []byte { - file_dummy_dummy_proto_rawDescOnce.Do(func() { - file_dummy_dummy_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_dummy_dummy_proto_rawDesc), len(file_dummy_dummy_proto_rawDesc))) - }) - return file_dummy_dummy_proto_rawDescData -} - var file_dummy_dummy_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_dummy_dummy_proto_goTypes = []any{ (*Empty)(nil), // 0: dummy.Empty diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index a5781f483..59d7fbb0d 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,14 +1,13 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: dummy/dummy.proto package dummy import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" ) @@ -24,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -34,15 +32,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -99,30 +91,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -156,11 +131,8 @@ type DummyNodeClient interface { // enforce interface compliance var _ DummyNodeClient = (*Node)(nil) -// There are no quorum calls. -type QuorumSpec interface{} - // Test is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (n *Node) Test(ctx context.Context, in *Empty) (resp *Empty, err error) { cd := gorums.CallData{ Message: in, diff --git a/tests/metadata/metadata.pb.go b/tests/metadata/metadata.pb.go index c3e70384f..d86b93e57 100644 --- a/tests/metadata/metadata.pb.go +++ b/tests/metadata/metadata.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: metadata/metadata.proto package metadata @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -23,8 +22,8 @@ const ( ) type NodeID struct { - state protoimpl.MessageState `protogen:"open.v1"` - ID uint32 `protobuf:"varint,1,opt,name=ID" json:"ID,omitempty"` + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_ID uint32 `protobuf:"varint,1,opt,name=ID"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -54,23 +53,36 @@ func (x *NodeID) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use NodeID.ProtoReflect.Descriptor instead. -func (*NodeID) Descriptor() ([]byte, []int) { - return file_metadata_metadata_proto_rawDescGZIP(), []int{0} -} - func (x *NodeID) GetID() uint32 { if x != nil { - return x.ID + return x.xxx_hidden_ID } return 0 } +func (x *NodeID) SetID(v uint32) { + x.xxx_hidden_ID = v +} + +type NodeID_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + ID uint32 +} + +func (b0 NodeID_builder) Build() *NodeID { + m0 := &NodeID{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_ID = b.ID + return m0 +} + type IPAddr struct { - state protoimpl.MessageState `protogen:"open.v1"` - Addr string `protobuf:"bytes,1,opt,name=Addr" json:"Addr,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Addr string `protobuf:"bytes,1,opt,name=Addr"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *IPAddr) Reset() { @@ -98,18 +110,31 @@ func (x *IPAddr) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use IPAddr.ProtoReflect.Descriptor instead. -func (*IPAddr) Descriptor() ([]byte, []int) { - return file_metadata_metadata_proto_rawDescGZIP(), []int{1} -} - func (x *IPAddr) GetAddr() string { if x != nil { - return x.Addr + return x.xxx_hidden_Addr } return "" } +func (x *IPAddr) SetAddr(v string) { + x.xxx_hidden_Addr = v +} + +type IPAddr_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Addr string +} + +func (b0 IPAddr_builder) Build() *IPAddr { + m0 := &IPAddr{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Addr = b.Addr + return m0 +} + var File_metadata_metadata_proto protoreflect.FileDescriptor const file_metadata_metadata_proto_rawDesc = "" + @@ -123,18 +148,6 @@ const file_metadata_metadata_proto_rawDesc = "" + "\bIDFromMD\x12\x16.google.protobuf.Empty\x1a\x10.metadata.NodeID\"\x00\x124\n" + "\x06WhatIP\x12\x16.google.protobuf.Empty\x1a\x10.metadata.IPAddr\"\x00B-Z&github.com/relab/gorums/tests/metadata\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var ( - file_metadata_metadata_proto_rawDescOnce sync.Once - file_metadata_metadata_proto_rawDescData []byte -) - -func file_metadata_metadata_proto_rawDescGZIP() []byte { - file_metadata_metadata_proto_rawDescOnce.Do(func() { - file_metadata_metadata_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_metadata_metadata_proto_rawDesc), len(file_metadata_metadata_proto_rawDesc))) - }) - return file_metadata_metadata_proto_rawDescData -} - var file_metadata_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_metadata_metadata_proto_goTypes = []any{ (*NodeID)(nil), // 0: metadata.NodeID diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index abb677f25..a2bc5132e 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,14 +1,13 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: metadata/metadata.proto package metadata import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" emptypb "google.golang.org/protobuf/types/known/emptypb" @@ -25,7 +24,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -35,15 +33,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -100,30 +92,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -158,9 +133,6 @@ type MetadataTestNodeClient interface { // enforce interface compliance var _ MetadataTestNodeClient = (*Node)(nil) -// There are no quorum calls. -type QuorumSpec interface{} - // IDFromMD returns the 'id' field from the metadata. func (n *Node) IDFromMD(ctx context.Context, in *emptypb.Empty) (resp *NodeID, err error) { cd := gorums.CallData{ diff --git a/tests/metadata/metadata_test.go b/tests/metadata/metadata_test.go index a92cb7590..dde393456 100644 --- a/tests/metadata/metadata_test.go +++ b/tests/metadata/metadata_test.go @@ -31,7 +31,7 @@ func (srv testSrv) IDFromMD(ctx gorums.ServerCtx, _ *emptypb.Empty) (resp *NodeI if err != nil { return nil, status.Errorf(codes.InvalidArgument, "value of id field: %q is not a number: %v", v[0], err) } - return &NodeID{ID: uint32(id)}, nil + return NodeID_builder{ID: uint32(id)}.Build(), nil } func (srv testSrv) WhatIP(ctx gorums.ServerCtx, _ *emptypb.Empty) (resp *IPAddr, err error) { @@ -39,7 +39,7 @@ func (srv testSrv) WhatIP(ctx gorums.ServerCtx, _ *emptypb.Empty) (resp *IPAddr, if !ok { return nil, status.Error(codes.NotFound, "Peer info unavailable") } - return &IPAddr{Addr: peerInfo.Addr.String()}, nil + return IPAddr_builder{Addr: peerInfo.Addr.String()}.Build(), nil } func initServer() *gorums.Server { diff --git a/tests/oneway/oneway.pb.go b/tests/oneway/oneway.pb.go index f47ec4f5b..b9b6544b8 100644 --- a/tests/oneway/oneway.pb.go +++ b/tests/oneway/oneway.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: oneway/oneway.proto package oneway @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -23,10 +22,10 @@ const ( ) type Request struct { - state protoimpl.MessageState `protogen:"open.v1"` - Num uint64 `protobuf:"varint,1,opt,name=Num" json:"Num,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Num uint64 `protobuf:"varint,1,opt,name=Num"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Request) Reset() { @@ -54,20 +53,33 @@ func (x *Request) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_oneway_oneway_proto_rawDescGZIP(), []int{0} -} - func (x *Request) GetNum() uint64 { if x != nil { - return x.Num + return x.xxx_hidden_Num } return 0 } +func (x *Request) SetNum(v uint64) { + x.xxx_hidden_Num = v +} + +type Request_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Num uint64 +} + +func (b0 Request_builder) Build() *Request { + m0 := &Request{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Num = b.Num + return m0 +} + type Empty struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState `protogen:"opaque.v1"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -97,9 +109,16 @@ func (x *Empty) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Empty.ProtoReflect.Descriptor instead. -func (*Empty) Descriptor() ([]byte, []int) { - return file_oneway_oneway_proto_rawDescGZIP(), []int{1} +type Empty_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 Empty_builder) Build() *Empty { + m0 := &Empty{} + b, x := &b0, m0 + _, _ = b, x + return m0 } var File_oneway_oneway_proto protoreflect.FileDescriptor @@ -116,18 +135,6 @@ const file_oneway_oneway_proto_rawDesc = "" + "\tMulticast\x12\x0f.oneway.Request\x1a\r.oneway.Empty\"\x04\x98\xb5\x18\x01\x12<\n" + "\x10MulticastPerNode\x12\x0f.oneway.Request\x1a\r.oneway.Empty\"\b\x98\xb5\x18\x01\xa0\xb6\x18\x01B+Z$github.com/relab/gorums/tests/oneway\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var ( - file_oneway_oneway_proto_rawDescOnce sync.Once - file_oneway_oneway_proto_rawDescData []byte -) - -func file_oneway_oneway_proto_rawDescGZIP() []byte { - file_oneway_oneway_proto_rawDescOnce.Do(func() { - file_oneway_oneway_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_oneway_oneway_proto_rawDesc), len(file_oneway_oneway_proto_rawDesc))) - }) - return file_oneway_oneway_proto_rawDescData -} - var file_oneway_oneway_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_oneway_oneway_proto_goTypes = []any{ (*Request)(nil), // 0: oneway.Request diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index 2c8ed6925..78741550c 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,17 +1,16 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: oneway/oneway.proto package oneway import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" + proto "google.golang.org/protobuf/proto" ) const ( @@ -25,7 +24,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -35,15 +33,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -100,30 +92,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -167,7 +142,7 @@ type OnewayTestNodeClient interface { var _ OnewayTestNodeClient = (*Node)(nil) // Multicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (c *Configuration) Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, @@ -188,16 +163,13 @@ func (c *Configuration) MulticastPerNode(ctx context.Context, in *Request, f fun Method: "oneway.OnewayTest.MulticastPerNode", } - cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { + cd.PerNodeArgFn = func(req proto.Message, nid uint32) proto.Message { return f(req.(*Request), nid) } c.RawConfiguration.Multicast(ctx, cd, opts...) } -// There are no quorum calls. -type QuorumSpec interface{} - // OnewayTest is the server-side API for the OnewayTest Service type OnewayTestServer interface { Unicast(ctx gorums.ServerCtx, request *Request) @@ -224,7 +196,7 @@ func RegisterOnewayTestServer(srv *gorums.Server, impl OnewayTestServer) { } // Unicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (n *Node) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, diff --git a/tests/oneway/oneway_test.go b/tests/oneway/oneway_test.go index a66432a4e..229d83208 100644 --- a/tests/oneway/oneway_test.go +++ b/tests/oneway/oneway_test.go @@ -42,8 +42,6 @@ func (s *onewaySrv) MulticastPerNode(ctx gorums.ServerCtx, r *oneway.Request) { s.wg.Done() } -type testQSpec struct{} - func setup(t testing.TB, cfgSize int) (cfg *oneway.Configuration, srvs []*onewaySrv, teardown func()) { t.Helper() srvs = make([]*onewaySrv, cfgSize) @@ -66,7 +64,7 @@ func setup(t testing.TB, cfgSize int) (cfg *oneway.Configuration, srvs []*oneway grpc.WithTransportCredentials(insecure.NewCredentials()), ), ) - cfg, err := mgr.NewConfiguration(&testQSpec{}, gorums.WithNodeMap(nodeMap)) + cfg, err := mgr.NewConfiguration(gorums.WithNodeMap(nodeMap)) if err != nil { t.Fatal(err) } @@ -111,7 +109,7 @@ func TestOnewayCalls(t *testing.T) { } for c := 1; c <= test.calls; c++ { - in := &oneway.Request{Num: uint64(c)} + in := oneway.Request_builder{Num: uint64(c)}.Build() if test.sendWait { f(cfg)(context.Background(), in) } else { @@ -125,8 +123,8 @@ func TestOnewayCalls(t *testing.T) { close(srvs[i].received) expected := uint64(1) for r := range srvs[i].received { - if expected != r.Num { - t.Errorf("%s(%d) = %d, expected %d", test.name, expected, r.Num, expected) + if expected != r.GetNum() { + t.Errorf("%s(%d) = %d, expected %d", test.name, expected, r.GetNum(), expected) } expected++ } @@ -141,7 +139,7 @@ func TestMulticastPerNode(t *testing.T) { // simple transformation function f := func(msg *oneway.Request, id uint32) *oneway.Request { - return &oneway.Request{Num: add(msg.Num, id)} + return oneway.Request_builder{Num: add(msg.GetNum(), id)}.Build() } ignoreNodes := []int{} ignore := func(id uint32) bool { @@ -155,7 +153,7 @@ func TestMulticastPerNode(t *testing.T) { if ignore(id) { return nil } - return &oneway.Request{Num: add(msg.Num, id)} + return oneway.Request_builder{Num: add(msg.GetNum(), id)}.Build() } tests := []struct { name string @@ -196,7 +194,7 @@ func TestMulticastPerNode(t *testing.T) { } for c := 1; c <= test.calls; c++ { - in := &oneway.Request{Num: uint64(c)} + in := oneway.Request_builder{Num: uint64(c)}.Build() if test.sendWait { cfg.MulticastPerNode(context.Background(), in, test.f) } else { @@ -213,8 +211,8 @@ func TestMulticastPerNode(t *testing.T) { srvs[i].wg.Wait() close(srvs[i].received) for r := range srvs[i].received { - if expected != r.Num { - t.Errorf("%s -> %d, expected %d, nodeID=%d, ignore=%t", test.name, r.Num, expected, nodeIDs[i], ignore(nodeIDs[i])) + if expected != r.GetNum() { + t.Errorf("%s -> %d, expected %d, nodeID=%d, ignore=%t", test.name, r.GetNum(), expected, nodeIDs[i], ignore(nodeIDs[i])) } expected++ } @@ -230,16 +228,16 @@ func BenchmarkUnicast(b *testing.B) { srv.benchmark = true } node := cfg.Nodes()[0] - in := &oneway.Request{Num: 0} + in := oneway.Request_builder{Num: 0}.Build() b.Run("UnicastSendWaiting__", func(b *testing.B) { for c := 1; c <= b.N; c++ { - in.Num = uint64(c) + in.SetNum(uint64(c)) node.Unicast(context.Background(), in) } }) b.Run("UnicastNoSendWaiting", func(b *testing.B) { for c := 1; c <= b.N; c++ { - in.Num = uint64(c) + in.SetNum(uint64(c)) node.Unicast(context.Background(), in, gorums.WithNoSendWaiting()) } }) @@ -251,16 +249,16 @@ func BenchmarkMulticast(b *testing.B) { for _, srv := range srvs { srv.benchmark = true } - in := &oneway.Request{Num: 0} + in := oneway.Request_builder{Num: 0}.Build() b.Run("MulticastSendWaiting__", func(b *testing.B) { for c := 1; c <= b.N; c++ { - in.Num = uint64(c) + in.SetNum(uint64(c)) cfg.Multicast(context.Background(), in) } }) b.Run("MulticastNoSendWaiting", func(b *testing.B) { for c := 1; c <= b.N; c++ { - in.Num = uint64(c) + in.SetNum(uint64(c)) cfg.Multicast(context.Background(), in, gorums.WithNoSendWaiting()) } }) diff --git a/tests/ordering/order.pb.go b/tests/ordering/order.pb.go index 01dcd4884..c766ab6da 100644 --- a/tests/ordering/order.pb.go +++ b/tests/ordering/order.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: ordering/order.proto package ordering @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -23,10 +22,10 @@ const ( ) type Request struct { - state protoimpl.MessageState `protogen:"open.v1"` - Num uint64 `protobuf:"varint,1,opt,name=Num" json:"Num,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Num uint64 `protobuf:"varint,1,opt,name=Num"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Request) Reset() { @@ -54,23 +53,36 @@ func (x *Request) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_ordering_order_proto_rawDescGZIP(), []int{0} -} - func (x *Request) GetNum() uint64 { if x != nil { - return x.Num + return x.xxx_hidden_Num } return 0 } +func (x *Request) SetNum(v uint64) { + x.xxx_hidden_Num = v +} + +type Request_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Num uint64 +} + +func (b0 Request_builder) Build() *Request { + m0 := &Request{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Num = b.Num + return m0 +} + type Response struct { - state protoimpl.MessageState `protogen:"open.v1"` - InOrder bool `protobuf:"varint,1,opt,name=InOrder" json:"InOrder,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_InOrder bool `protobuf:"varint,1,opt,name=InOrder"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Response) Reset() { @@ -98,18 +110,31 @@ func (x *Response) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_ordering_order_proto_rawDescGZIP(), []int{1} -} - func (x *Response) GetInOrder() bool { if x != nil { - return x.InOrder + return x.xxx_hidden_InOrder } return false } +func (x *Response) SetInOrder(v bool) { + x.xxx_hidden_InOrder = v +} + +type Response_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + InOrder bool +} + +func (b0 Response_builder) Build() *Response { + m0 := &Response{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_InOrder = b.InOrder + return m0 +} + var File_ordering_order_proto protoreflect.FileDescriptor const file_ordering_order_proto_rawDesc = "" + @@ -118,25 +143,13 @@ const file_ordering_order_proto_rawDesc = "" + "\aRequest\x12\x10\n" + "\x03Num\x18\x01 \x01(\x04R\x03Num\"$\n" + "\bResponse\x12\x18\n" + - "\aInOrder\x18\x01 \x01(\bR\aInOrder2\xb0\x01\n" + + "\aInOrder\x18\x01 \x01(\bR\aInOrder2\xac\x01\n" + "\n" + "GorumsTest\x121\n" + - "\x02QC\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x04\xa0\xb5\x18\x01\x12:\n" + - "\aQCAsync\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\b\xa0\xb5\x18\x01ะต\x18\x01\x123\n" + + "\x02QC\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x04\xa0\xb5\x18\x01\x126\n" + + "\aQCAsync\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x04\xa0\xb5\x18\x01\x123\n" + "\bUnaryRPC\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x00B-Z&github.com/relab/gorums/tests/ordering\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var ( - file_ordering_order_proto_rawDescOnce sync.Once - file_ordering_order_proto_rawDescData []byte -) - -func file_ordering_order_proto_rawDescGZIP() []byte { - file_ordering_order_proto_rawDescOnce.Do(func() { - file_ordering_order_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_ordering_order_proto_rawDesc), len(file_ordering_order_proto_rawDesc))) - }) - return file_ordering_order_proto_rawDescData -} - var file_ordering_order_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_ordering_order_proto_goTypes = []any{ (*Request)(nil), // 0: ordering.Request diff --git a/tests/ordering/order.proto b/tests/ordering/order.proto index b22c6542d..1760cd1ce 100644 --- a/tests/ordering/order.proto +++ b/tests/ordering/order.proto @@ -14,7 +14,6 @@ service GorumsTest { rpc QCAsync(Request) returns (Response) { option (gorums.quorumcall) = true; - option (gorums.async) = true; } rpc UnaryRPC(Request) returns (Response) {} diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index f5b9dfe20..ff4ff2e64 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,17 +1,15 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: ordering/order.proto package ordering import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) const ( @@ -25,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -35,15 +32,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -100,30 +91,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -149,30 +123,11 @@ type Node struct { *gorums.RawNode } -// QCAsync asynchronously invokes a quorum call on configuration c -// and returns a AsyncResponse, which can be used to inspect the quorum call -// reply and error when available. -func (c *Configuration) QCAsync(ctx context.Context, in *Request) *AsyncResponse { - cd := gorums.QuorumCallData{ - Message: in, - Method: "ordering.GorumsTest.QCAsync", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QCAsyncQF(req.(*Request), r) - } - - fut := c.RawConfiguration.AsyncCall(ctx, cd) - return &AsyncResponse{fut} -} - // GorumsTestClient is the client interface for the GorumsTest service. type GorumsTestClient interface { - QC(ctx context.Context, in *Request) (resp *Response, err error) - QCAsync(ctx context.Context, in *Request) *AsyncResponse + QC(ctx context.Context, in *Request) gorums.Iterator[*Response] + + QCAsync(ctx context.Context, in *Request) gorums.Iterator[*Response] } // enforce interface compliance @@ -186,49 +141,32 @@ type GorumsTestNodeClient interface { // enforce interface compliance var _ GorumsTestNodeClient = (*Node)(nil) -// QuorumSpec is the interface of quorum functions for GorumsTest. -type QuorumSpec interface { - gorums.ConfigOption - - // QCQF is the quorum function for the QC - // quorum call method. The in parameter is the request object - // supplied to the QC method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QCQF(in *Request, replies map[uint32]*Response) (*Response, bool) +// QC is a quorum call invoked on all nodes in configuration c, +// with the same argument in, and returns a combined result. test +func (c *Configuration) QC(ctx context.Context, in *Request) gorums.Iterator[*Response] { + cd := gorums.QuorumCallData{ + Message: in, + Method: "ordering.GorumsTest.QC", + ServerStream: false, + } - // QCAsyncQF is the quorum function for the QCAsync - // asynchronous quorum call method. The in parameter is the request object - // supplied to the QCAsync method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - QCAsyncQF(in *Request, replies map[uint32]*Response) (*Response, bool) + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } -// QC is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) QC(ctx context.Context, in *Request) (resp *Response, err error) { +// QCAsync is a quorum call invoked on all nodes in configuration c, +// with the same argument in, and returns a combined result. test +func (c *Configuration) QCAsync(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "ordering.GorumsTest.QC", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.QCQF(req.(*Request), r) + Message: in, + Method: "ordering.GorumsTest.QCAsync", + ServerStream: false, } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Response), err + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // UnaryRPC is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (n *Node) UnaryRPC(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.CallData{ Message: in, @@ -275,18 +213,3 @@ type internalResponse struct { reply *Response err error } - -// AsyncResponse is a async object for processing replies. -type AsyncResponse struct { - *gorums.Async -} - -// Get returns the reply and any error associated with the called method. -// The method blocks until a reply or error is available. -func (f *AsyncResponse) Get() (*Response, error) { - resp, err := f.Async.Get() - if err != nil { - return nil, err - } - return resp.(*Response), err -} diff --git a/tests/ordering/order_test.go b/tests/ordering/order_test.go index d47a0b2f1..4c554b03c 100644 --- a/tests/ordering/order_test.go +++ b/tests/ordering/order_test.go @@ -29,54 +29,53 @@ func (s *testSrv) isInOrder(num uint64) bool { } func (s *testSrv) QC(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { - return &Response{ + return Response_builder{ InOrder: s.isInOrder(req.GetNum()), - }, nil + }.Build(), nil } func (s *testSrv) QCAsync(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { - return &Response{ + return Response_builder{ InOrder: s.isInOrder(req.GetNum()), - }, nil + }.Build(), nil } func (s *testSrv) UnaryRPC(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { - return &Response{ + return Response_builder{ InOrder: s.isInOrder(req.GetNum()), - }, nil + }.Build(), nil } -type testQSpec struct { - quorum int -} +func qfiter(ctx context.Context, responses gorums.Iterator[*Response], quorum int) (*Response, error) { + replyCount := 0 + var orderMsg *Response + var firstMsg *Response + for response := range responses { + msg, err, _ := response.Unpack() + if err != nil { + return nil, err + } + replyCount++ + if firstMsg == nil { + firstMsg = msg + } + if orderMsg == nil && !msg.GetInOrder() { + orderMsg = msg + } -func (q testQSpec) qf(replies map[uint32]*Response) (*Response, bool) { - if len(replies) < q.quorum { - return nil, false - } - for _, reply := range replies { - if !reply.InOrder { - return reply, true + if replyCount < quorum { + continue + } + if orderMsg != nil { + return orderMsg, nil } + return firstMsg, nil } - var reply *Response - for _, r := range replies { - reply = r - break + err := ctx.Err() + if err != nil { + return nil, err } - return reply, true -} - -func (q testQSpec) QCQF(_ *Request, replies map[uint32]*Response) (*Response, bool) { - return q.qf(replies) -} - -func (q testQSpec) QCAsyncQF(_ *Request, replies map[uint32]*Response) (*Response, bool) { - return q.qf(replies) -} - -func (q testQSpec) AsyncHandlerQF(_ *Request, replies map[uint32]*Response) (*Response, bool) { - return q.qf(replies) + return nil, errors.New("qfiter: quorum not found") } func setup(t *testing.T, cfgSize int) (cfg *Configuration, teardown func()) { @@ -91,7 +90,7 @@ func setup(t *testing.T, cfgSize int) (cfg *Configuration, teardown func()) { grpc.WithTransportCredentials(insecure.NewCredentials()), ), ) - cfg, err := mgr.NewConfiguration(&testQSpec{cfgSize}, gorums.WithNodeList(addrs)) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(addrs)) if err != nil { t.Fatal(err) } @@ -112,7 +111,7 @@ func TestUnaryRPCOrdering(t *testing.T) { i := 1 for time.Now().Before(stopTime) { i++ - resp, err := node.UnaryRPC(context.Background(), &Request{Num: uint64(i)}) + resp, err := node.UnaryRPC(context.Background(), Request_builder{Num: uint64(i)}.Build()) if err != nil { t.Fatalf("RPC error: %v", err) } @@ -134,7 +133,9 @@ func TestQCOrdering(t *testing.T) { i := 1 for time.Now().Before(stopTime) { i++ - resp, err := cfg.QC(context.Background(), &Request{Num: uint64(i)}) + ctx := context.Background() + req := Request_builder{Num: uint64(i)}.Build() + resp, err := qfiter(ctx, cfg.QC(ctx, req), 4) if err != nil { t.Fatalf("QC error: %v", err) } @@ -158,11 +159,11 @@ func TestQCAsyncOrdering(t *testing.T) { i := 1 for time.Now().Before(stopTime) { i++ - promise := cfg.QCAsync(ctx, &Request{Num: uint64(i)}) + responses := cfg.QCAsync(ctx, Request_builder{Num: uint64(i)}.Build()) wg.Add(1) - go func(promise *AsyncResponse) { + go func(responses gorums.Iterator[*Response]) { defer wg.Done() - resp, err := promise.Get() + resp, err := qfiter(ctx, responses, 4) if err != nil { if errors.Is(err, context.Canceled) { return @@ -175,7 +176,7 @@ func TestQCAsyncOrdering(t *testing.T) { if !resp.GetInOrder() && !t.Failed() { t.Errorf("Message received out of order.") } - }(promise) + }(responses) } wg.Wait() cancel() @@ -190,7 +191,9 @@ func TestMixedOrdering(t *testing.T) { stopTime := time.Now().Add(5 * time.Second) i := 1 for time.Now().Before(stopTime) { - resp, err := cfg.QC(context.Background(), &Request{Num: uint64(i)}) + req := Request_builder{Num: uint64(i)}.Build() + ctx := context.Background() + resp, err := qfiter(ctx, cfg.QC(ctx, req), 4) i++ if err != nil { t.Fatalf("QC error: %v", err) @@ -206,7 +209,7 @@ func TestMixedOrdering(t *testing.T) { for _, node := range nodes { go func(node *Node) { defer wg.Done() - resp, err := node.UnaryRPC(context.Background(), &Request{Num: uint64(i)}) + resp, err := node.UnaryRPC(context.Background(), Request_builder{Num: uint64(i)}.Build()) if err != nil { t.Errorf("RPC error: %v", err) return diff --git a/tests/qf/qf.pb.go b/tests/qf/qf.pb.go index 264935381..af177a133 100644 --- a/tests/qf/qf.pb.go +++ b/tests/qf/qf.pb.go @@ -3,7 +3,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: qf/qf.proto package qf @@ -13,7 +13,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -25,10 +24,10 @@ const ( ) type Request struct { - state protoimpl.MessageState `protogen:"open.v1"` - Value int64 `protobuf:"varint,1,opt,name=Value" json:"Value,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Value int64 `protobuf:"varint,1,opt,name=Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Request) Reset() { @@ -56,23 +55,36 @@ func (x *Request) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_qf_qf_proto_rawDescGZIP(), []int{0} -} - func (x *Request) GetValue() int64 { if x != nil { - return x.Value + return x.xxx_hidden_Value } return 0 } +func (x *Request) SetValue(v int64) { + x.xxx_hidden_Value = v +} + +type Request_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Value int64 +} + +func (b0 Request_builder) Build() *Request { + m0 := &Request{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Value = b.Value + return m0 +} + type Response struct { - state protoimpl.MessageState `protogen:"open.v1"` - Result int64 `protobuf:"varint,1,opt,name=Result" json:"Result,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Result int64 `protobuf:"varint,1,opt,name=Result"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Response) Reset() { @@ -100,18 +112,31 @@ func (x *Response) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_qf_qf_proto_rawDescGZIP(), []int{1} -} - func (x *Response) GetResult() int64 { if x != nil { - return x.Result + return x.xxx_hidden_Result } return 0 } +func (x *Response) SetResult(v int64) { + x.xxx_hidden_Result = v +} + +type Response_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Result int64 +} + +func (b0 Response_builder) Build() *Response { + m0 := &Response{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Result = b.Result + return m0 +} + var File_qf_qf_proto protoreflect.FileDescriptor const file_qf_qf_proto_rawDesc = "" + @@ -125,18 +150,6 @@ const file_qf_qf_proto_rawDesc = "" + "\x06UseReq\x12\v.qf.Request\x1a\f.qf.Response\"\x04\xa0\xb5\x18\x01\x12,\n" + "\tIgnoreReq\x12\v.qf.Request\x1a\f.qf.Response\"\x04\xa0\xb5\x18\x01B'Z github.com/relab/gorums/tests/qf\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var ( - file_qf_qf_proto_rawDescOnce sync.Once - file_qf_qf_proto_rawDescData []byte -) - -func file_qf_qf_proto_rawDescGZIP() []byte { - file_qf_qf_proto_rawDescOnce.Do(func() { - file_qf_qf_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_qf_qf_proto_rawDesc), len(file_qf_qf_proto_rawDesc))) - }) - return file_qf_qf_proto_rawDescData -} - var file_qf_qf_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_qf_qf_proto_goTypes = []any{ (*Request)(nil), // 0: qf.Request diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index ba043877b..67f0970f7 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,17 +1,15 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: qf/qf.proto package qf import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) const ( @@ -25,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -35,15 +32,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -100,30 +91,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -151,74 +125,36 @@ type Node struct { // QuorumFunctionClient is the client interface for the QuorumFunction service. type QuorumFunctionClient interface { - UseReq(ctx context.Context, in *Request) (resp *Response, err error) - IgnoreReq(ctx context.Context, in *Request) (resp *Response, err error) + UseReq(ctx context.Context, in *Request) gorums.Iterator[*Response] + + IgnoreReq(ctx context.Context, in *Request) gorums.Iterator[*Response] } // enforce interface compliance var _ QuorumFunctionClient = (*Configuration)(nil) -// QuorumSpec is the interface of quorum functions for QuorumFunction. -type QuorumSpec interface { - gorums.ConfigOption - - // UseReqQF is the quorum function for the UseReq - // quorum call method. The in parameter is the request object - // supplied to the UseReq method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - UseReqQF(in *Request, replies map[uint32]*Response) (*Response, bool) - - // IgnoreReqQF is the quorum function for the IgnoreReq - // quorum call method. The in parameter is the request object - // supplied to the IgnoreReq method at call time, and may or may not - // be used by the quorum function. If the in parameter is not needed - // you should implement your quorum function with '_ *Request'. - IgnoreReqQF(in *Request, replies map[uint32]*Response) (*Response, bool) -} - // UseReq is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) UseReq(ctx context.Context, in *Request) (resp *Response, err error) { +// with the same argument in, and returns a combined result. test +func (c *Configuration) UseReq(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "qf.QuorumFunction.UseReq", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.UseReqQF(req.(*Request), r) + Message: in, + Method: "qf.QuorumFunction.UseReq", + ServerStream: false, } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Response), err + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // IgnoreReq is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (c *Configuration) IgnoreReq(ctx context.Context, in *Request) (resp *Response, err error) { +// with the same argument in, and returns a combined result. test +func (c *Configuration) IgnoreReq(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ - Message: in, - Method: "qf.QuorumFunction.IgnoreReq", - } - cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { - r := make(map[uint32]*Response, len(replies)) - for k, v := range replies { - r[k] = v.(*Response) - } - return c.qspec.IgnoreReqQF(req.(*Request), r) + Message: in, + Method: "qf.QuorumFunction.IgnoreReq", + ServerStream: false, } - res, err := c.RawConfiguration.QuorumCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*Response), err + return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } // QuorumFunction is the server-side API for the QuorumFunction Service diff --git a/tests/qf/qf_test.go b/tests/qf/qf_test.go index 5b5532dd0..92bcd667b 100644 --- a/tests/qf/qf_test.go +++ b/tests/qf/qf_test.go @@ -2,6 +2,7 @@ package qf import ( "context" + "errors" "fmt" "testing" @@ -92,18 +93,55 @@ func (q testQSpec) WithoutReqQF(replies map[uint32]*Response) (*Response, bool) return reply, true } +func UseReq(ctx context.Context, cfg *Configuration, quorum int, req *Request) (*Response, error) { + replies := int(0) + for response := range cfg.UseReq(ctx, req) { + msg, err, _ := response.Unpack() + if err != nil { + return nil, err + } + replies++ + if replies < quorum { + continue + } + _ = req.GetValue() + return msg, nil + } + return nil, errors.New("UseReq: quorum not found") +} + +func IgnoreReq(ctx context.Context, cfg *Configuration, quorum int, req *Request) (*Response, error) { + replies := 0 + var firstMsg *Response + for response := range cfg.IgnoreReq(ctx, req) { + msg, err, _ := response.Unpack() + if err != nil { + return nil, err + } + if firstMsg == nil { + firstMsg = msg + } + replies++ + if replies < quorum { + continue + } + return firstMsg, nil + } + return nil, errors.New("IgnoreReq: quorum not found") +} + func BenchmarkQF(b *testing.B) { for n := 3; n < 20; n += 2 { quorum := n / 2 mapSize := n << 1 qspec := &testQSpec{quorum: quorum} - request := &Request{Value: 1} + request := Request_builder{Value: 1}.Build() b.Run(fmt.Sprintf("UseReq_%d", n), func(b *testing.B) { for b.Loop() { replies := make(map[uint32]*Response, mapSize) for j := range n { - replies[uint32(j)] = &Response{Result: request.Value} + replies[uint32(j)] = Response_builder{Result: request.GetValue()}.Build() resp, q := qspec.UseReqQF(request, replies) if q { _ = resp.GetResult() @@ -115,7 +153,7 @@ func BenchmarkQF(b *testing.B) { for b.Loop() { replies := make(map[uint32]*Response, mapSize) for j := range n { - replies[uint32(j)] = &Response{Result: request.Value} + replies[uint32(j)] = Response_builder{Result: request.GetValue()}.Build() resp, q := qspec.IgnoreReqQF(request, replies) if q { _ = resp.GetResult() @@ -127,7 +165,7 @@ func BenchmarkQF(b *testing.B) { for b.Loop() { replies := make(map[uint32]*Response, mapSize) for j := range n { - replies[uint32(j)] = &Response{Result: request.Value} + replies[uint32(j)] = Response_builder{Result: request.GetValue()}.Build() resp, q := qspec.WithoutReqQF(replies) if q { _ = resp.GetResult() @@ -142,7 +180,7 @@ func BenchmarkQF(b *testing.B) { for b.Loop() { replies := make([]*Response, n) for j := range n { - replies[uint32(j)] = &Response{Result: request.Value} + replies[uint32(j)] = Response_builder{Result: request.GetValue()}.Build() resp, q := qspec.SliceUseReqQF(request, replies) if q { _ = resp.GetResult() @@ -154,7 +192,7 @@ func BenchmarkQF(b *testing.B) { for b.Loop() { replies := make([]*Response, n) for j := range n { - replies[uint32(j)] = &Response{Result: request.Value} + replies[uint32(j)] = Response_builder{Result: request.GetValue()}.Build() resp, q := qspec.SliceIgnoreReqQF(request, replies) if q { _ = resp.GetResult() @@ -166,7 +204,7 @@ func BenchmarkQF(b *testing.B) { for b.Loop() { replies := make([]*Response, n) for j := range n { - replies[uint32(j)] = &Response{Result: request.Value} + replies[uint32(j)] = Response_builder{Result: request.GetValue()}.Build() resp, q := qspec.SliceWithoutReqQF(replies) if q { _ = resp.GetResult() @@ -180,11 +218,11 @@ func BenchmarkQF(b *testing.B) { type testSrv struct{} func (s testSrv) UseReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { - return &Response{Result: req.GetValue()}, nil + return Response_builder{Result: req.GetValue()}.Build(), nil } func (s testSrv) IgnoreReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { - return &Response{Result: req.GetValue()}, nil + return Response_builder{Result: req.GetValue()}.Build(), nil } func BenchmarkFullStackQF(b *testing.B) { @@ -200,7 +238,6 @@ func BenchmarkFullStackQF(b *testing.B) { ), ) c, err := mgr.NewConfiguration( - &testQSpec{quorum: n / 2}, gorums.WithNodeList([]string{"127.0.0.1:9080", "127.0.0.1:9081", "127.0.0.1:9082"}), // dummy node list; won't actually be used in test ) if err != nil { @@ -210,9 +247,11 @@ func BenchmarkFullStackQF(b *testing.B) { b.ReportAllocs() b.ResetTimer() + quorum := n / 2 + b.Run(fmt.Sprintf("UseReq_%d", n), func(b *testing.B) { for b.Loop() { - resp, err := c.UseReq(context.Background(), &Request{Value: int64(requestValue)}) + resp, err := UseReq(context.Background(), c, quorum, Request_builder{Value: int64(requestValue)}.Build()) if err != nil { b.Fatalf("UseReq error: %v", err) } @@ -221,7 +260,7 @@ func BenchmarkFullStackQF(b *testing.B) { }) b.Run(fmt.Sprintf("IgnoreReq_%d", n), func(b *testing.B) { for b.Loop() { - resp, err := c.IgnoreReq(context.Background(), &Request{Value: int64(requestValue)}) + resp, err := IgnoreReq(context.Background(), c, quorum, Request_builder{Value: int64(requestValue)}.Build()) if err != nil { b.Fatalf("IgnoreReq error: %v", err) } diff --git a/tests/tls/tls.pb.go b/tests/tls/tls.pb.go index ac75ced87..0dfe543fe 100644 --- a/tests/tls/tls.pb.go +++ b/tests/tls/tls.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: tls/tls.proto package tls @@ -10,7 +10,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -22,7 +21,7 @@ const ( ) type Request struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState `protogen:"opaque.v1"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -52,14 +51,21 @@ func (x *Request) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_tls_tls_proto_rawDescGZIP(), []int{0} +type Request_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 Request_builder) Build() *Request { + m0 := &Request{} + b, x := &b0, m0 + _, _ = b, x + return m0 } type Response struct { - state protoimpl.MessageState `protogen:"open.v1"` - OK bool `protobuf:"varint,1,opt,name=OK" json:"OK,omitempty"` + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_OK bool `protobuf:"varint,1,opt,name=OK"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -89,18 +95,31 @@ func (x *Response) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_tls_tls_proto_rawDescGZIP(), []int{1} -} - func (x *Response) GetOK() bool { if x != nil { - return x.OK + return x.xxx_hidden_OK } return false } +func (x *Response) SetOK(v bool) { + x.xxx_hidden_OK = v +} + +type Response_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + OK bool +} + +func (b0 Response_builder) Build() *Response { + m0 := &Response{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_OK = b.OK + return m0 +} + var File_tls_tls_proto protoreflect.FileDescriptor const file_tls_tls_proto_rawDesc = "" + @@ -112,18 +131,6 @@ const file_tls_tls_proto_rawDesc = "" + "\x03TLS\x12(\n" + "\aTestTLS\x12\f.tls.Request\x1a\r.tls.Response\"\x00B(Z!github.com/relab/gorums/tests/tls\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var ( - file_tls_tls_proto_rawDescOnce sync.Once - file_tls_tls_proto_rawDescData []byte -) - -func file_tls_tls_proto_rawDescGZIP() []byte { - file_tls_tls_proto_rawDescOnce.Do(func() { - file_tls_tls_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_tls_tls_proto_rawDesc), len(file_tls_tls_proto_rawDesc))) - }) - return file_tls_tls_proto_rawDescData -} - var file_tls_tls_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_tls_tls_proto_goTypes = []any{ (*Request)(nil), // 0: tls.Request diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 0806ac504..c21567671 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,14 +1,13 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: tls/tls.proto package tls import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" ) @@ -24,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -34,15 +32,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -99,30 +91,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -156,11 +131,8 @@ type TLSNodeClient interface { // enforce interface compliance var _ TLSNodeClient = (*Node)(nil) -// There are no quorum calls. -type QuorumSpec interface{} - // TestTLS is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (n *Node) TestTLS(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.CallData{ Message: in, diff --git a/tests/tls/tls_test.go b/tests/tls/tls_test.go index 5cf8b4cc6..cd34f0aed 100644 --- a/tests/tls/tls_test.go +++ b/tests/tls/tls_test.go @@ -17,9 +17,9 @@ type testSrv struct{} func (t testSrv) TestTLS(ctx gorums.ServerCtx, in *Request) (resp *Response, err error) { peerInfo, ok := peer.FromContext(ctx) if !ok || peerInfo.AuthInfo.AuthType() != "tls" { - return &Response{OK: false}, nil + return Response_builder{OK: false}.Build(), nil } - return &Response{OK: true}, nil + return Response_builder{OK: true}.Build(), nil } func TestTLS(t *testing.T) { diff --git a/tests/unresponsive/unresponsive.pb.go b/tests/unresponsive/unresponsive.pb.go index 99626deb2..15cd35237 100644 --- a/tests/unresponsive/unresponsive.pb.go +++ b/tests/unresponsive/unresponsive.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 -// protoc v5.29.3 +// protoc v6.30.2 // source: unresponsive/unresponsive.proto package unresponsive @@ -10,7 +10,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" unsafe "unsafe" ) @@ -22,7 +21,7 @@ const ( ) type Empty struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState `protogen:"opaque.v1"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -52,9 +51,16 @@ func (x *Empty) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Empty.ProtoReflect.Descriptor instead. -func (*Empty) Descriptor() ([]byte, []int) { - return file_unresponsive_unresponsive_proto_rawDescGZIP(), []int{0} +type Empty_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + +} + +func (b0 Empty_builder) Build() *Empty { + m0 := &Empty{} + b, x := &b0, m0 + _, _ = b, x + return m0 } var File_unresponsive_unresponsive_proto protoreflect.FileDescriptor @@ -66,18 +72,6 @@ const file_unresponsive_unresponsive_proto_rawDesc = "" + "\fUnresponsive\x12>\n" + "\x10TestUnresponsive\x12\x13.unresponsive.Empty\x1a\x13.unresponsive.Empty\"\x00B1Z*github.com/relab/gorums/tests/unresponsive\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var ( - file_unresponsive_unresponsive_proto_rawDescOnce sync.Once - file_unresponsive_unresponsive_proto_rawDescData []byte -) - -func file_unresponsive_unresponsive_proto_rawDescGZIP() []byte { - file_unresponsive_unresponsive_proto_rawDescOnce.Do(func() { - file_unresponsive_unresponsive_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_unresponsive_unresponsive_proto_rawDesc), len(file_unresponsive_unresponsive_proto_rawDesc))) - }) - return file_unresponsive_unresponsive_proto_rawDescData -} - var file_unresponsive_unresponsive_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_unresponsive_unresponsive_proto_goTypes = []any{ (*Empty)(nil), // 0: unresponsive.Empty diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index 708c25adc..d8914459f 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,14 +1,13 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+ee38614a -// protoc v5.29.3 +// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc v6.30.2 // source: unresponsive/unresponsive.proto package unresponsive import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" encoding "google.golang.org/grpc/encoding" ) @@ -24,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - qspec QuorumSpec nodes []*Node } @@ -34,15 +32,9 @@ type Configuration struct { // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error) { - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") - } +func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error) { newCfg := &Configuration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice newCfg.nodes = make([]*Node, newCfg.Size()) @@ -99,30 +91,13 @@ func NewManager(opts ...gorums.ManagerOption) *Manager { // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, // using the And, WithNewNodes, Except, and WithoutNodes methods. -func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error) { - if len(opts) < 1 || len(opts) > 2 { - return nil, fmt.Errorf("config: wrong number of options: %d", len(opts)) - } +func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configuration, err error) { c = &Configuration{} - for _, opt := range opts { - switch v := opt.(type) { - case gorums.NodeListOption: - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, v) - if err != nil { - return nil, err - } - case QuorumSpec: - // Must be last since v may match QuorumSpec if it is interface{} - c.qspec = v - default: - return nil, fmt.Errorf("config: unknown option type: %v", v) - } - } - // return an error if the QuorumSpec interface is not empty and no implementation was provided. - var test any = struct{}{} - if _, empty := test.(QuorumSpec); !empty && c.qspec == nil { - return nil, fmt.Errorf("config: missing required QuorumSpec") + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, nodeList) + if err != nil { + return nil, err } + // initialize the nodes slice c.nodes = make([]*Node, c.Size()) for i, n := range c.RawConfiguration { @@ -156,11 +131,8 @@ type UnresponsiveNodeClient interface { // enforce interface compliance var _ UnresponsiveNodeClient = (*Node)(nil) -// There are no quorum calls. -type QuorumSpec interface{} - // TestUnresponsive is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. +// with the same argument in, and returns a combined result. test func (n *Node) TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) { cd := gorums.CallData{ Message: in, From cfbafa5aa1fb3bbcf23d3b5b5ac08bd2a49f8267 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sun, 20 Apr 2025 18:19:07 +0200 Subject: [PATCH 04/27] refactor benchmark --- benchmark/benchmark.go | 51 ++-- benchmark/benchmark_gorums.pb.go | 2 +- benchmark/qspec.go | 264 ++++-------------- cmd/benchmark/main.go | 9 +- .../dev/zorums_client_gorums.pb.go | 2 +- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_quorumcall_gorums.pb.go | 2 +- .../dev/zorums_rpc_gorums.pb.go | 2 +- .../dev/zorums_server_gorums.pb.go | 2 +- .../dev/zorums_types_gorums.pb.go | 2 +- .../dev/zorums_unicast_gorums.pb.go | 2 +- iterator.go | 14 + quorumcall.go | 23 +- tests/config/config_gorums.pb.go | 2 +- tests/correctable/correctable_gorums.pb.go | 2 +- tests/dummy/dummy_gorums.pb.go | 2 +- tests/metadata/metadata_gorums.pb.go | 2 +- tests/oneway/oneway_gorums.pb.go | 2 +- tests/ordering/order_gorums.pb.go | 2 +- tests/qf/qf_gorums.pb.go | 2 +- tests/tls/tls_gorums.pb.go | 2 +- tests/unresponsive/unresponsive_gorums.pb.go | 2 +- 22 files changed, 122 insertions(+), 273 deletions(-) diff --git a/benchmark/benchmark.go b/benchmark/benchmark.go index 9999ca454..34747800c 100644 --- a/benchmark/benchmark.go +++ b/benchmark/benchmark.go @@ -32,13 +32,12 @@ type Bench struct { } type ( - benchFunc func(Options) (*Result, error) - qcFunc func(context.Context, *Configuration, QSpec, *Echo) (*Echo, error) - asyncQCFunc func(context.Context, *Echo) *gorums.Iterator[*Echo] - serverFunc func(context.Context, *TimedMsg) + benchFunc func(Options) (*Result, error) + qcFunc func(context.Context, *Echo) gorums.Iterator[*Echo] + serverFunc func(context.Context, *TimedMsg) ) -func runQCBenchmark(opts Options, cfg *Configuration, qspec QSpec, f qcFunc) (*Result, error) { +func runQCBenchmark(opts Options, cfg *Configuration, quorum int, f qcFunc) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() msg := Echo_builder{Payload: make([]byte, opts.Payload)}.Build() @@ -49,7 +48,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, qspec QSpec, f qcFunc) (*R g.Go(func() error { warmupEnd := time.Now().Add(opts.Warmup) for !time.Now().After(warmupEnd) { - _, err := f(ctx, cfg, qspec, msg) + err := qf(f(ctx, msg), quorum) if err != nil { return err } @@ -64,7 +63,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, qspec QSpec, f qcFunc) (*R } if opts.Remote { - _, err := QspecWrapper(cfg, qspec, cfg.StartBenchmark(ctx, &StartRequest{}), &StartRequest{}, StartBenchmarkQF) + err := qf(cfg.StartBenchmark(ctx, &StartRequest{}), quorum) if err != nil { return nil, err } @@ -76,7 +75,7 @@ func runQCBenchmark(opts Options, cfg *Configuration, qspec QSpec, f qcFunc) (*R endTime := time.Now().Add(opts.Duration) for !time.Now().After(endTime) { start := time.Now() - _, err := f(ctx, cfg, qspec, msg) + err := qf(f(ctx, msg), quorum) if err != nil { return err } @@ -94,17 +93,17 @@ func runQCBenchmark(opts Options, cfg *Configuration, qspec QSpec, f qcFunc) (*R result := s.GetResult() if opts.Remote { - memStats, err := QspecWrapper(cfg, qspec, cfg.StopBenchmark(ctx, &StopRequest{}), &StopRequest{}, StopBenchmarkQF) + memStats, err := stopBenchmarkQF(cfg.StopBenchmark(ctx, &StopRequest{}), cfg.Size()) if err != nil { return nil, err } - result.SetServerStats(memStats.GetMemoryStats()) + result.SetServerStats(memStats) } return result, nil } -func runAsyncQCBenchmark(opts Options, cfg *Configuration, qspec QSpec) (*Result, error) { +func runAsyncQCBenchmark(opts Options, cfg *Configuration, quorum int) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() msg := Echo_builder{Payload: make([]byte, opts.Payload)}.Build() @@ -119,7 +118,7 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, qspec QSpec) (*Result for ; !time.Now().After(warmupEnd) && atomic.LoadUint64(&async) < uint64(opts.MaxAsync); atomic.AddUint64(&async, 1) { responses := cfg.AsyncQuorumCall(ctx, msg) g.Go(func() error { - _, err := QspecWrapper(cfg, qspec, responses, msg, qf) + err := qf(responses, quorum) if err != nil { return err } @@ -140,7 +139,7 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, qspec QSpec) (*Result } if opts.Remote { - _, err := QspecWrapper(cfg, qspec, cfg.StartBenchmark(ctx, &StartRequest{}), &StartRequest{}, StartBenchmarkQF) + err := qf(cfg.StartBenchmark(ctx, &StartRequest{}), cfg.Size()) if err != nil { return nil, err } @@ -153,7 +152,7 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, qspec QSpec) (*Result start := time.Now() responses := cfg.AsyncQuorumCall(ctx, msg) g.Go(func() error { - _, err := QspecWrapper(cfg, qspec, responses, msg, qf) + err := qf(responses, quorum) if err != nil { return err } @@ -178,17 +177,17 @@ func runAsyncQCBenchmark(opts Options, cfg *Configuration, qspec QSpec) (*Result result := s.GetResult() if opts.Remote { - memStats, err := QspecWrapper(cfg, qspec, cfg.StopBenchmark(ctx, &StopRequest{}), &StopRequest{}, StopBenchmarkQF) + memStats, err := stopBenchmarkQF(cfg.StopBenchmark(ctx, &StopRequest{}), cfg.Size()) if err != nil { return nil, err } - result.SetServerStats(memStats.GetMemoryStats()) + result.SetServerStats(memStats) } return result, nil } -func runServerBenchmark(opts Options, cfg *Configuration, qspec QSpec, f serverFunc) (*Result, error) { +func runServerBenchmark(opts Options, cfg *Configuration, f serverFunc) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() payload := make([]byte, opts.Payload) @@ -212,7 +211,7 @@ func runServerBenchmark(opts Options, cfg *Configuration, qspec QSpec, f serverF return nil, err } - _, err = QspecWrapper(cfg, qspec, cfg.StartServerBenchmark(ctx, &StartRequest{}), &StartRequest{}, StartServerBenchmarkQF) + err = qf(cfg.StartServerBenchmark(ctx, &StartRequest{}), cfg.Size()) if err != nil { return nil, err } @@ -228,7 +227,7 @@ func runServerBenchmark(opts Options, cfg *Configuration, qspec QSpec, f serverF } runtime.ReadMemStats(&end) - resp, err := QspecWrapper(cfg, qspec, cfg.StopServerBenchmark(ctx, &StopRequest{}), &StopRequest{}, StopServerBenchmarkQF) + resp, err := stopServerBenchmarkQF(cfg.StopServerBenchmark(ctx, &StopRequest{}), cfg.Size()) if err != nil { return nil, err } @@ -242,28 +241,28 @@ func runServerBenchmark(opts Options, cfg *Configuration, qspec QSpec, f serverF } // GetBenchmarks returns a list of Benchmarks that can be performed on the configuration -func GetBenchmarks(cfg *Configuration, qspec QSpec) []Bench { +func GetBenchmarks(cfg *Configuration, quorum int) []Bench { m := []Bench{ { Name: "QuorumCall", Description: "NodeStream based quorum call implementation with FIFO ordering", - runBench: func(opts Options) (*Result, error) { return runQCBenchmark(opts, cfg, qspec, QuorumCall) }, + runBench: func(opts Options) (*Result, error) { return runQCBenchmark(opts, cfg, quorum, cfg.QuorumCall) }, }, { Name: "AsyncQuorumCall", Description: "NodeStream based async quorum call implementation with FIFO ordering", - runBench: func(opts Options) (*Result, error) { return runAsyncQCBenchmark(opts, cfg, qspec) }, + runBench: func(opts Options) (*Result, error) { return runAsyncQCBenchmark(opts, cfg, quorum) }, }, { Name: "SlowServer", Description: "Quorum Call with a 10s processing time on the server", - runBench: func(opts Options) (*Result, error) { return runQCBenchmark(opts, cfg, qspec, SlowServer) }, + runBench: func(opts Options) (*Result, error) { return runQCBenchmark(opts, cfg, quorum, cfg.SlowServer) }, }, { Name: "Multicast", Description: "NodeStream based multicast implementation (servers measure latency and throughput)", runBench: func(opts Options) (*Result, error) { - return runServerBenchmark(opts, cfg, qspec, func(ctx context.Context, msg *TimedMsg) { cfg.Multicast(ctx, msg) }) + return runServerBenchmark(opts, cfg, func(ctx context.Context, msg *TimedMsg) { cfg.Multicast(ctx, msg) }) }, }, } @@ -271,8 +270,8 @@ func GetBenchmarks(cfg *Configuration, qspec QSpec) []Bench { } // RunBenchmarks runs all the benchmarks that match the given regex with the given options -func RunBenchmarks(benchRegex *regexp.Regexp, options Options, cfg *Configuration, qspec QSpec) ([]*Result, error) { - benchmarks := GetBenchmarks(cfg, qspec) +func RunBenchmarks(benchRegex *regexp.Regexp, options Options, cfg *Configuration, quorum int) ([]*Result, error) { + benchmarks := GetBenchmarks(cfg, quorum) var results []*Result for _, b := range benchmarks { if benchRegex.MatchString(b.Name) { diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 97711f2b4..eacbf65d6 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: benchmark/benchmark.proto diff --git a/benchmark/qspec.go b/benchmark/qspec.go index 1f9538232..9e9aed0c4 100644 --- a/benchmark/qspec.go +++ b/benchmark/qspec.go @@ -1,241 +1,73 @@ package benchmark import ( - "context" - "errors" + fmt "fmt" gorums "github.com/relab/gorums" "google.golang.org/protobuf/proto" ) -// QSpec is the quorum specification object for the benchmark -type QSpec struct { - CfgSize int - QSize int -} - -func qf(qspec QSpec, _ *Echo, replies []*Echo) (*Echo, bool) { - if len(replies) < qspec.QSize { - return nil, false - } - var resp *Echo - for _, r := range replies { - resp = r - break - } - return resp, true -} - -// StartServerBenchmarkQF is the quorum function for the StartServerBenchmark quorumcall. -// It requires a response from all nodes. -func StartServerBenchmarkQF(qspec QSpec, _ *StartRequest, replies []*StartResponse) (*StartResponse, bool) { - if len(replies) < qspec.CfgSize { - return nil, false - } - // return any response - var resp *StartResponse - for _, r := range replies { - resp = r - break - } - return resp, true -} - -// StopServerBenchmarkQF is the quorum function for the StopServerBenchmark quorumcall. +// stopServerBenchmarkQF is the quorum function for the StopServerBenchmark quorumcall. // It requires a response from all nodes. -func StopServerBenchmarkQF(qspec QSpec, _ *StopRequest, replies []*Result) (*Result, bool) { - if len(replies) < qspec.CfgSize { - return nil, false - } +func stopServerBenchmarkQF(replies gorums.Iterator[*Result], cfgSize int) (*Result, error) { // combine results, calculating averages and pooled variance - resp := &Result{} - for _, reply := range replies { - if resp.GetName() != "" { - resp.SetName(reply.GetName()) + resp := &Result_builder{} + replyCount := 0 + for reply := range replies.IgnoreErrors() { + replyCount++ + msg := reply.Msg + if resp.Name != "" { + resp.Name = msg.GetName() } - resp.SetTotalOps(resp.GetTotalOps() + reply.GetTotalOps()) - resp.SetTotalTime(resp.GetTotalTime() + reply.GetTotalTime()) - resp.SetThroughput(resp.GetThroughput() + reply.GetThroughput()) - resp.SetLatencyAvg(resp.GetLatencyAvg() + reply.GetLatencyAvg()*float64(reply.GetTotalOps())) - resp.SetServerStats(append(resp.GetServerStats(), MemoryStat_builder{ - Allocs: reply.GetAllocsPerOp() * resp.GetTotalOps(), - Memory: reply.GetMemPerOp() * resp.GetTotalOps(), - }.Build())) - } - resp.SetLatencyAvg(resp.GetLatencyAvg() / float64(resp.GetTotalOps())) - for _, reply := range replies { - resp.SetLatencyVar(resp.GetLatencyVar() + float64(reply.GetTotalOps()-1)*reply.GetLatencyVar()) + resp.TotalOps += msg.GetTotalOps() + resp.TotalTime += msg.GetTotalTime() + resp.Throughput += msg.GetThroughput() + resp.LatencyAvg += msg.GetLatencyAvg() * float64(msg.GetTotalOps()) + resp.LatencyVar += float64(msg.GetTotalOps()-1) * msg.GetLatencyVar() + resp.ServerStats = append(resp.ServerStats, MemoryStat_builder{ + Allocs: msg.GetAllocsPerOp() * resp.TotalOps, + Memory: msg.GetMemPerOp() * resp.TotalOps, + }.Build()) } - resp.SetLatencyVar(resp.GetLatencyVar() / (float64(resp.GetTotalOps()) - float64(len(replies)))) - resp.SetTotalOps(resp.GetTotalOps() / uint64(len(replies))) - resp.SetTotalTime(resp.GetTotalTime() / int64(len(replies))) - resp.SetThroughput(resp.GetThroughput() / float64(len(replies))) - return resp, true -} -// StartBenchmarkQF is the quorum function for the StartBenchmark quorumcall. -// It requires a response from all nodes. -func StartBenchmarkQF(qspec QSpec, _ *StartRequest, replies []*StartResponse) (*StartResponse, bool) { - if len(replies) < qspec.CfgSize { - return nil, false - } - // return any response - var resp *StartResponse - for _, r := range replies { - resp = r - break + if replyCount < cfgSize { + return nil, fmt.Errorf("missing benchmark results got %d want %d", replyCount, cfgSize) } - return resp, true -} -// StopBenchmarkQF is the quorum function for the StopBenchmark quorumcall. -// It requires a response from all nodes. -func StopBenchmarkQF(qspec QSpec, _ *StopRequest, replies []*MemoryStat) (*MemoryStatList, bool) { - if len(replies) < qspec.CfgSize { - return nil, false - } - replyList := make([]*MemoryStat, 0, len(replies)) - for _, v := range replies { - replyList = append(replyList, v) - } - return MemoryStatList_builder{MemoryStats: replyList}.Build(), true + resp.LatencyAvg /= float64(resp.TotalOps) + resp.LatencyVar /= float64(resp.TotalOps) - float64(replyCount) + resp.TotalOps /= uint64(replyCount) + resp.TotalTime /= int64(replyCount) + resp.Throughput /= float64(replyCount) + return resp.Build(), nil } -func QspecWrapper[ - requestType proto.Message, - replyType proto.Message, - returnType proto.Message, -]( - cfg *Configuration, - qspec QSpec, - iterator gorums.Iterator[replyType], - request requestType, - f func(QSpec, requestType, []replyType) (returnType, bool), -) (returnType, error) { - replies := make([]replyType, 0) - var noResult returnType - for reply := range iterator { - msg, err, _ := reply.Unpack() - replies = append(replies, msg) - if err != nil { +// stopBenchmarkQF is the quorum function for the StopBenchmark quorumcall. +// It requires a response from all nodes. +func stopBenchmarkQF(replies gorums.Iterator[*MemoryStat], cfgSize int) ([]*MemoryStat, error) { + replyList := make([]*MemoryStat, 0) + replyCount := 0 + for reply := range replies.IgnoreErrors() { + replyCount++ + replyList = append(replyList, reply.Msg) + if len(replyList) < cfgSize { continue } - result, quorum := f(qspec, request, replies) - if quorum { - return result, nil - } - } - return noResult, errors.New("quorumcall no result") -} - -// QuorumCallQF is the quorum function for the QuorumCall quorumcall -func QuorumCall(ctx context.Context, cfg *Configuration, qspec QSpec, request *Echo) (*Echo, error) { - return QspecWrapper(cfg, qspec, cfg.QuorumCall(ctx, request), request, qf) -} - -// SlowServerQF is the quorum function for the SlowServer quorumcall -func SlowServer(ctx context.Context, cfg *Configuration, qspec QSpec, request *Echo) (*Echo, error) { - return QspecWrapper(cfg, qspec, cfg.SlowServer(ctx, request), request, qf) -} - -func (qspec QSpec) qf(replies map[uint32]*Echo) (*Echo, bool) { - if len(replies) < qspec.QSize { - return nil, false - } - var resp *Echo - for _, r := range replies { - resp = r - break - } - return resp, true -} - -// StartServerBenchmarkQF is the quorum function for the StartServerBenchmark quorumcall. -// It requires a response from all nodes. -func (qspec QSpec) StartServerBenchmarkQF(_ *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool) { - if len(replies) < qspec.CfgSize { - return nil, false - } - // return any response - var resp *StartResponse - for _, r := range replies { - resp = r - break + return replyList, nil } - return resp, true + return nil, fmt.Errorf("quorum not found, got %d responses want %d", replyCount, cfgSize) } -// StopServerBenchmarkQF is the quorum function for the StopServerBenchmark quorumcall. -// It requires a response from all nodes. -func (qspec QSpec) StopServerBenchmarkQF(_ *StopRequest, replies map[uint32]*Result) (*Result, bool) { - if len(replies) < qspec.CfgSize { - return nil, false - } - // combine results, calculating averages and pooled variance - resp := &Result{} - for _, reply := range replies { - if resp.GetName() != "" { - resp.SetName(reply.GetName()) +// qf is a generic quorum function which does not return anything. +// It requires a response from a specified quorum amount of nodes. +func qf[responseType proto.Message](replies gorums.Iterator[responseType], quorum int) error { + replyCount := 0 + for range replies.IgnoreErrors() { + replyCount++ + if replyCount < quorum { + continue } - resp.SetTotalOps(resp.GetTotalOps() + reply.GetTotalOps()) - resp.SetTotalTime(resp.GetTotalTime() + reply.GetTotalTime()) - resp.SetThroughput(resp.GetThroughput() + reply.GetThroughput()) - resp.SetLatencyAvg(resp.GetLatencyAvg() + reply.GetLatencyAvg()*float64(reply.GetTotalOps())) - resp.SetServerStats(append(resp.GetServerStats(), MemoryStat_builder{ - Allocs: reply.GetAllocsPerOp() * resp.GetTotalOps(), - Memory: reply.GetMemPerOp() * resp.GetTotalOps(), - }.Build())) - } - resp.SetLatencyAvg(resp.GetLatencyAvg() / float64(resp.GetTotalOps())) - for _, reply := range replies { - resp.SetLatencyVar(resp.GetLatencyVar() + float64(reply.GetTotalOps()-1)*reply.GetLatencyVar()) - } - resp.SetLatencyVar(resp.GetLatencyVar() / (float64(resp.GetTotalOps()) - float64(len(replies)))) - resp.SetTotalOps(resp.GetTotalOps() / uint64(len(replies))) - resp.SetTotalTime(resp.GetTotalTime() / int64(len(replies))) - resp.SetThroughput(resp.GetThroughput() / float64(len(replies))) - return resp, true -} - -// StartBenchmarkQF is the quorum function for the StartBenchmark quorumcall. -// It requires a response from all nodes. -func (qspec QSpec) StartBenchmarkQF(_ *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool) { - if len(replies) < qspec.CfgSize { - return nil, false - } - // return any response - var resp *StartResponse - for _, r := range replies { - resp = r - break - } - return resp, true -} - -// StopBenchmarkQF is the quorum function for the StopBenchmark quorumcall. -// It requires a response from all nodes. -func (qspec QSpec) StopBenchmarkQF(_ *StopRequest, replies map[uint32]*MemoryStat) (*MemoryStatList, bool) { - if len(replies) < qspec.CfgSize { - return nil, false + return nil } - replyList := make([]*MemoryStat, 0, len(replies)) - for _, v := range replies { - replyList = append(replyList, v) - } - return MemoryStatList_builder{MemoryStats: replyList}.Build(), true -} - -// QuorumCallQF is the quorum function for the QuorumCall quorumcall -func (qspec QSpec) QuorumCallQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { - return qspec.qf(replies) -} - -// SlowServerQF is the quorum function for the SlowServer quorumcall -func (qspec QSpec) SlowServerQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { - return qspec.qf(replies) -} - -// AsyncQuorumCallQF is the quorum function for the AsyncQuorumCall quorumcall -func (qspec QSpec) AsyncQuorumCallQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool) { - return qspec.qf(replies) + return fmt.Errorf("quorum not found, got %d responses want %d", replyCount, quorum) } diff --git a/cmd/benchmark/main.go b/cmd/benchmark/main.go index bf10610fd..c69e89487 100644 --- a/cmd/benchmark/main.go +++ b/cmd/benchmark/main.go @@ -58,7 +58,7 @@ func (f *listFlag) Get() []string { func listBenchmarks() { tw := tabwriter.NewWriter(os.Stdout, 0, 0, 4, ' ', 0) - benchmarks := benchmark.GetBenchmarks(nil, benchmark.QSpec{}) + benchmarks := benchmark.GetBenchmarks(nil, 0) for _, b := range benchmarks { fmt.Fprintf(tw, "%s:\t%s\n", b.Name, b.Description) } @@ -199,15 +199,10 @@ func main() { mgr := benchmark.NewManager(mgrOpts...) defer mgr.Close() - qspec := benchmark.QSpec{ - QSize: options.QuorumSize, - CfgSize: options.NumNodes, - } - cfg, err := mgr.NewConfiguration(gorums.WithNodeList(remotes[:options.NumNodes])) checkf("Failed to create configuration: %v", err) - results, err := benchmark.RunBenchmarks(benchReg, options, cfg, qspec) + results, err := benchmark.RunBenchmarks(benchReg, options, cfg, options.QuorumSize) checkf("Error running benchmarks: %v", err) printResults(results, options, *serverStats) diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index b22b715df..2bc38abfd 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index 00068a9af..d118e5e2a 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index be49475f3..e927783a7 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index d7a7944ae..383fa5270 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index 81cec0653..515aa1fd7 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go index c6b213d78..0d8bc0f74 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index 052ad8622..72f77af22 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: zorums.proto diff --git a/iterator.go b/iterator.go index 4cab49ee5..e6f811da7 100644 --- a/iterator.go +++ b/iterator.go @@ -47,6 +47,20 @@ func (iterator Iterator[messageType]) Filter(forward func(Response[messageType]) } } +// this method uses a function to keep/remove messages from a quorum call +// this can be used to verify the responses from servers before any further computation +func (iterator Iterator[messageType]) IgnoreErrors() Iterator[messageType] { + return func(yield func(Response[messageType]) bool) { + for resp := range iterator { + if resp.Err == nil { + if !yield(resp) { + return + } + } + } + } +} + // If you expect all servers to send the same reply, // you can use GetQuorum to find the first message to occur // a specified amount of times diff --git a/quorumcall.go b/quorumcall.go index fce3d36b9..1e16e9a45 100644 --- a/quorumcall.go +++ b/quorumcall.go @@ -27,17 +27,17 @@ func QuorumCall[responseType proto.Message]( c RawConfiguration, d QuorumCallData, ) Iterator[responseType] { - expectedReplies := len(c) + nodes := len(c) md := ordering.NewGorumsMetadata(ctx, c.getMsgID(), d.Method) - replyChan := make(chan response, expectedReplies) + replyChan := make(chan response, nodes) for _, n := range c { msg := d.Message if d.PerNodeArgFn != nil { msg = d.PerNodeArgFn(d.Message, n.id) if !msg.ProtoReflect().IsValid() { - expectedReplies-- + nodes-- continue // don't send if no msg } } @@ -57,22 +57,31 @@ func QuorumCall[responseType proto.Message]( } replies := int(0) + errors := int(0) return func(yield func(Response[responseType]) bool) { for { + if d.ServerStream { + if errors >= nodes { + return + } + } else { + if replies >= nodes { + return + } + } select { case r := <-replyChan: replies++ + if r.err != nil { + errors++ + } if !yield(NewResponse(r.msg.(responseType), r.err, r.nid)) { return } case <-ctx.Done(): return } - // for streaming just wait for context timeout/cancel - if d.ServerStream && replies >= expectedReplies { - return - } } } } diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index 413aaa387..860f99754 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: config/config.proto diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 5d81423ff..46aa80b56 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: correctable/correctable.proto diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index 59d7fbb0d..51e43bd5d 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: dummy/dummy.proto diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index a2bc5132e..b571deacc 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: metadata/metadata.proto diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index 78741550c..ee026a587 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: oneway/oneway.proto diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index ff4ff2e64..c4451f45d 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: ordering/order.proto diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 67f0970f7..42a503f48 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: qf/qf.proto diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index c21567671..19507115b 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: tls/tls.proto diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index d8914459f..6df15e8ce 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+71bed4a8 // protoc v6.30.2 // source: unresponsive/unresponsive.proto From 0ae594089617884ec163b31a91d3da8b53412f6b Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sun, 20 Apr 2025 19:29:45 +0200 Subject: [PATCH 05/27] refactor tests --- async.go | 2 +- correctable.go | 47 ++++++++--------- iterator.go | 26 ++++----- tests/config/config_test.go | 17 +++--- tests/correctable/correctable_test.go | 46 ++++++++-------- tests/ordering/order_test.go | 10 ++-- tests/qf/qf_test.go | 76 ++++++++++++++++++++------- 7 files changed, 127 insertions(+), 97 deletions(-) diff --git a/async.go b/async.go index efe8d2a07..af59e9fc8 100644 --- a/async.go +++ b/async.go @@ -29,6 +29,7 @@ func (f *Async[resultType]) Done() bool { } } +// IterAsync lets you use a quorum call as an async call. func IterAsync[responseType proto.Message, resultType any]( iter Iterator[responseType], asyncFunc func(Iterator[responseType]) resultType, @@ -39,7 +40,6 @@ func IterAsync[responseType proto.Message, resultType any]( go func() { async.reply = asyncFunc(iter) - close(async.c) }() diff --git a/correctable.go b/correctable.go index 7619f11d2..3e23aea2f 100644 --- a/correctable.go +++ b/correctable.go @@ -1,7 +1,6 @@ package gorums import ( - "iter" "sync" "google.golang.org/protobuf/proto" @@ -54,22 +53,13 @@ func (c *Correctable[resultType]) Watch(level int) <-chan struct{} { return ch } -func (c *Correctable[resultType]) set(reply resultType, level int, err error, done bool) { +func (c *Correctable[resultType]) set(reply resultType, level int, err error) { c.mu.Lock() defer c.mu.Unlock() if c.done { panic("set(...) called on a done correctable") } - c.reply, c.level, c.err, c.done = reply, level, err, done - if done { - close(c.donech) - for _, watcher := range c.watchers { - if watcher != nil { - close(watcher.ch) - } - } - return - } + c.reply, c.level, c.err = reply, level, err for i := range c.watchers { if c.watchers[i] != nil && c.watchers[i].level <= level { close(c.watchers[i].ch) @@ -78,23 +68,30 @@ func (c *Correctable[resultType]) set(reply resultType, level int, err error, do } } -func IterToCorrectable[responseType proto.Message, dataType any, resultType any]( +func (c *Correctable[resultType]) setDone() { + c.mu.Lock() + defer c.mu.Unlock() + if c.done { + panic("setDone(...) called on a done correctable") + } + + c.done = true + close(c.donech) + for _, watcher := range c.watchers { + if watcher != nil { + close(watcher.ch) + } + } +} + +func IterCorrectable[responseType proto.Message, resultType any]( iter Iterator[responseType], - data dataType, - corrFunction func(Iterator[responseType], dataType) iter.Seq2[resultType, int], + corrFunction func(Iterator[responseType], func(resultType, int, error)), ) *Correctable[resultType] { corr := &Correctable[resultType]{donech: make(chan struct{}, 1)} go func() { - for result, level := range corrFunction(iter, data) { - corr.set(result, level, nil, false) - } - corr.done = true - close(corr.donech) - for _, watcher := range corr.watchers { - if watcher != nil { - close(watcher.ch) - } - } + corrFunction(iter, corr.set) + corr.setDone() }() return corr } diff --git a/iterator.go b/iterator.go index e6f811da7..8689d704f 100644 --- a/iterator.go +++ b/iterator.go @@ -18,6 +18,7 @@ type Response[messageType proto.Message] struct { } // NewResponse initialized a response struct without needing to specify the message type +// the function can be private func NewResponse[messageType proto.Message](msg messageType, err error, nid uint32) Response[messageType] { return Response[messageType]{ Msg: msg, @@ -33,12 +34,12 @@ func (r Response[messageType]) Unpack() (messageType, error, uint32) { type Iterator[messageType proto.Message] iter.Seq[Response[messageType]] -// this method uses a function to keep/remove messages from a quorum call -// this can be used to verify the responses from servers before any further computation -func (iterator Iterator[messageType]) Filter(forward func(Response[messageType]) bool) Iterator[messageType] { +// Filter uses a function to keep/remove messages from a quorum call +// can be used to verify/filter responses from servers before computing quorum +func (iterator Iterator[messageType]) Filter(keep func(Response[messageType]) bool) Iterator[messageType] { return func(yield func(Response[messageType]) bool) { for resp := range iterator { - if forward(resp) { + if keep(resp) { if !yield(resp) { return } @@ -47,23 +48,22 @@ func (iterator Iterator[messageType]) Filter(forward func(Response[messageType]) } } -// this method uses a function to keep/remove messages from a quorum call -// this can be used to verify the responses from servers before any further computation +// IgnoreErrors removes the errors from the iterator func (iterator Iterator[messageType]) IgnoreErrors() Iterator[messageType] { return func(yield func(Response[messageType]) bool) { for resp := range iterator { - if resp.Err == nil { - if !yield(resp) { - return - } + if resp.Err != nil { + continue + } + if !yield(resp) { + return } } } } -// If you expect all servers to send the same reply, -// you can use GetQuorum to find the first message to occur -// a specified amount of times +// GetQuorum is an example function for an iterator method +// it returns a message if it occurs more than a specified amount of times func (iterator Iterator[messageType]) GetQuorum(quorum int) (messageType, error) { type replyFreq struct { val messageType diff --git a/tests/config/config_test.go b/tests/config/config_test.go index 7eb9cc8d0..c1b2ca484 100644 --- a/tests/config/config_test.go +++ b/tests/config/config_test.go @@ -2,7 +2,6 @@ package config import ( "context" - "errors" fmt "fmt" "testing" @@ -52,16 +51,16 @@ func setup(t *testing.T, mgr *Manager, cfgSize int) (cfg *Configuration, teardow func configQF(cfg *Configuration, req *Request) (*Response, error) { quorum := cfg.Size()/2 + 1 - replies := int(0) - responses := cfg.Config(context.Background(), req) - for response := range responses { - msg, _, _ := response.Unpack() - replies++ - if replies >= quorum { - return msg, nil + replyCount := int(0) + replies := cfg.Config(context.Background(), req) + for reply := range replies.IgnoreErrors() { + replyCount++ + if replyCount < quorum { + continue } + return reply.Msg, nil } - return nil, errors.New("configQF: no quorum") + return nil, fmt.Errorf("configQF: no quorum got: %d, want (at least): %d", replyCount, quorum) } // TestConfig creates and combines multiple configurations and invokes the Config RPC diff --git a/tests/correctable/correctable_test.go b/tests/correctable/correctable_test.go index 309689f2e..0d00372d4 100644 --- a/tests/correctable/correctable_test.go +++ b/tests/correctable/correctable_test.go @@ -2,7 +2,6 @@ package correctable import ( "context" - "iter" "testing" "time" @@ -55,22 +54,24 @@ func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration } } -func qcorr(responses gorums.Iterator[*CorrectableResponse], q qspec) iter.Seq2[int, int] { - return func(yield func(int, int) bool) { - sum := 0 - for response := range responses { - reply, err, _ := response.Unpack() - if err != nil { - continue - } - sum += int(reply.GetLevel()) - level := sum / q.div - if !yield(level, level) { - return - } - if level >= q.doneLevel { - return - } +type qspec struct { + div int + doneLevel int +} + +func (q qspec) corrQF(responses gorums.Iterator[*CorrectableResponse], levelSet func(int, int, error)) { + sum := 0 + for response := range responses { + msg, err, _ := response.Unpack() + if err != nil { + levelSet(0, 0, err) + continue + } + sum += int(msg.GetLevel()) + level := sum / q.div + levelSet(level, level, nil) + if level >= q.doneLevel { + return } } } @@ -78,22 +79,19 @@ func qcorr(responses gorums.Iterator[*CorrectableResponse], q qspec) iter.Seq2[i func TestCorrectable(t *testing.T) { run(t, 4, 1, func(ctx context.Context, c *Configuration, n int, div int) *gorums.Correctable[int] { corr := c.Correctable(ctx, &CorrectableRequest{}) - return gorums.IterToCorrectable(corr, qspec{div, n}, qcorr) + qspec := qspec{div, n} + return gorums.IterCorrectable(corr, qspec.corrQF) }) } func TestCorrectableStream(t *testing.T) { run(t, 4, 4, func(ctx context.Context, c *Configuration, n int, div int) *gorums.Correctable[int] { corr := c.CorrectableStream(ctx, &CorrectableRequest{}) - return gorums.IterToCorrectable(corr, qspec{div, n}, qcorr) + qspec := qspec{div, n} + return gorums.IterCorrectable(corr, qspec.corrQF) }) } -type qspec struct { - div int - doneLevel int -} - type testSrv struct { n int } diff --git a/tests/ordering/order_test.go b/tests/ordering/order_test.go index 4c554b03c..246f248b5 100644 --- a/tests/ordering/order_test.go +++ b/tests/ordering/order_test.go @@ -46,7 +46,7 @@ func (s *testSrv) UnaryRPC(_ gorums.ServerCtx, req *Request) (resp *Response, er }.Build(), nil } -func qfiter(ctx context.Context, responses gorums.Iterator[*Response], quorum int) (*Response, error) { +func orderQF(ctx context.Context, responses gorums.Iterator[*Response], quorum int) (*Response, error) { replyCount := 0 var orderMsg *Response var firstMsg *Response @@ -75,7 +75,7 @@ func qfiter(ctx context.Context, responses gorums.Iterator[*Response], quorum in if err != nil { return nil, err } - return nil, errors.New("qfiter: quorum not found") + return nil, errors.New("orderQF: quorum not found") } func setup(t *testing.T, cfgSize int) (cfg *Configuration, teardown func()) { @@ -135,7 +135,7 @@ func TestQCOrdering(t *testing.T) { i++ ctx := context.Background() req := Request_builder{Num: uint64(i)}.Build() - resp, err := qfiter(ctx, cfg.QC(ctx, req), 4) + resp, err := orderQF(ctx, cfg.QC(ctx, req), 4) if err != nil { t.Fatalf("QC error: %v", err) } @@ -163,7 +163,7 @@ func TestQCAsyncOrdering(t *testing.T) { wg.Add(1) go func(responses gorums.Iterator[*Response]) { defer wg.Done() - resp, err := qfiter(ctx, responses, 4) + resp, err := orderQF(ctx, responses, 4) if err != nil { if errors.Is(err, context.Canceled) { return @@ -193,7 +193,7 @@ func TestMixedOrdering(t *testing.T) { for time.Now().Before(stopTime) { req := Request_builder{Num: uint64(i)}.Build() ctx := context.Background() - resp, err := qfiter(ctx, cfg.QC(ctx, req), 4) + resp, err := orderQF(ctx, cfg.QC(ctx, req), 4) i++ if err != nil { t.Fatalf("QC error: %v", err) diff --git a/tests/qf/qf_test.go b/tests/qf/qf_test.go index 92bcd667b..0346661bf 100644 --- a/tests/qf/qf_test.go +++ b/tests/qf/qf_test.go @@ -93,15 +93,12 @@ func (q testQSpec) WithoutReqQF(replies map[uint32]*Response) (*Response, bool) return reply, true } -func UseReq(ctx context.Context, cfg *Configuration, quorum int, req *Request) (*Response, error) { - replies := int(0) - for response := range cfg.UseReq(ctx, req) { - msg, err, _ := response.Unpack() - if err != nil { - return nil, err - } - replies++ - if replies < quorum { +func IterUseReq(replies gorums.Iterator[*Response], quorum int, req *Request) (*Response, error) { + replyCount := 0 + for reply := range replies.IgnoreErrors() { + msg := reply.Msg + replyCount++ + if replyCount < quorum { continue } _ = req.GetValue() @@ -110,19 +107,16 @@ func UseReq(ctx context.Context, cfg *Configuration, quorum int, req *Request) ( return nil, errors.New("UseReq: quorum not found") } -func IgnoreReq(ctx context.Context, cfg *Configuration, quorum int, req *Request) (*Response, error) { - replies := 0 +func IterIgnoreReq(replies gorums.Iterator[*Response], quorum int) (*Response, error) { + replyCount := 0 var firstMsg *Response - for response := range cfg.IgnoreReq(ctx, req) { - msg, err, _ := response.Unpack() - if err != nil { - return nil, err - } + for reply := range replies.IgnoreErrors() { + msg := reply.Msg if firstMsg == nil { firstMsg = msg } - replies++ - if replies < quorum { + replyCount++ + if replyCount < quorum { continue } return firstMsg, nil @@ -212,6 +206,46 @@ func BenchmarkQF(b *testing.B) { } } }) + + b.Run(fmt.Sprintf("IterUseReq_%d", n), func(b *testing.B) { + for b.Loop() { + iterator := func(yield func(gorums.Response[*Response]) bool) { + for j := range n { + response := gorums.NewResponse( + Response_builder{Result: request.GetValue()}.Build(), + nil, + uint32(j), + ) + if !yield(response) { + return + } + } + } + + resp, _ := IterUseReq(iterator, qspec.quorum, request) + _ = resp.GetResult() + } + }) + + b.Run(fmt.Sprintf("IterIgnoreReq_%d", n), func(b *testing.B) { + for b.Loop() { + iterator := func(yield func(gorums.Response[*Response]) bool) { + for j := range n { + response := gorums.NewResponse( + Response_builder{Result: request.GetValue()}.Build(), + nil, + uint32(j), + ) + if !yield(response) { + return + } + } + } + + resp, _ := IterIgnoreReq(iterator, qspec.quorum) + _ = resp.GetResult() + } + }) } } @@ -251,7 +285,8 @@ func BenchmarkFullStackQF(b *testing.B) { b.Run(fmt.Sprintf("UseReq_%d", n), func(b *testing.B) { for b.Loop() { - resp, err := UseReq(context.Background(), c, quorum, Request_builder{Value: int64(requestValue)}.Build()) + req := Request_builder{Value: int64(requestValue)}.Build() + resp, err := IterUseReq(c.UseReq(context.Background(), req), quorum, req) if err != nil { b.Fatalf("UseReq error: %v", err) } @@ -260,7 +295,8 @@ func BenchmarkFullStackQF(b *testing.B) { }) b.Run(fmt.Sprintf("IgnoreReq_%d", n), func(b *testing.B) { for b.Loop() { - resp, err := IgnoreReq(context.Background(), c, quorum, Request_builder{Value: int64(requestValue)}.Build()) + req := Request_builder{Value: int64(requestValue)}.Build() + resp, err := IterIgnoreReq(c.IgnoreReq(context.Background(), req), quorum) if err != nil { b.Fatalf("IgnoreReq error: %v", err) } From d509a2332dd76752b24ee5b54688598e417d1b56 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sun, 20 Apr 2025 20:33:12 +0200 Subject: [PATCH 06/27] protoc-gen-go small changes --- benchmark/benchmark_gorums.pb.go | 61 ++++++++----------- cmd/protoc-gen-gorums/dev/config.go | 12 ++-- cmd/protoc-gen-gorums/dev/mgr.go | 6 -- .../dev/zorums_client_gorums.pb.go | 9 +-- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_quorumcall_gorums.pb.go | 2 +- .../dev/zorums_rpc_gorums.pb.go | 2 +- .../dev/zorums_server_gorums.pb.go | 2 +- .../dev/zorums_types_gorums.pb.go | 2 +- .../dev/zorums_unicast_gorums.pb.go | 12 ++-- .../gengorums/template_client.go | 2 +- .../gengorums/template_quorumcall.go | 11 ++-- .../gengorums/template_static.go | 18 ++---- tests/config/config_gorums.pb.go | 25 +++----- tests/correctable/correctable_gorums.pb.go | 33 +++++----- tests/dummy/dummy_gorums.pb.go | 25 +++----- tests/metadata/metadata_gorums.pb.go | 20 ++---- tests/oneway/oneway_gorums.pb.go | 34 +++++------ tests/ordering/order_gorums.pb.go | 36 +++++------ tests/qf/qf_gorums.pb.go | 31 ++++------ tests/tls/tls_gorums.pb.go | 25 +++----- tests/unresponsive/unresponsive_gorums.pb.go | 25 +++----- 22 files changed, 156 insertions(+), 239 deletions(-) diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index eacbf65d6..d548dfcbe 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: benchmark/benchmark.proto @@ -24,7 +24,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -37,11 +36,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -50,7 +44,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -98,12 +96,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -127,17 +119,11 @@ type Node struct { // BenchmarkClient is the client interface for the Benchmark service. type BenchmarkClient interface { StartServerBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] - StopServerBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*Result] - StartBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] - StopBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*MemoryStat] - QuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] - AsyncQuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] - SlowServer(ctx context.Context, in *Echo) gorums.Iterator[*Echo] Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption) } @@ -148,8 +134,9 @@ var _ BenchmarkClient = (*Configuration)(nil) // Reference imports to suppress errors if they are not otherwise used. var _ emptypb.Empty -// Multicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// Multicast is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, @@ -159,8 +146,9 @@ func (c *Configuration) Multicast(ctx context.Context, in *TimedMsg, opts ...gor c.RawConfiguration.Multicast(ctx, cd, opts...) } -// StartServerBenchmark is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// StartServerBenchmark is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] { cd := gorums.QuorumCallData{ Message: in, @@ -171,8 +159,9 @@ func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartReque return gorums.QuorumCall[*StartResponse](ctx, c.RawConfiguration, cd) } -// StopServerBenchmark is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// StopServerBenchmark is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*Result] { cd := gorums.QuorumCallData{ Message: in, @@ -183,8 +172,9 @@ func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest return gorums.QuorumCall[*Result](ctx, c.RawConfiguration, cd) } -// StartBenchmark is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// StartBenchmark is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] { cd := gorums.QuorumCallData{ Message: in, @@ -195,8 +185,9 @@ func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) go return gorums.QuorumCall[*StartResponse](ctx, c.RawConfiguration, cd) } -// StopBenchmark is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// StopBenchmark is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*MemoryStat] { cd := gorums.QuorumCallData{ Message: in, @@ -218,8 +209,9 @@ func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) gorums.Iterato return gorums.QuorumCall[*Echo](ctx, c.RawConfiguration, cd) } -// AsyncQuorumCall is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// AsyncQuorumCall is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] { cd := gorums.QuorumCallData{ Message: in, @@ -230,8 +222,9 @@ func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) gorums.It return gorums.QuorumCall[*Echo](ctx, c.RawConfiguration, cd) } -// SlowServer is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// SlowServer is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) SlowServer(ctx context.Context, in *Echo) gorums.Iterator[*Echo] { cd := gorums.QuorumCallData{ Message: in, diff --git a/cmd/protoc-gen-gorums/dev/config.go b/cmd/protoc-gen-gorums/dev/config.go index 18e7d9dcd..17bdafb81 100644 --- a/cmd/protoc-gen-gorums/dev/config.go +++ b/cmd/protoc-gen-gorums/dev/config.go @@ -8,7 +8,6 @@ import ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -21,11 +20,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -34,7 +28,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. diff --git a/cmd/protoc-gen-gorums/dev/mgr.go b/cmd/protoc-gen-gorums/dev/mgr.go index 7b0ab5232..3766435cc 100644 --- a/cmd/protoc-gen-gorums/dev/mgr.go +++ b/cmd/protoc-gen-gorums/dev/mgr.go @@ -39,12 +39,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index 2bc38abfd..733360b98 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: zorums.proto @@ -22,19 +22,12 @@ const ( // ZorumsServiceClient is the client interface for the ZorumsService service. type ZorumsServiceClient interface { QuorumCall(ctx context.Context, in *Request) gorums.Iterator[*Response] - QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] - QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] - QuorumCallEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] - QuorumCallStream(ctx context.Context, in *Request) gorums.Iterator[*Response] - QuorumCallStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] - QuorumCallStreamEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] - QuorumCallStreamEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) MulticastPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index d118e5e2a..6a281c2f7 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index e927783a7..3dd286409 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index 383fa5270..66e2f8ffe 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index 515aa1fd7..da5b3fd4c 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go index 0d8bc0f74..6c314cb39 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index 72f77af22..ebd721486 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: zorums.proto @@ -19,8 +19,9 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 9) ) -// Unicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// Unicast is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (n *Node) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, @@ -33,8 +34,9 @@ func (n *Node) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOpti // Reference imports to suppress errors if they are not otherwise used. var _ emptypb.Empty -// Unicast2 is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// Unicast2 is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (n *Node) Unicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, diff --git a/cmd/protoc-gen-gorums/gengorums/template_client.go b/cmd/protoc-gen-gorums/gengorums/template_client.go index bf4682c6b..3b3361d4d 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_client.go +++ b/cmd/protoc-gen-gorums/gengorums/template_client.go @@ -24,7 +24,7 @@ var clientConfigurationInterface = ` {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}, opts ...{{$callOpt}}) {{- else}} {{- $out := out $genFile .}} - {{$iterator := use "gorums.Iterator" $genFile}} + {{- $iterator := use "gorums.Iterator" $genFile}} {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) {{$iterator}}[*{{$out}}] {{- end}} {{- end}} diff --git a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go index e205bde0d..e94631a4c 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go +++ b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go @@ -20,15 +20,18 @@ var quorumCallComment = ` {{if ne $comments ""}} {{$comments -}} {{else}} -{{if hasPerNodeArg .Method}} // {{$method}} is a quorum call invoked on each node in configuration c, -// with the argument returned by the provided function f, and returns the combined result. +{{if hasPerNodeArg .Method}} +// with the argument returned by the provided function f, +// it returns the responses as an iterator. // The per node function f receives a copy of the {{$in}} request argument and // returns a {{$in}} manipulated to be passed to the given nodeID. // The function f must be thread-safe. {{else}} -// {{$method}} is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// with the same argument in, and returns the responses as an iterator. +{{end -}} +{{if isStream .Method}} +// This is a streaming quorum call, so each can respond with any amount of responses. {{end -}} {{end -}} ` diff --git a/cmd/protoc-gen-gorums/gengorums/template_static.go b/cmd/protoc-gen-gorums/gengorums/template_static.go index db2fe6231..ea183512e 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_static.go +++ b/cmd/protoc-gen-gorums/gengorums/template_static.go @@ -15,7 +15,6 @@ var staticCode = `// A Configuration represents a static set of nodes on which q // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -28,11 +27,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -41,7 +35,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -89,12 +87,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index 860f99754..acdd43c81 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: config/config.proto @@ -23,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -36,11 +35,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -49,7 +43,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -97,12 +95,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -131,8 +123,9 @@ type ConfigTestClient interface { // enforce interface compliance var _ ConfigTestClient = (*Configuration)(nil) -// Config is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// Config is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) Config(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ Message: in, diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 46aa80b56..2423a9c34 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: correctable/correctable.proto @@ -25,7 +25,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -38,11 +37,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -51,7 +45,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -99,12 +97,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -128,15 +120,15 @@ type Node struct { // CorrectableTestClient is the client interface for the CorrectableTest service. type CorrectableTestClient interface { Correctable(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] - CorrectableStream(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] } // enforce interface compliance var _ CorrectableTestClient = (*Configuration)(nil) -// Correctable is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// Correctable is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) Correctable(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] { cd := gorums.QuorumCallData{ Message: in, @@ -147,8 +139,11 @@ func (c *Configuration) Correctable(ctx context.Context, in *CorrectableRequest) return gorums.QuorumCall[*CorrectableResponse](ctx, c.RawConfiguration, cd) } -// CorrectableStream is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// CorrectableStream is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. + +// This is a streaming quorum call, so each can respond with any amount of responses. func (c *Configuration) CorrectableStream(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] { cd := gorums.QuorumCallData{ Message: in, diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index 51e43bd5d..41b23259d 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: dummy/dummy.proto @@ -23,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -36,11 +35,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -49,7 +43,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -97,12 +95,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -131,8 +123,9 @@ type DummyNodeClient interface { // enforce interface compliance var _ DummyNodeClient = (*Node)(nil) -// Test is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// Test is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (n *Node) Test(ctx context.Context, in *Empty) (resp *Empty, err error) { cd := gorums.CallData{ Message: in, diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index b571deacc..93c577c03 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: metadata/metadata.proto @@ -24,7 +24,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -37,11 +36,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -50,7 +44,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -98,12 +96,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index ee026a587..c6fc34f42 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: oneway/oneway.proto @@ -24,7 +24,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -37,11 +36,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -50,7 +44,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -98,12 +96,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -141,8 +133,9 @@ type OnewayTestNodeClient interface { // enforce interface compliance var _ OnewayTestNodeClient = (*Node)(nil) -// Multicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// Multicast is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, @@ -153,7 +146,9 @@ func (c *Configuration) Multicast(ctx context.Context, in *Request, opts ...goru } // MulticastPerNode is a quorum call invoked on each node in configuration c, -// with the argument returned by the provided function f, and returns the combined result. + +// with the argument returned by the provided function f, +// it returns the responses as an iterator. // The per node function f receives a copy of the Request request argument and // returns a Request manipulated to be passed to the given nodeID. // The function f must be thread-safe. @@ -195,8 +190,9 @@ func RegisterOnewayTestServer(srv *gorums.Server, impl OnewayTestServer) { }) } -// Unicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// Unicast is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (n *Node) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index c4451f45d..551b4b473 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: ordering/order.proto @@ -23,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -36,11 +35,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -49,7 +43,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -97,12 +95,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -126,7 +118,6 @@ type Node struct { // GorumsTestClient is the client interface for the GorumsTest service. type GorumsTestClient interface { QC(ctx context.Context, in *Request) gorums.Iterator[*Response] - QCAsync(ctx context.Context, in *Request) gorums.Iterator[*Response] } @@ -141,8 +132,9 @@ type GorumsTestNodeClient interface { // enforce interface compliance var _ GorumsTestNodeClient = (*Node)(nil) -// QC is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// QC is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) QC(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ Message: in, @@ -153,8 +145,9 @@ func (c *Configuration) QC(ctx context.Context, in *Request) gorums.Iterator[*Re return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } -// QCAsync is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// QCAsync is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) QCAsync(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ Message: in, @@ -165,8 +158,9 @@ func (c *Configuration) QCAsync(ctx context.Context, in *Request) gorums.Iterato return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } -// UnaryRPC is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// UnaryRPC is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (n *Node) UnaryRPC(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.CallData{ Message: in, diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 42a503f48..3bce2eae6 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: qf/qf.proto @@ -23,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -36,11 +35,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -49,7 +43,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -97,12 +95,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -126,15 +118,15 @@ type Node struct { // QuorumFunctionClient is the client interface for the QuorumFunction service. type QuorumFunctionClient interface { UseReq(ctx context.Context, in *Request) gorums.Iterator[*Response] - IgnoreReq(ctx context.Context, in *Request) gorums.Iterator[*Response] } // enforce interface compliance var _ QuorumFunctionClient = (*Configuration)(nil) -// UseReq is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// UseReq is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) UseReq(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ Message: in, @@ -145,8 +137,9 @@ func (c *Configuration) UseReq(ctx context.Context, in *Request) gorums.Iterator return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } -// IgnoreReq is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// IgnoreReq is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) IgnoreReq(ctx context.Context, in *Request) gorums.Iterator[*Response] { cd := gorums.QuorumCallData{ Message: in, diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 19507115b..668ca94ca 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: tls/tls.proto @@ -23,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -36,11 +35,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -49,7 +43,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -97,12 +95,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -131,8 +123,9 @@ type TLSNodeClient interface { // enforce interface compliance var _ TLSNodeClient = (*Node)(nil) -// TestTLS is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// TestTLS is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (n *Node) TestTLS(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.CallData{ Message: in, diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index 6df15e8ce..a338a6d62 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+71bed4a8 +// protoc-gen-gorums v0.9.0-devel+0ae59408 // protoc v6.30.2 // source: unresponsive/unresponsive.proto @@ -23,7 +23,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -36,11 +35,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -49,7 +43,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -97,12 +95,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -131,8 +123,9 @@ type UnresponsiveNodeClient interface { // enforce interface compliance var _ UnresponsiveNodeClient = (*Node)(nil) -// TestUnresponsive is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// TestUnresponsive is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (n *Node) TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) { cd := gorums.CallData{ Message: in, From a34a05f92df5066dc9d9ed3568e0cf08683a5eb8 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Tue, 22 Apr 2025 14:21:42 +0200 Subject: [PATCH 07/27] fix example error handling --- examples/storage/repl.go | 47 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/examples/storage/repl.go b/examples/storage/repl.go index 43929a822..2e5ed74ee 100644 --- a/examples/storage/repl.go +++ b/examples/storage/repl.go @@ -249,24 +249,18 @@ func (repl) writeRPC(args []string, node *pb.Node) { fmt.Println("Write OK") } -func readqc(cfg *pb.Configuration, ctx context.Context, req *pb.ReadRequest) (*pb.ReadResponse, error) { - cfgSize := cfg.Size() - +func readQF(replies gorums.Iterator[*pb.ReadResponse], quorum int) (*pb.ReadResponse, error) { var newest *pb.ReadResponse - replies := int(0) - for response := range cfg.ReadQC(ctx, req) { - msg, err, _ := response.Unpack() - if err != nil { - return nil, err - } - replies++ - newest = newestValueOfTwo(msg, newest) - if replies <= cfgSize/2 { + replyCount := int(0) + for reply := range replies.IgnoreErrors() { + newest = newestValueOfTwo(newest, reply.Msg) + replyCount++ + if replyCount <= quorum { continue } return newest, nil } - return nil, errors.New("storage.readqc: Error unreachable") + return nil, errors.New("storage.readqc: quorum not found") } func (repl) readQC(args []string, cfg *pb.Configuration) { @@ -276,7 +270,8 @@ func (repl) readQC(args []string, cfg *pb.Configuration) { } ctx, cancel := context.WithTimeout(context.Background(), time.Second) - resp, err := readqc(cfg, ctx, pb.ReadRequest_builder{Key: args[0]}.Build()) + req := pb.ReadRequest_builder{Key: args[0]}.Build() + resp, err := readQF(cfg.ReadQC(ctx, req), cfg.Size()/2) cancel() if err != nil { @@ -290,19 +285,12 @@ func (repl) readQC(args []string, cfg *pb.Configuration) { fmt.Printf("%s = %s\n", args[0], resp.GetValue()) } -func writeqc(cfg *pb.Configuration, ctx context.Context, req *pb.WriteRequest) (*pb.WriteResponse, error) { - cfgSize := cfg.Size() - - replies := int(0) +func writeQF(replies gorums.Iterator[*pb.WriteResponse], cfgSize int) (*pb.WriteResponse, error) { + replyCount := int(0) updated := int(0) - for response := range cfg.WriteQC(ctx, req) { - msg, err, _ := response.Unpack() - - if err != nil { - return nil, err - } - replies++ - if isUpdated(msg) { + for response := range replies.IgnoreErrors() { + replyCount++ + if isUpdated(response.Msg) { updated++ } if updated > cfgSize/2 { @@ -310,11 +298,11 @@ func writeqc(cfg *pb.Configuration, ctx context.Context, req *pb.WriteRequest) ( } // if all replicas have responded, there must have been another write before ours // that had a newer timestamp - if replies == cfgSize { + if replyCount == cfgSize { return proto.WriteResponse_builder{New: false}.Build(), nil } } - return nil, errors.New("storage.writeqc: Error unreachable") + return nil, errors.New("storage.writeqc: incomplete response") } func (repl) writeQC(args []string, cfg *pb.Configuration) { @@ -323,7 +311,8 @@ func (repl) writeQC(args []string, cfg *pb.Configuration) { return } ctx, cancel := context.WithTimeout(context.Background(), time.Second) - resp, err := writeqc(cfg, ctx, pb.WriteRequest_builder{Key: args[0], Value: args[1], Time: timestamppb.Now()}.Build()) + req := pb.WriteRequest_builder{Key: args[0], Value: args[1], Time: timestamppb.Now()}.Build() + resp, err := writeQF(cfg.WriteQC(ctx, req), cfg.Size()) cancel() if err != nil { fmt.Printf("Write RPC finished with error: %v\n", err) From 206a5710f07b1fac0b4cbc2cd4f9b70a480c8ae0 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sun, 27 Apr 2025 17:50:23 +0200 Subject: [PATCH 08/27] remove benchmark.MemoryStatList --- benchmark/benchmark.pb.go | 129 ++++++++++---------------------------- benchmark/benchmark.proto | 4 -- 2 files changed, 33 insertions(+), 100 deletions(-) diff --git a/benchmark/benchmark.pb.go b/benchmark/benchmark.pb.go index 946512671..10aa6a49d 100644 --- a/benchmark/benchmark.pb.go +++ b/benchmark/benchmark.pb.go @@ -527,65 +527,6 @@ func (b0 MemoryStat_builder) Build() *MemoryStat { return m0 } -type MemoryStatList struct { - state protoimpl.MessageState `protogen:"opaque.v1"` - xxx_hidden_MemoryStats *[]*MemoryStat `protobuf:"bytes,1,rep,name=MemoryStats"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *MemoryStatList) Reset() { - *x = MemoryStatList{} - mi := &file_benchmark_benchmark_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *MemoryStatList) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MemoryStatList) ProtoMessage() {} - -func (x *MemoryStatList) ProtoReflect() protoreflect.Message { - mi := &file_benchmark_benchmark_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -func (x *MemoryStatList) GetMemoryStats() []*MemoryStat { - if x != nil { - if x.xxx_hidden_MemoryStats != nil { - return *x.xxx_hidden_MemoryStats - } - } - return nil -} - -func (x *MemoryStatList) SetMemoryStats(v []*MemoryStat) { - x.xxx_hidden_MemoryStats = &v -} - -type MemoryStatList_builder struct { - _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. - - MemoryStats []*MemoryStat -} - -func (b0 MemoryStatList_builder) Build() *MemoryStatList { - m0 := &MemoryStatList{} - b, x := &b0, m0 - _, _ = b, x - x.xxx_hidden_MemoryStats = &b.MemoryStats - return m0 -} - var File_benchmark_benchmark_proto protoreflect.FileDescriptor const file_benchmark_benchmark_proto_rawDesc = "" + @@ -618,9 +559,7 @@ const file_benchmark_benchmark_proto_rawDesc = "" + "\n" + "MemoryStat\x12\x16\n" + "\x06Allocs\x18\x01 \x01(\x04R\x06Allocs\x12\x16\n" + - "\x06Memory\x18\x02 \x01(\x04R\x06Memory\"I\n" + - "\x0eMemoryStatList\x127\n" + - "\vMemoryStats\x18\x01 \x03(\v2\x15.benchmark.MemoryStatR\vMemoryStats2\x9c\x04\n" + + "\x06Memory\x18\x02 \x01(\x04R\x06Memory2\x9c\x04\n" + "\tBenchmark\x12O\n" + "\x14StartServerBenchmark\x12\x17.benchmark.StartRequest\x1a\x18.benchmark.StartResponse\"\x04\xa0\xb5\x18\x01\x12F\n" + "\x13StopServerBenchmark\x12\x16.benchmark.StopRequest\x1a\x11.benchmark.Result\"\x04\xa0\xb5\x18\x01\x12I\n" + @@ -633,42 +572,40 @@ const file_benchmark_benchmark_proto_rawDesc = "" + "SlowServer\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x12>\n" + "\tMulticast\x12\x13.benchmark.TimedMsg\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01B(Z!github.com/relab/gorums/benchmark\x92\x03\x02\b\x02b\beditionsp\xe8\a" -var file_benchmark_benchmark_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_benchmark_benchmark_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_benchmark_benchmark_proto_goTypes = []any{ - (*Echo)(nil), // 0: benchmark.Echo - (*TimedMsg)(nil), // 1: benchmark.TimedMsg - (*StartRequest)(nil), // 2: benchmark.StartRequest - (*StartResponse)(nil), // 3: benchmark.StartResponse - (*StopRequest)(nil), // 4: benchmark.StopRequest - (*Result)(nil), // 5: benchmark.Result - (*MemoryStat)(nil), // 6: benchmark.MemoryStat - (*MemoryStatList)(nil), // 7: benchmark.MemoryStatList - (*emptypb.Empty)(nil), // 8: google.protobuf.Empty + (*Echo)(nil), // 0: benchmark.Echo + (*TimedMsg)(nil), // 1: benchmark.TimedMsg + (*StartRequest)(nil), // 2: benchmark.StartRequest + (*StartResponse)(nil), // 3: benchmark.StartResponse + (*StopRequest)(nil), // 4: benchmark.StopRequest + (*Result)(nil), // 5: benchmark.Result + (*MemoryStat)(nil), // 6: benchmark.MemoryStat + (*emptypb.Empty)(nil), // 7: google.protobuf.Empty } var file_benchmark_benchmark_proto_depIdxs = []int32{ - 6, // 0: benchmark.Result.ServerStats:type_name -> benchmark.MemoryStat - 6, // 1: benchmark.MemoryStatList.MemoryStats:type_name -> benchmark.MemoryStat - 2, // 2: benchmark.Benchmark.StartServerBenchmark:input_type -> benchmark.StartRequest - 4, // 3: benchmark.Benchmark.StopServerBenchmark:input_type -> benchmark.StopRequest - 2, // 4: benchmark.Benchmark.StartBenchmark:input_type -> benchmark.StartRequest - 4, // 5: benchmark.Benchmark.StopBenchmark:input_type -> benchmark.StopRequest - 0, // 6: benchmark.Benchmark.QuorumCall:input_type -> benchmark.Echo - 0, // 7: benchmark.Benchmark.AsyncQuorumCall:input_type -> benchmark.Echo - 0, // 8: benchmark.Benchmark.SlowServer:input_type -> benchmark.Echo - 1, // 9: benchmark.Benchmark.Multicast:input_type -> benchmark.TimedMsg - 3, // 10: benchmark.Benchmark.StartServerBenchmark:output_type -> benchmark.StartResponse - 5, // 11: benchmark.Benchmark.StopServerBenchmark:output_type -> benchmark.Result - 3, // 12: benchmark.Benchmark.StartBenchmark:output_type -> benchmark.StartResponse - 6, // 13: benchmark.Benchmark.StopBenchmark:output_type -> benchmark.MemoryStat - 0, // 14: benchmark.Benchmark.QuorumCall:output_type -> benchmark.Echo - 0, // 15: benchmark.Benchmark.AsyncQuorumCall:output_type -> benchmark.Echo - 0, // 16: benchmark.Benchmark.SlowServer:output_type -> benchmark.Echo - 8, // 17: benchmark.Benchmark.Multicast:output_type -> google.protobuf.Empty - 10, // [10:18] is the sub-list for method output_type - 2, // [2:10] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 6, // 0: benchmark.Result.ServerStats:type_name -> benchmark.MemoryStat + 2, // 1: benchmark.Benchmark.StartServerBenchmark:input_type -> benchmark.StartRequest + 4, // 2: benchmark.Benchmark.StopServerBenchmark:input_type -> benchmark.StopRequest + 2, // 3: benchmark.Benchmark.StartBenchmark:input_type -> benchmark.StartRequest + 4, // 4: benchmark.Benchmark.StopBenchmark:input_type -> benchmark.StopRequest + 0, // 5: benchmark.Benchmark.QuorumCall:input_type -> benchmark.Echo + 0, // 6: benchmark.Benchmark.AsyncQuorumCall:input_type -> benchmark.Echo + 0, // 7: benchmark.Benchmark.SlowServer:input_type -> benchmark.Echo + 1, // 8: benchmark.Benchmark.Multicast:input_type -> benchmark.TimedMsg + 3, // 9: benchmark.Benchmark.StartServerBenchmark:output_type -> benchmark.StartResponse + 5, // 10: benchmark.Benchmark.StopServerBenchmark:output_type -> benchmark.Result + 3, // 11: benchmark.Benchmark.StartBenchmark:output_type -> benchmark.StartResponse + 6, // 12: benchmark.Benchmark.StopBenchmark:output_type -> benchmark.MemoryStat + 0, // 13: benchmark.Benchmark.QuorumCall:output_type -> benchmark.Echo + 0, // 14: benchmark.Benchmark.AsyncQuorumCall:output_type -> benchmark.Echo + 0, // 15: benchmark.Benchmark.SlowServer:output_type -> benchmark.Echo + 7, // 16: benchmark.Benchmark.Multicast:output_type -> google.protobuf.Empty + 9, // [9:17] is the sub-list for method output_type + 1, // [1:9] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_benchmark_benchmark_proto_init() } @@ -682,7 +619,7 @@ func file_benchmark_benchmark_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_benchmark_benchmark_proto_rawDesc), len(file_benchmark_benchmark_proto_rawDesc)), NumEnums: 0, - NumMessages: 8, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/benchmark/benchmark.proto b/benchmark/benchmark.proto index 493a5d26d..845d93af5 100644 --- a/benchmark/benchmark.proto +++ b/benchmark/benchmark.proto @@ -42,10 +42,6 @@ message MemoryStat { uint64 Memory = 2; } -message MemoryStatList { - repeated MemoryStat MemoryStats = 1; -} - service Benchmark { rpc StartServerBenchmark(StartRequest) returns (StartResponse) { option (gorums.quorumcall) = true; From 83910400e3880c74e13e86c4fe834da477e6379a Mon Sep 17 00:00:00 2001 From: asbjorn Date: Tue, 6 May 2025 17:29:39 +0200 Subject: [PATCH 09/27] recompile proto files --- benchmark/benchmark.pb.go | 125 +++++++++++------- benchmark/benchmark_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/dev/zorums.pb.go | 113 +++++++++++----- .../dev/zorums_client_gorums.pb.go | 2 +- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_quorumcall_gorums.pb.go | 2 +- .../dev/zorums_rpc_gorums.pb.go | 2 +- .../dev/zorums_server_gorums.pb.go | 2 +- .../dev/zorums_types_gorums.pb.go | 2 +- .../dev/zorums_unicast_gorums.pb.go | 2 +- gorums.pb.go | 45 +++++-- internal/correctable/opts.pb.go | 32 +++-- ordering/ordering.pb.go | 47 ++++--- tests/config/config.pb.go | 35 +++-- tests/config/config_gorums.pb.go | 2 +- tests/correctable/correctable.pb.go | 42 ++++-- tests/correctable/correctable_gorums.pb.go | 2 +- tests/dummy/dummy.pb.go | 23 ++-- tests/dummy/dummy_gorums.pb.go | 2 +- tests/metadata/metadata.pb.go | 38 ++++-- tests/metadata/metadata_gorums.pb.go | 2 +- tests/oneway/oneway.pb.go | 39 ++++-- tests/oneway/oneway_gorums.pb.go | 2 +- tests/ordering/order.pb.go | 42 +++--- tests/ordering/order_gorums.pb.go | 2 +- tests/qf/qf.pb.go | 35 +++-- tests/qf/qf_gorums.pb.go | 2 +- tests/tls/tls.pb.go | 27 ++-- tests/tls/tls_gorums.pb.go | 2 +- tests/unresponsive/unresponsive.pb.go | 27 ++-- tests/unresponsive/unresponsive_gorums.pb.go | 2 +- 31 files changed, 459 insertions(+), 245 deletions(-) diff --git a/benchmark/benchmark.pb.go b/benchmark/benchmark.pb.go index 10aa6a49d..70f01876a 100644 --- a/benchmark/benchmark.pb.go +++ b/benchmark/benchmark.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: benchmark/benchmark.proto @@ -12,7 +12,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" - unsafe "unsafe" ) const ( @@ -529,48 +528,83 @@ func (b0 MemoryStat_builder) Build() *MemoryStat { var File_benchmark_benchmark_proto protoreflect.FileDescriptor -const file_benchmark_benchmark_proto_rawDesc = "" + - "\n" + - "\x19benchmark/benchmark.proto\x12\tbenchmark\x1a\x1bgoogle/protobuf/empty.proto\x1a\fgorums.proto\" \n" + - "\x04Echo\x12\x18\n" + - "\apayload\x18\x01 \x01(\fR\apayload\"@\n" + - "\bTimedMsg\x12\x1a\n" + - "\bSendTime\x18\x01 \x01(\x03R\bSendTime\x12\x18\n" + - "\apayload\x18\x02 \x01(\fR\apayload\"\x0e\n" + - "\fStartRequest\"\x0f\n" + - "\rStartResponse\"\r\n" + - "\vStopRequest\"\xad\x02\n" + - "\x06Result\x12\x12\n" + - "\x04Name\x18\x01 \x01(\tR\x04Name\x12\x1a\n" + - "\bTotalOps\x18\x02 \x01(\x04R\bTotalOps\x12\x1c\n" + - "\tTotalTime\x18\x03 \x01(\x03R\tTotalTime\x12\x1e\n" + - "\n" + - "Throughput\x18\x04 \x01(\x01R\n" + - "Throughput\x12\x1e\n" + - "\n" + - "LatencyAvg\x18\x05 \x01(\x01R\n" + - "LatencyAvg\x12\x1e\n" + - "\n" + - "LatencyVar\x18\x06 \x01(\x01R\n" + - "LatencyVar\x12 \n" + - "\vAllocsPerOp\x18\a \x01(\x04R\vAllocsPerOp\x12\x1a\n" + - "\bMemPerOp\x18\b \x01(\x04R\bMemPerOp\x127\n" + - "\vServerStats\x18\t \x03(\v2\x15.benchmark.MemoryStatR\vServerStats\"<\n" + - "\n" + - "MemoryStat\x12\x16\n" + - "\x06Allocs\x18\x01 \x01(\x04R\x06Allocs\x12\x16\n" + - "\x06Memory\x18\x02 \x01(\x04R\x06Memory2\x9c\x04\n" + - "\tBenchmark\x12O\n" + - "\x14StartServerBenchmark\x12\x17.benchmark.StartRequest\x1a\x18.benchmark.StartResponse\"\x04\xa0\xb5\x18\x01\x12F\n" + - "\x13StopServerBenchmark\x12\x16.benchmark.StopRequest\x1a\x11.benchmark.Result\"\x04\xa0\xb5\x18\x01\x12I\n" + - "\x0eStartBenchmark\x12\x17.benchmark.StartRequest\x1a\x18.benchmark.StartResponse\"\x04\xa0\xb5\x18\x01\x12D\n" + - "\rStopBenchmark\x12\x16.benchmark.StopRequest\x1a\x15.benchmark.MemoryStat\"\x04\xa0\xb5\x18\x01\x124\n" + - "\n" + - "QuorumCall\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x129\n" + - "\x0fAsyncQuorumCall\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x124\n" + - "\n" + - "SlowServer\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x12>\n" + - "\tMulticast\x12\x13.benchmark.TimedMsg\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01B(Z!github.com/relab/gorums/benchmark\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_benchmark_benchmark_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2f, 0x62, 0x65, 0x6e, 0x63, + 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x62, 0x65, 0x6e, + 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x20, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x22, 0x40, 0x0a, 0x08, 0x54, 0x69, 0x6d, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x12, + 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x08, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x0e, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xad, 0x02, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4f, 0x70, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4f, 0x70, 0x73, + 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x09, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x54, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x70, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x01, 0x52, 0x0a, 0x54, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x70, 0x75, 0x74, 0x12, 0x1e, + 0x0a, 0x0a, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x41, 0x76, 0x67, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x01, 0x52, 0x0a, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x41, 0x76, 0x67, 0x12, 0x1e, + 0x0a, 0x0a, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x56, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x01, 0x52, 0x0a, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x56, 0x61, 0x72, 0x12, 0x20, + 0x0a, 0x0b, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x50, 0x65, 0x72, 0x4f, 0x70, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0b, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x50, 0x65, 0x72, 0x4f, 0x70, + 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x65, 0x6d, 0x50, 0x65, 0x72, 0x4f, 0x70, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x08, 0x4d, 0x65, 0x6d, 0x50, 0x65, 0x72, 0x4f, 0x70, 0x12, 0x37, 0x0a, 0x0b, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x4d, 0x65, + 0x6d, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x52, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x22, 0x3c, 0x0a, 0x0a, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x53, + 0x74, 0x61, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x06, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x4d, + 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x4d, 0x65, 0x6d, + 0x6f, 0x72, 0x79, 0x32, 0x9c, 0x04, 0x0a, 0x09, 0x42, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, + 0x6b, 0x12, 0x4f, 0x0a, 0x14, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x42, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x17, 0x2e, 0x62, 0x65, 0x6e, 0x63, + 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, + 0x18, 0x01, 0x12, 0x46, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x70, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x42, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x16, 0x2e, 0x62, 0x65, 0x6e, 0x63, + 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x52, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x49, 0x0a, 0x0e, 0x53, 0x74, + 0x61, 0x72, 0x74, 0x42, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x17, 0x2e, 0x62, + 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, + 0x6b, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x44, 0x0a, 0x0d, 0x53, 0x74, 0x6f, 0x70, 0x42, 0x65, 0x6e, + 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x16, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, + 0x72, 0x6b, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, + 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x4d, 0x65, 0x6d, 0x6f, 0x72, + 0x79, 0x53, 0x74, 0x61, 0x74, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x34, 0x0a, 0x0a, 0x51, + 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0f, 0x2e, 0x62, 0x65, 0x6e, 0x63, + 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x1a, 0x0f, 0x2e, 0x62, 0x65, 0x6e, + 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x22, 0x04, 0xa0, 0xb5, 0x18, + 0x01, 0x12, 0x39, 0x0a, 0x0f, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, + 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0f, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, + 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x1a, 0x0f, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, + 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x34, 0x0a, 0x0a, + 0x53, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0f, 0x2e, 0x62, 0x65, 0x6e, + 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x1a, 0x0f, 0x2e, 0x62, 0x65, + 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x22, 0x04, 0xa0, 0xb5, + 0x18, 0x01, 0x12, 0x3e, 0x0a, 0x09, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, + 0x13, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x64, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x98, 0xb5, + 0x18, 0x01, 0x42, 0x28, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x62, 0x65, + 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_benchmark_benchmark_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_benchmark_benchmark_proto_goTypes = []any{ @@ -617,7 +651,7 @@ func file_benchmark_benchmark_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_benchmark_benchmark_proto_rawDesc), len(file_benchmark_benchmark_proto_rawDesc)), + RawDescriptor: file_benchmark_benchmark_proto_rawDesc, NumEnums: 0, NumMessages: 7, NumExtensions: 0, @@ -628,6 +662,7 @@ func file_benchmark_benchmark_proto_init() { MessageInfos: file_benchmark_benchmark_proto_msgTypes, }.Build() File_benchmark_benchmark_proto = out.File + file_benchmark_benchmark_proto_rawDesc = nil file_benchmark_benchmark_proto_goTypes = nil file_benchmark_benchmark_proto_depIdxs = nil } diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index d548dfcbe..2154981c1 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: benchmark/benchmark.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums.pb.go index 52c8d2571..d4fa3b759 100644 --- a/cmd/protoc-gen-gorums/dev/zorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: zorums.proto @@ -12,7 +12,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" - unsafe "unsafe" ) const ( @@ -195,37 +194,82 @@ func (b0 MyResponse_builder) Build() *MyResponse { var File_zorums_proto protoreflect.FileDescriptor -const file_zorums_proto_rawDesc = "" + - "\n" + - "\fzorums.proto\x12\x03dev\x1a\fgorums.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x1f\n" + - "\aRequest\x12\x14\n" + - "\x05Value\x18\x01 \x01(\tR\x05Value\"\"\n" + - "\bResponse\x12\x16\n" + - "\x06Result\x18\x01 \x01(\x03R\x06Result\"\"\n" + - "\n" + - "MyResponse\x12\x14\n" + - "\x05Value\x18\x01 \x01(\tR\x05Value2\xbd\a\n" + - "\rZorumsService\x12)\n" + - "\bGRPCCall\x12\f.dev.Request\x1a\r.dev.Response\"\x00\x12/\n" + - "\n" + - "QuorumCall\x12\f.dev.Request\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x01\x12=\n" + - "\x14QuorumCallPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01\xa0\xb6\x18\x01\x12>\n" + - "\x0fQuorumCallEmpty\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x01\x12>\n" + - "\x10QuorumCallEmpty2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa0\xb5\x18\x01\x127\n" + - "\x10QuorumCallStream\x12\f.dev.Request\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x010\x01\x12E\n" + - "\x1aQuorumCallStreamPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01\xa0\xb6\x18\x010\x01\x12F\n" + - "\x15QuorumCallStreamEmpty\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x010\x01\x12F\n" + - "\x16QuorumCallStreamEmpty2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa0\xb5\x18\x010\x01\x12.\n" + - "\tMulticast\x12\f.dev.Request\x1a\r.dev.Response\"\x04\x98\xb5\x18\x01\x12<\n" + - "\x13MulticastPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\x98\xb5\x18\x01\xa0\xb6\x18\x01\x12/\n" + - "\n" + - "Multicast2\x12\f.dev.Request\x1a\r.dev.Response\"\x04\x98\xb5\x18\x01\x128\n" + - "\n" + - "Multicast3\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01\x12B\n" + - "\n" + - "Multicast4\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01\x12,\n" + - "\aUnicast\x12\f.dev.Request\x1a\r.dev.Response\"\x04\x90\xb5\x18\x01\x126\n" + - "\bUnicast2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\x90\xb5\x18\x01B Z\x19cmd/protoc-gen-gorums/dev\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_zorums_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x7a, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, + 0x64, 0x65, 0x76, 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, + 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, + 0x22, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x52, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x22, 0x22, 0x0a, 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32, 0xbd, 0x07, 0x0a, 0x0d, 0x5a, 0x6f, 0x72, 0x75, + 0x6d, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x47, 0x52, 0x50, + 0x43, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x0a, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, + 0x6c, 0x6c, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x3d, 0x0a, 0x14, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, + 0x61, 0x6c, 0x6c, 0x50, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x72, 0x67, 0x12, 0x0c, 0x2e, + 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, + 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x08, 0xa0, 0xb5, 0x18, 0x01, + 0xa0, 0xb6, 0x18, 0x01, 0x12, 0x3e, 0x0a, 0x0f, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, + 0x6c, 0x6c, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, + 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, + 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x3e, 0x0a, 0x10, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, + 0x6c, 0x6c, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, + 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x37, 0x0a, 0x10, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, + 0x6c, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x30, 0x01, 0x12, 0x45, 0x0a, + 0x1a, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x50, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x72, 0x67, 0x12, 0x0c, 0x2e, 0x64, 0x65, + 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x08, 0xa0, 0xb5, 0x18, 0x01, 0xa0, 0xb6, + 0x18, 0x01, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x15, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, + 0x6c, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x16, + 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0xa0, 0xb5, + 0x18, 0x01, 0x30, 0x01, 0x12, 0x2e, 0x0a, 0x09, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, + 0x74, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, + 0x98, 0xb5, 0x18, 0x01, 0x12, 0x3c, 0x0a, 0x13, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, + 0x74, 0x50, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x72, 0x67, 0x12, 0x0c, 0x2e, 0x64, 0x65, + 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x08, 0x98, 0xb5, 0x18, 0x01, 0xa0, 0xb6, + 0x18, 0x01, 0x12, 0x2f, 0x0a, 0x0a, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x32, + 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, + 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0x98, + 0xb5, 0x18, 0x01, 0x12, 0x38, 0x0a, 0x0a, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, + 0x33, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x98, 0xb5, 0x18, 0x01, 0x12, 0x42, 0x0a, + 0x0a, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x34, 0x12, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x98, 0xb5, 0x18, + 0x01, 0x12, 0x2c, 0x0a, 0x07, 0x55, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x0c, 0x2e, 0x64, + 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0x90, 0xb5, 0x18, 0x01, 0x12, + 0x36, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x32, 0x12, 0x0c, 0x2e, 0x64, 0x65, + 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x22, 0x04, 0x90, 0xb5, 0x18, 0x01, 0x42, 0x20, 0x5a, 0x19, 0x63, 0x6d, 0x64, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, + 0x2f, 0x64, 0x65, 0x76, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_zorums_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_zorums_proto_goTypes = []any{ @@ -283,7 +327,7 @@ func file_zorums_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_zorums_proto_rawDesc), len(file_zorums_proto_rawDesc)), + RawDescriptor: file_zorums_proto_rawDesc, NumEnums: 0, NumMessages: 3, NumExtensions: 0, @@ -294,6 +338,7 @@ func file_zorums_proto_init() { MessageInfos: file_zorums_proto_msgTypes, }.Build() File_zorums_proto = out.File + file_zorums_proto_rawDesc = nil file_zorums_proto_goTypes = nil file_zorums_proto_depIdxs = nil } diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index 733360b98..0e486dca6 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index 6a281c2f7..cee71ca7f 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index 3dd286409..66b036f5c 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index 66e2f8ffe..1ba3b2c7a 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index da5b3fd4c..995d0da57 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go index 6c314cb39..c0ed132d7 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index ebd721486..178231aa3 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: zorums.proto diff --git a/gorums.pb.go b/gorums.pb.go index 062b1b324..a542ee9b0 100644 --- a/gorums.pb.go +++ b/gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: gorums.proto @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" - unsafe "unsafe" ) const ( @@ -84,17 +83,34 @@ var ( var File_gorums_proto protoreflect.FileDescriptor -const file_gorums_proto_rawDesc = "" + - "\n" + - "\fgorums.proto\x12\x06gorums\x1a google/protobuf/descriptor.proto:2\n" + - "\x03rpc\x12\x1e.google.protobuf.MethodOptions\x18ั†\x03 \x01(\bR\x03rpc::\n" + - "\aunicast\x12\x1e.google.protobuf.MethodOptions\x18า†\x03 \x01(\bR\aunicast:>\n" + - "\tmulticast\x12\x1e.google.protobuf.MethodOptions\x18ำ†\x03 \x01(\bR\tmulticast:@\n" + - "\n" + - "quorumcall\x12\x1e.google.protobuf.MethodOptions\x18ิ†\x03 \x01(\bR\n" + - "quorumcall:B\n" + - "\fper_node_arg\x12\x1e.google.protobuf.MethodOptions\x18\xe4\x86\x03 \x01(\bR\n" + - "perNodeArgB\x1eZ\x17github.com/relab/gorums\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_gorums_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, + 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x32, 0x0a, 0x03, 0x72, 0x70, 0x63, 0x12, + 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0xd1, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x72, 0x70, 0x63, 0x3a, 0x3a, 0x0a, 0x07, + 0x75, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd2, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x07, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x3a, 0x3e, 0x0a, 0x09, 0x6d, 0x75, 0x6c, 0x74, + 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd3, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6d, + 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x3a, 0x40, 0x0a, 0x0a, 0x71, 0x75, 0x6f, 0x72, + 0x75, 0x6d, 0x63, 0x61, 0x6c, 0x6c, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd4, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x71, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x63, 0x61, 0x6c, 0x6c, 0x3a, 0x42, 0x0a, 0x0c, 0x70, 0x65, + 0x72, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x61, 0x72, 0x67, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xe4, 0x86, 0x03, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x72, 0x67, 0x42, 0x1e, + 0x5a, 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, + 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, + 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_gorums_proto_goTypes = []any{ (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions @@ -121,7 +137,7 @@ func file_gorums_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_gorums_proto_rawDesc), len(file_gorums_proto_rawDesc)), + RawDescriptor: file_gorums_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 5, @@ -132,6 +148,7 @@ func file_gorums_proto_init() { ExtensionInfos: file_gorums_proto_extTypes, }.Build() File_gorums_proto = out.File + file_gorums_proto_rawDesc = nil file_gorums_proto_goTypes = nil file_gorums_proto_depIdxs = nil } diff --git a/internal/correctable/opts.pb.go b/internal/correctable/opts.pb.go index d5b8e7053..9810986c1 100644 --- a/internal/correctable/opts.pb.go +++ b/internal/correctable/opts.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: internal/correctable/opts.proto @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" - unsafe "unsafe" ) const ( @@ -50,11 +49,27 @@ var ( var File_internal_correctable_opts_proto protoreflect.FileDescriptor -const file_internal_correctable_opts_proto_rawDesc = "" + - "\n" + - "\x1finternal/correctable/opts.proto\x12\vcorrectable\x1a google/protobuf/descriptor.proto:A\n" + - "\vcorrectable\x12\x1e.google.protobuf.MethodOptions\x18\xb80 \x01(\bR\vcorrectable:N\n" + - "\x12correctable_stream\x12\x1e.google.protobuf.MethodOptions\x18\xb90 \x01(\bR\x11correctableStreamB3Z,github.com/relab/gorums/internal/correctable\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_internal_correctable_opts_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x72, 0x72, 0x65, + 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2f, 0x6f, 0x70, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x1a, 0x20, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x3a, 0x41, 0x0a, 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, + 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0xb8, 0x30, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x3a, 0x4e, 0x0a, 0x12, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, + 0x6c, 0x65, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb9, 0x30, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x11, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x42, 0x33, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_internal_correctable_opts_proto_goTypes = []any{ (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions @@ -78,7 +93,7 @@ func file_internal_correctable_opts_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_correctable_opts_proto_rawDesc), len(file_internal_correctable_opts_proto_rawDesc)), + RawDescriptor: file_internal_correctable_opts_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 2, @@ -89,6 +104,7 @@ func file_internal_correctable_opts_proto_init() { ExtensionInfos: file_internal_correctable_opts_proto_extTypes, }.Build() File_internal_correctable_opts_proto = out.File + file_internal_correctable_opts_proto_rawDesc = nil file_internal_correctable_opts_proto_goTypes = nil file_internal_correctable_opts_proto_depIdxs = nil } diff --git a/ordering/ordering.pb.go b/ordering/ordering.pb.go index 489bf8de8..1410143db 100644 --- a/ordering/ordering.pb.go +++ b/ordering/ordering.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: ordering/ordering.proto @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -209,20 +208,33 @@ func (b0 MetadataEntry_builder) Build() *MetadataEntry { var File_ordering_ordering_proto protoreflect.FileDescriptor -const file_ordering_ordering_proto_rawDesc = "" + - "\n" + - "\x17ordering/ordering.proto\x12\bordering\x1a\x17google/rpc/status.proto\"\x9b\x01\n" + - "\bMetadata\x12\x1c\n" + - "\tMessageID\x18\x01 \x01(\x04R\tMessageID\x12\x16\n" + - "\x06Method\x18\x02 \x01(\tR\x06Method\x12*\n" + - "\x06Status\x18\x03 \x01(\v2\x12.google.rpc.StatusR\x06Status\x12-\n" + - "\x05Entry\x18\x04 \x03(\v2\x17.ordering.MetadataEntryR\x05Entry\"7\n" + - "\rMetadataEntry\x12\x10\n" + - "\x03Key\x18\x01 \x01(\tR\x03Key\x12\x14\n" + - "\x05Value\x18\x02 \x01(\tR\x05Value2B\n" + - "\x06Gorums\x128\n" + - "\n" + - "NodeStream\x12\x12.ordering.Metadata\x1a\x12.ordering.Metadata(\x010\x01B'Z github.com/relab/gorums/ordering\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_ordering_ordering_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x69, 0x6e, 0x67, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9b, 0x01, 0x0a, + 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, + 0x2a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2d, 0x0a, 0x05, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x37, 0x0a, 0x0d, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x4b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x32, 0x42, 0x0a, 0x06, 0x47, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x12, 0x38, 0x0a, + 0x0a, 0x4e, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x12, 0x2e, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, + 0x12, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x28, 0x01, 0x30, 0x01, 0x42, 0x27, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, + 0x6d, 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x92, 0x03, 0x02, 0x08, 0x02, + 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_ordering_ordering_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_ordering_ordering_proto_goTypes = []any{ @@ -251,7 +263,7 @@ func file_ordering_ordering_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_ordering_ordering_proto_rawDesc), len(file_ordering_ordering_proto_rawDesc)), + RawDescriptor: file_ordering_ordering_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -262,6 +274,7 @@ func file_ordering_ordering_proto_init() { MessageInfos: file_ordering_ordering_proto_msgTypes, }.Build() File_ordering_ordering_proto = out.File + file_ordering_ordering_proto_rawDesc = nil file_ordering_ordering_proto_goTypes = nil file_ordering_ordering_proto_depIdxs = nil } diff --git a/tests/config/config.pb.go b/tests/config/config.pb.go index 845e635c9..09b0f1bd4 100644 --- a/tests/config/config.pb.go +++ b/tests/config/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: config/config.proto @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -151,17 +150,24 @@ func (b0 Response_builder) Build() *Response { var File_config_config_proto protoreflect.FileDescriptor -const file_config_config_proto_rawDesc = "" + - "\n" + - "\x13config/config.proto\x12\x06config\x1a\fgorums.proto\"\x1b\n" + - "\aRequest\x12\x10\n" + - "\x03Num\x18\x01 \x01(\x04R\x03Num\"0\n" + - "\bResponse\x12\x12\n" + - "\x04Name\x18\x01 \x01(\tR\x04Name\x12\x10\n" + - "\x03Num\x18\x02 \x01(\x04R\x03Num2?\n" + - "\n" + - "ConfigTest\x121\n" + - "\x06Config\x12\x0f.config.Request\x1a\x10.config.Response\"\x04\xa0\xb5\x18\x01B+Z$github.com/relab/gorums/tests/config\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_config_config_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x0c, 0x67, + 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1b, 0x0a, 0x07, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x22, 0x30, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x32, 0x3f, 0x0a, 0x0a, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x54, 0x65, 0x73, 0x74, 0x12, 0x31, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x0f, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x42, 0x2b, 0x5a, 0x24, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, + 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_config_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_config_config_proto_goTypes = []any{ @@ -187,7 +193,7 @@ func file_config_config_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_config_config_proto_rawDesc), len(file_config_config_proto_rawDesc)), + RawDescriptor: file_config_config_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -198,6 +204,7 @@ func file_config_config_proto_init() { MessageInfos: file_config_config_proto_msgTypes, }.Build() File_config_config_proto = out.File + file_config_config_proto_rawDesc = nil file_config_config_proto_goTypes = nil file_config_config_proto_depIdxs = nil } diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index acdd43c81..dc5d002ca 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: config/config.proto diff --git a/tests/correctable/correctable.pb.go b/tests/correctable/correctable.pb.go index 4c0057287..90abddaa2 100644 --- a/tests/correctable/correctable.pb.go +++ b/tests/correctable/correctable.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: correctable/correctable.proto @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -123,15 +122,33 @@ func (b0 CorrectableResponse_builder) Build() *CorrectableResponse { var File_correctable_correctable_proto protoreflect.FileDescriptor -const file_correctable_correctable_proto_rawDesc = "" + - "\n" + - "\x1dcorrectable/correctable.proto\x12\vcorrectable\x1a\fgorums.proto\"\x14\n" + - "\x12CorrectableRequest\"+\n" + - "\x13CorrectableResponse\x12\x14\n" + - "\x05Level\x18\x01 \x01(\x05R\x05Level2\xc9\x01\n" + - "\x0fCorrectableTest\x12V\n" + - "\vCorrectable\x12\x1f.correctable.CorrectableRequest\x1a .correctable.CorrectableResponse\"\x04\xa0\xb5\x18\x01\x12^\n" + - "\x11CorrectableStream\x12\x1f.correctable.CorrectableRequest\x1a .correctable.CorrectableResponse\"\x04\xa0\xb5\x18\x010\x01B0Z)github.com/relab/gorums/tests/correctable\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_correctable_correctable_proto_rawDesc = []byte{ + 0x0a, 0x1d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2f, 0x63, 0x6f, + 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x1a, 0x0c, 0x67, 0x6f, + 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x43, 0x6f, + 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x2b, 0x0a, 0x13, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x32, 0xc9, 0x01, + 0x0a, 0x0f, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x65, 0x73, + 0x74, 0x12, 0x56, 0x0a, 0x0b, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, + 0x12, 0x1f, 0x2e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x43, + 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x20, 0x2e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, + 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x5e, 0x0a, 0x11, 0x43, 0x6f, 0x72, + 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1f, + 0x2e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x72, + 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x20, 0x2e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x43, 0x6f, + 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x30, 0x01, 0x42, 0x30, 0x5a, 0x29, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, + 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x72, 0x72, 0x65, + 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_correctable_correctable_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_correctable_correctable_proto_goTypes = []any{ @@ -159,7 +176,7 @@ func file_correctable_correctable_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_correctable_correctable_proto_rawDesc), len(file_correctable_correctable_proto_rawDesc)), + RawDescriptor: file_correctable_correctable_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -170,6 +187,7 @@ func file_correctable_correctable_proto_init() { MessageInfos: file_correctable_correctable_proto_msgTypes, }.Build() File_correctable_correctable_proto = out.File + file_correctable_correctable_proto_rawDesc = nil file_correctable_correctable_proto_goTypes = nil file_correctable_correctable_proto_depIdxs = nil } diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 2423a9c34..d45c61b89 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: correctable/correctable.proto diff --git a/tests/dummy/dummy.pb.go b/tests/dummy/dummy.pb.go index ef88427fa..7ab69a686 100644 --- a/tests/dummy/dummy.pb.go +++ b/tests/dummy/dummy.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: dummy/dummy.proto @@ -10,7 +10,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -65,12 +64,17 @@ func (b0 Empty_builder) Build() *Empty { var File_dummy_dummy_proto protoreflect.FileDescriptor -const file_dummy_dummy_proto_rawDesc = "" + - "\n" + - "\x11dummy/dummy.proto\x12\x05dummy\"\a\n" + - "\x05Empty2-\n" + - "\x05Dummy\x12$\n" + - "\x04Test\x12\f.dummy.Empty\x1a\f.dummy.Empty\"\x00B*Z#github.com/relab/gorums/tests/dummy\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_dummy_dummy_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x2f, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x32, 0x2d, 0x0a, 0x05, 0x44, 0x75, 0x6d, 0x6d, 0x79, 0x12, 0x24, 0x0a, 0x04, + 0x54, 0x65, 0x73, 0x74, 0x12, 0x0c, 0x2e, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x1a, 0x0c, 0x2e, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x22, 0x00, 0x42, 0x2a, 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, + 0x73, 0x74, 0x73, 0x2f, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, + 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_dummy_dummy_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_dummy_dummy_proto_goTypes = []any{ @@ -95,7 +99,7 @@ func file_dummy_dummy_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_dummy_dummy_proto_rawDesc), len(file_dummy_dummy_proto_rawDesc)), + RawDescriptor: file_dummy_dummy_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -106,6 +110,7 @@ func file_dummy_dummy_proto_init() { MessageInfos: file_dummy_dummy_proto_msgTypes, }.Build() File_dummy_dummy_proto = out.File + file_dummy_dummy_proto_rawDesc = nil file_dummy_dummy_proto_goTypes = nil file_dummy_dummy_proto_depIdxs = nil } diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index 41b23259d..5845c43f2 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: dummy/dummy.proto diff --git a/tests/metadata/metadata.pb.go b/tests/metadata/metadata.pb.go index d86b93e57..43ddce3ae 100644 --- a/tests/metadata/metadata.pb.go +++ b/tests/metadata/metadata.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: metadata/metadata.proto @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" - unsafe "unsafe" ) const ( @@ -137,16 +136,28 @@ func (b0 IPAddr_builder) Build() *IPAddr { var File_metadata_metadata_proto protoreflect.FileDescriptor -const file_metadata_metadata_proto_rawDesc = "" + - "\n" + - "\x17metadata/metadata.proto\x12\bmetadata\x1a\x1bgoogle/protobuf/empty.proto\"\x18\n" + - "\x06NodeID\x12\x0e\n" + - "\x02ID\x18\x01 \x01(\rR\x02ID\"\x1c\n" + - "\x06IPAddr\x12\x12\n" + - "\x04Addr\x18\x01 \x01(\tR\x04Addr2|\n" + - "\fMetadataTest\x126\n" + - "\bIDFromMD\x12\x16.google.protobuf.Empty\x1a\x10.metadata.NodeID\"\x00\x124\n" + - "\x06WhatIP\x12\x16.google.protobuf.Empty\x1a\x10.metadata.IPAddr\"\x00B-Z&github.com/relab/gorums/tests/metadata\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_metadata_metadata_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x18, 0x0a, 0x06, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x49, 0x44, 0x22, 0x1c, 0x0a, 0x06, 0x49, 0x50, + 0x41, 0x64, 0x64, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x41, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x41, 0x64, 0x64, 0x72, 0x32, 0x7c, 0x0a, 0x0c, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x54, 0x65, 0x73, 0x74, 0x12, 0x36, 0x0a, 0x08, 0x49, 0x44, 0x46, 0x72, + 0x6f, 0x6d, 0x4d, 0x44, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x22, 0x00, + 0x12, 0x34, 0x0a, 0x06, 0x57, 0x68, 0x61, 0x74, 0x49, 0x50, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x49, 0x50, + 0x41, 0x64, 0x64, 0x72, 0x22, 0x00, 0x42, 0x2d, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, + 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, + 0xe8, 0x07, +} var file_metadata_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_metadata_metadata_proto_goTypes = []any{ @@ -175,7 +186,7 @@ func file_metadata_metadata_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_metadata_metadata_proto_rawDesc), len(file_metadata_metadata_proto_rawDesc)), + RawDescriptor: file_metadata_metadata_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -186,6 +197,7 @@ func file_metadata_metadata_proto_init() { MessageInfos: file_metadata_metadata_proto_msgTypes, }.Build() File_metadata_metadata_proto = out.File + file_metadata_metadata_proto_rawDesc = nil file_metadata_metadata_proto_goTypes = nil file_metadata_metadata_proto_depIdxs = nil } diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index 93c577c03..e3553f452 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: metadata/metadata.proto diff --git a/tests/oneway/oneway.pb.go b/tests/oneway/oneway.pb.go index b9b6544b8..2f8837b4a 100644 --- a/tests/oneway/oneway.pb.go +++ b/tests/oneway/oneway.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: oneway/oneway.proto @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -123,17 +122,28 @@ func (b0 Empty_builder) Build() *Empty { var File_oneway_oneway_proto protoreflect.FileDescriptor -const file_oneway_oneway_proto_rawDesc = "" + - "\n" + - "\x13oneway/oneway.proto\x12\x06oneway\x1a\fgorums.proto\"\x1b\n" + - "\aRequest\x12\x10\n" + - "\x03Num\x18\x01 \x01(\x04R\x03Num\"\a\n" + - "\x05Empty2\xae\x01\n" + - "\n" + - "OnewayTest\x12/\n" + - "\aUnicast\x12\x0f.oneway.Request\x1a\r.oneway.Empty\"\x04\x90\xb5\x18\x01\x121\n" + - "\tMulticast\x12\x0f.oneway.Request\x1a\r.oneway.Empty\"\x04\x98\xb5\x18\x01\x12<\n" + - "\x10MulticastPerNode\x12\x0f.oneway.Request\x1a\r.oneway.Empty\"\b\x98\xb5\x18\x01\xa0\xb6\x18\x01B+Z$github.com/relab/gorums/tests/oneway\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_oneway_oneway_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x1a, 0x0c, 0x67, + 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1b, 0x0a, 0x07, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x32, 0xae, 0x01, 0x0a, 0x0a, 0x4f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x54, 0x65, 0x73, 0x74, + 0x12, 0x2f, 0x0a, 0x07, 0x55, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x0f, 0x2e, 0x6f, 0x6e, + 0x65, 0x77, 0x61, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x6f, + 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x90, 0xb5, 0x18, + 0x01, 0x12, 0x31, 0x0a, 0x09, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x0f, + 0x2e, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x0d, 0x2e, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, + 0x98, 0xb5, 0x18, 0x01, 0x12, 0x3c, 0x0a, 0x10, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, + 0x74, 0x50, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0f, 0x2e, 0x6f, 0x6e, 0x65, 0x77, 0x61, + 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x6f, 0x6e, 0x65, 0x77, + 0x61, 0x79, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x08, 0x98, 0xb5, 0x18, 0x01, 0xa0, 0xb6, + 0x18, 0x01, 0x42, 0x2b, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, + 0x73, 0x74, 0x73, 0x2f, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, + 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_oneway_oneway_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_oneway_oneway_proto_goTypes = []any{ @@ -163,7 +173,7 @@ func file_oneway_oneway_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_oneway_oneway_proto_rawDesc), len(file_oneway_oneway_proto_rawDesc)), + RawDescriptor: file_oneway_oneway_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -174,6 +184,7 @@ func file_oneway_oneway_proto_init() { MessageInfos: file_oneway_oneway_proto_msgTypes, }.Build() File_oneway_oneway_proto = out.File + file_oneway_oneway_proto_rawDesc = nil file_oneway_oneway_proto_goTypes = nil file_oneway_oneway_proto_depIdxs = nil } diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index c6fc34f42..cd07d6c86 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: oneway/oneway.proto diff --git a/tests/ordering/order.pb.go b/tests/ordering/order.pb.go index c766ab6da..f19367b14 100644 --- a/tests/ordering/order.pb.go +++ b/tests/ordering/order.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: ordering/order.proto @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -137,18 +136,30 @@ func (b0 Response_builder) Build() *Response { var File_ordering_order_proto protoreflect.FileDescriptor -const file_ordering_order_proto_rawDesc = "" + - "\n" + - "\x14ordering/order.proto\x12\bordering\x1a\fgorums.proto\"\x1b\n" + - "\aRequest\x12\x10\n" + - "\x03Num\x18\x01 \x01(\x04R\x03Num\"$\n" + - "\bResponse\x12\x18\n" + - "\aInOrder\x18\x01 \x01(\bR\aInOrder2\xac\x01\n" + - "\n" + - "GorumsTest\x121\n" + - "\x02QC\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x04\xa0\xb5\x18\x01\x126\n" + - "\aQCAsync\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x04\xa0\xb5\x18\x01\x123\n" + - "\bUnaryRPC\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x00B-Z&github.com/relab/gorums/tests/ordering\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_ordering_order_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, + 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1b, + 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x22, 0x24, 0x0a, 0x08, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x6e, 0x4f, 0x72, 0x64, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x49, 0x6e, 0x4f, 0x72, 0x64, 0x65, + 0x72, 0x32, 0xac, 0x01, 0x0a, 0x0a, 0x47, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x54, 0x65, 0x73, 0x74, + 0x12, 0x31, 0x0a, 0x02, 0x51, 0x43, 0x12, 0x11, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, + 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6f, 0x72, 0x64, 0x65, + 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, + 0xb5, 0x18, 0x01, 0x12, 0x36, 0x0a, 0x07, 0x51, 0x43, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x12, 0x11, + 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x12, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x33, 0x0a, 0x08, 0x55, + 0x6e, 0x61, 0x72, 0x79, 0x52, 0x50, 0x43, 0x12, 0x11, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, + 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x42, 0x2d, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, + 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, + 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, + 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_ordering_order_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_ordering_order_proto_goTypes = []any{ @@ -178,7 +189,7 @@ func file_ordering_order_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_ordering_order_proto_rawDesc), len(file_ordering_order_proto_rawDesc)), + RawDescriptor: file_ordering_order_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -189,6 +200,7 @@ func file_ordering_order_proto_init() { MessageInfos: file_ordering_order_proto_msgTypes, }.Build() File_ordering_order_proto = out.File + file_ordering_order_proto_rawDesc = nil file_ordering_order_proto_goTypes = nil file_ordering_order_proto_depIdxs = nil } diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index 551b4b473..7e6463e84 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: ordering/order.proto diff --git a/tests/qf/qf.pb.go b/tests/qf/qf.pb.go index af177a133..0b8b29998 100644 --- a/tests/qf/qf.pb.go +++ b/tests/qf/qf.pb.go @@ -2,7 +2,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: qf/qf.proto @@ -13,7 +13,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -139,16 +138,25 @@ func (b0 Response_builder) Build() *Response { var File_qf_qf_proto protoreflect.FileDescriptor -const file_qf_qf_proto_rawDesc = "" + - "\n" + - "\vqf/qf.proto\x12\x02qf\x1a\fgorums.proto\"\x1f\n" + - "\aRequest\x12\x14\n" + - "\x05Value\x18\x01 \x01(\x03R\x05Value\"\"\n" + - "\bResponse\x12\x16\n" + - "\x06Result\x18\x01 \x01(\x03R\x06Result2i\n" + - "\x0eQuorumFunction\x12)\n" + - "\x06UseReq\x12\v.qf.Request\x1a\f.qf.Response\"\x04\xa0\xb5\x18\x01\x12,\n" + - "\tIgnoreReq\x12\v.qf.Request\x1a\f.qf.Response\"\x04\xa0\xb5\x18\x01B'Z github.com/relab/gorums/tests/qf\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_qf_qf_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x71, 0x66, 0x2f, 0x71, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x71, + 0x66, 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x1f, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x22, 0x22, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x52, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x32, 0x69, 0x0a, 0x0e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x46, 0x75, + 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x52, 0x65, 0x71, + 0x12, 0x0b, 0x2e, 0x71, 0x66, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, + 0x71, 0x66, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, + 0x01, 0x12, 0x2c, 0x0a, 0x09, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x12, 0x0b, + 0x2e, 0x71, 0x66, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x71, 0x66, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x42, + 0x27, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, + 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, + 0x2f, 0x71, 0x66, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_qf_qf_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_qf_qf_proto_goTypes = []any{ @@ -176,7 +184,7 @@ func file_qf_qf_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_qf_qf_proto_rawDesc), len(file_qf_qf_proto_rawDesc)), + RawDescriptor: file_qf_qf_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -187,6 +195,7 @@ func file_qf_qf_proto_init() { MessageInfos: file_qf_qf_proto_msgTypes, }.Build() File_qf_qf_proto = out.File + file_qf_qf_proto_rawDesc = nil file_qf_qf_proto_goTypes = nil file_qf_qf_proto_depIdxs = nil } diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 3bce2eae6..44aef00ec 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: qf/qf.proto diff --git a/tests/tls/tls.pb.go b/tests/tls/tls.pb.go index 0dfe543fe..567a53ebf 100644 --- a/tests/tls/tls.pb.go +++ b/tests/tls/tls.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: tls/tls.proto @@ -10,7 +10,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -122,14 +121,19 @@ func (b0 Response_builder) Build() *Response { var File_tls_tls_proto protoreflect.FileDescriptor -const file_tls_tls_proto_rawDesc = "" + - "\n" + - "\rtls/tls.proto\x12\x03tls\"\t\n" + - "\aRequest\"\x1a\n" + - "\bResponse\x12\x0e\n" + - "\x02OK\x18\x01 \x01(\bR\x02OK2/\n" + - "\x03TLS\x12(\n" + - "\aTestTLS\x12\f.tls.Request\x1a\r.tls.Response\"\x00B(Z!github.com/relab/gorums/tests/tls\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_tls_tls_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x74, 0x6c, 0x73, 0x2f, 0x74, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x03, 0x74, 0x6c, 0x73, 0x22, 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x1a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x4f, + 0x4b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x4f, 0x4b, 0x32, 0x2f, 0x0a, 0x03, 0x54, + 0x4c, 0x53, 0x12, 0x28, 0x0a, 0x07, 0x54, 0x65, 0x73, 0x74, 0x54, 0x4c, 0x53, 0x12, 0x0c, 0x2e, + 0x74, 0x6c, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x74, 0x6c, + 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x28, 0x5a, 0x21, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, + 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x74, 0x6c, + 0x73, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x70, 0xe8, 0x07, +} var file_tls_tls_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_tls_tls_proto_goTypes = []any{ @@ -155,7 +159,7 @@ func file_tls_tls_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_tls_tls_proto_rawDesc), len(file_tls_tls_proto_rawDesc)), + RawDescriptor: file_tls_tls_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -166,6 +170,7 @@ func file_tls_tls_proto_init() { MessageInfos: file_tls_tls_proto_msgTypes, }.Build() File_tls_tls_proto = out.File + file_tls_tls_proto_rawDesc = nil file_tls_tls_proto_goTypes = nil file_tls_tls_proto_depIdxs = nil } diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 668ca94ca..9d4f8ceb6 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: tls/tls.proto diff --git a/tests/unresponsive/unresponsive.pb.go b/tests/unresponsive/unresponsive.pb.go index 15cd35237..bd367e97c 100644 --- a/tests/unresponsive/unresponsive.pb.go +++ b/tests/unresponsive/unresponsive.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.3 // protoc v6.30.2 // source: unresponsive/unresponsive.proto @@ -10,7 +10,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -65,12 +64,21 @@ func (b0 Empty_builder) Build() *Empty { var File_unresponsive_unresponsive_proto protoreflect.FileDescriptor -const file_unresponsive_unresponsive_proto_rawDesc = "" + - "\n" + - "\x1funresponsive/unresponsive.proto\x12\funresponsive\"\a\n" + - "\x05Empty2N\n" + - "\fUnresponsive\x12>\n" + - "\x10TestUnresponsive\x12\x13.unresponsive.Empty\x1a\x13.unresponsive.Empty\"\x00B1Z*github.com/relab/gorums/tests/unresponsive\x92\x03\x02\b\x02b\beditionsp\xe8\a" +var file_unresponsive_unresponsive_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x2f, 0x75, + 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x0c, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x22, + 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x4e, 0x0a, 0x0c, 0x55, 0x6e, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x12, 0x3e, 0x0a, 0x10, 0x54, 0x65, 0x73, 0x74, + 0x55, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x12, 0x13, 0x2e, 0x75, + 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x13, 0x2e, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x31, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, + 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} var file_unresponsive_unresponsive_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_unresponsive_unresponsive_proto_goTypes = []any{ @@ -95,7 +103,7 @@ func file_unresponsive_unresponsive_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_unresponsive_unresponsive_proto_rawDesc), len(file_unresponsive_unresponsive_proto_rawDesc)), + RawDescriptor: file_unresponsive_unresponsive_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -106,6 +114,7 @@ func file_unresponsive_unresponsive_proto_init() { MessageInfos: file_unresponsive_unresponsive_proto_msgTypes, }.Build() File_unresponsive_unresponsive_proto = out.File + file_unresponsive_unresponsive_proto_rawDesc = nil file_unresponsive_unresponsive_proto_goTypes = nil file_unresponsive_unresponsive_proto_depIdxs = nil } diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index a338a6d62..bbab90ac1 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+0ae59408 +// protoc-gen-gorums v0.9.0-devel+206a5710 // protoc v6.30.2 // source: unresponsive/unresponsive.proto From e7bc839b6906b125989aeb6db611bbb9c848b898 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Wed, 7 May 2025 11:36:47 +0200 Subject: [PATCH 10/27] update documentation (qspec -> iter) --- doc/method-options.md | 72 +++++++++++++---------- doc/ordering.md | 2 +- doc/user-guide.md | 130 +++++++++++++++--------------------------- 3 files changed, 90 insertions(+), 114 deletions(-) diff --git a/doc/method-options.md b/doc/method-options.md index 8c1cee86b..7227c7cd1 100644 --- a/doc/method-options.md +++ b/doc/method-options.md @@ -9,7 +9,6 @@ Gorums currently supports the following call types (these cannot be combined): | Unicast | `gorums.unicast` | FIFO-ordered one-way asynchronous unicast. | | Multicast | `gorums.multicast` | FIFO-ordered one-way asynchronous multicast. | | Quorum Call | `gorums.quorumcall` | FIFO-ordered synchronous quorum call on a configuration of nodes. | -| Correctable | `gorums.correctable` | Asynchronous quorum call with *incremental consistency guarantees*. | All call types rely on a streaming RPC call named `NodeStream` to send and receive messages to/from individual nodes. However, the server API generated by Gorums does not expose the gRPC stream-based API. @@ -19,25 +18,19 @@ Each call type may also specify some advanced options: | Name | Gorums option | Type | Description | | ------------------ | --------------------------- | ------ | ---------------------------------------------------------------------------------------------- | -| Custom return type | `gorums.custom_return_type` | string | Makes the quorum function return a different type than the RPC response type. | | Per node arguments | `gorums.per_node_arg` | bool | Makes it possible to send different request objects to each node in a call. | -| Asynchronous | `gorums.async` | bool | Makes the quorum call run asynchronously and returns a "promise" object to fetch the result. | The following matrix shows which call types can be combined with the different options: | Option | Ordered RPC | Unicast | Multicast | Quorum Call | Correctable | | ------------------ | ----------- | ------- | --------- | ----------- | ----------- | -| Custom return type | N/A | N/A | N/A | Yes | Yes | | Per node arguments | N/A | N/A | Yes | Yes | Yes | -| Asynchronous | No | N/A | N/A | Yes | No | -The correctable quorum call is an asynchronous call type that comes in two variants. +The quorum call comes in two variants. In the first variant, each node of the configuration sends only a single response. In the second variant, each node may return multiple responses. The second variant uses the gRPC server-side stream API and is indicated with the `stream` keyword associated with the return type. -See `ReadCorrectableStream` method below for an example. - -Note that the `gorums.correctable` option should not be combined with the `gorums.async` option. +See `ReadStream` method below for an example. ## Example Protobuf Definitions @@ -53,29 +46,10 @@ service Storage { option (gorums.quorumcall) = true; } - // ReadAsync is an asynchronous quorum call that - // returns a promise object for retrieving results. - rpc ReadAsync(ReadRequest) returns (State) { - option (gorums.async) = true; - option (gorums.quorumcall) = true; - } - - // ReadCustomReturn is a FIFO-ordered synchronous quorum call with a custom return type. - rpc ReadCustomReturn(ReadRequest) returns (State) { - option (gorums.quorumcall) = true; - option (gorums.custom_return_type) = "MyState"; - } - - // ReadCorrectable is an asynchronous correctable quorum call that - // returns a correctable object for retrieving results. - rpc ReadCorrectable(ReadRequest) returns (State) { - option (gorums.correctable) = true; - } - // ReadCorrectableStream is an asynchronous correctable quorum call that // returns a correctable object for retrieving results over a stream. - rpc ReadCorrectableStream(ReadRequest) returns (stream State) { - option (gorums.correctable) = true; + rpc ReadStream(ReadRequest) returns (stream State) { + option (gorums.quorumcall) = true; } // WriteMulticast is an asynchronous multicast to all nodes in a configuration. @@ -93,3 +67,41 @@ service Storage { } } ``` + +## Correctable calls + +The iterators returned by quorum calls can be passed to the IterCorrectable function along with a callback function, in order to create a correctable object that can be used to get results at multiple levels. + +```go +type CustomResult struct { + abc uint32 + msg *State +} +// example correctable quorum function that uses a custom result type +func ReadCorrectableQF(responses gorums.Iterator[*State], levelSet func(CustomResult, int, error)) { + level := 0 + for response := range responses.IgnoreErrors() { + level++ + + levelSet(CustomResult{ + abc: response.Nid, + msg: response.Msg, + }, level, nil) + + if level >= 10 { + return + } + } + levelSet(nil, 0, errors.New("not enough responses")) +} + +func ReadCorrectable(ctx context.Context, cfg *Configuration, req *ReadRequest) *gorums.Correctable[CustomResult] { + responses := cfg.ReadQC(ctx, req) + return gorums.IterCorrectable(responses, ReadCorrectableQF) +} + +func ReadCorrectableStream(ctx context.Context, cfg *Configuration, req *ReadRequest) *gorums.Correctable[CustomResult] { + responses := cfg.ReadStream(ctx, req) + return gorums.IterCorrectable(responses, ReadCorrectableQF) +} +``` diff --git a/doc/ordering.md b/doc/ordering.md index 9e2a038e4..50984ce46 100644 --- a/doc/ordering.md +++ b/doc/ordering.md @@ -94,6 +94,6 @@ Hence, to preserve message ordering, the following rules must be adhered to: * (Client-side) Quorum calls cannot be started in separate goroutines, as the scheduling of goroutines is non-deterministic. -* (Client-side) To process replies from different quorum calls concurrently, use the `async` option. +* (Client-side) To process replies from different quorum calls concurrently, use the `gorums.Async` function, or process the responses from the gorums iterator in a goroutine. * (Server-side) If the server must return replies in the same order as the client sent them, the server-side handler must also preserve ordering. diff --git a/doc/user-guide.md b/doc/user-guide.md index 45d0f272a..da149b7bb 100644 --- a/doc/user-guide.md +++ b/doc/user-guide.md @@ -117,7 +117,7 @@ func (n *Node) Write(ctx context.Context, in *State) (*WriteResponse, error) And this is our server interface: ```go -type Storage interface { +type StorageServer interface { Read(gorums.ServerCtx, *ReadRequest) (*State, error) Write(gorums.ServerCtx, *State) (*WriteResponse, error) } @@ -280,7 +280,7 @@ While Gorums allows us to call RPCs on individual nodes as we did above, Gorums ## Quorum Calls Instead of invoking an RPC explicitly on all nodes in a configuration, Gorums allows users to invoke a *quorum call* via a method on the `Configuration` type. -If an RPC is invoked as a quorum call, Gorums will invoke the RPCs on all nodes in parallel and collect and process the replies. +If an RPC is invoked as a quorum call, Gorums will invoke the RPCs on all nodes in parallel and return the replies in an iterator. For the Gorums plugin to generate quorum calls we need to specify the `quorumcall` option for our RPC methods in the proto file, as shown below: @@ -300,95 +300,67 @@ service QCStorage { The generated methods have the following client-side interface: ```go -func (c *Configuration) Read(ctx context.Context, in *ReadRequest) (*State, error) -func (c *Configuration) Write(ctx context.Context, in *State) (*WriteResponse, error) +func (c *Configuration) Read(ctx context.Context, in *ReadRequest) gorums.Iterator[*State] +func (c *Configuration) Write(ctx context.Context, in *State) gorums.Iterator[*WriteResponse] ``` -## The QuorumSpec Interface with Quorum Functions +## The quorum call iterators -Gorums uses a *quorum function*, that takes as input a set of replies from individual servers, and computes the reply to be returned from the quorum call. -Such a quorum function has two responsibilities: +The quorum calls return an iterator which is used to process the responses from the quorum call. +Behind the scenes, the RPCs invoked as part of a quorum call return multiple responses. +Each of these responses is a struct containing the node id of the server, and contains either a proto message and an error (or both). +If you only care about the successfully received messages you can use the `IgnoreErrors` method on the iterator. +We can create "quorum functions" which takes a quorum call iterator and returns a single result or an error. -1. Report when a set of replies form a quorum. -2. Compute a single reply from a set of replies that form a quorum. - -Behind the scenes, the RPCs invoked as part of a quorum call return multiple replies. -Typically, only one of these replies should be returned to the end-user. -However, Gorums cannot provide a generic policy for selecting a single reply from many replies. -Instead, Gorums makes this an application-specific choice. -For example, it may be necessary to compare the content of several reply messages when deciding which reply to return to the client's quorum call, and sometimes several replies must be combined into a new one. -Gorums, therefore, generates a `QuorumSpec` interface that contains a quorum function for every quorum call. -The `QuorumSpec` generated for our example is as follows: - -```go -type QuorumSpec interface { - // ReadQF is the quorum function for the Read - // quorum call method. - ReadQF(req *ReadRequest, replies map[uint32]*State) (*State, bool) - - // WriteQF is the quorum function for the Write - // quorum call method. - WriteQF(req *WriteRequest, replies map[uint32]*WriteResponse) (*WriteResponse, bool) -} -``` - -A `QuorumSpec` implementation must be provided when creating a new configuration. -Each quorum function of the `QuorumSpec` must adhere to the following rules: - -* If too few replies have been received, a quorum function must return `false`, signaling to Gorums that the quorum call should wait for more replies. -* Once sufficiently many replies have been received, the quorum function must return `true` along with an appropriate return value, signaling that the quorum call can return the value to the client. - -The example below shows an implementation of the `QuorumSpec` interface. -Here, `ReadQF` returns the `*State` with the highest timestamp and `true`, signaling that the quorum call can return. -The quorum call will return the `*State` chosen by the quorum function. +The example below shows an implementation of a "quorum function" for the `Read` and `Write` quorum calls. +Here, `readQF` returns the `*State` with the highest timestamp for a majority of responses. +`writeQF` returns the `*WriteResponse` from one of the responses when it received a majority of responses. +We decide to ignore all errors, meaning errors do not count towards the quorum. ```go package gorumsexample -import "sort" - -type QSpec struct { - quorumSize int +func readQF(responses gorums.Iterator[*State], quorum int) (*State, error) { + var newest *pb.ReadResponse + replyCount := int(0) + for response := range responses.IgnoreErrors() { + if newest != nil { + newest = newestStateOfTwo(newest, response.Msg) + } else { + newest = response.Msg + } + replyCount++ + if replyCount >= quorum { + return newest, nil + } + } + return nil, errors.New("QCStorage.readqf: quorum not found") } -// ReadQF is the quorum function for the Read RPC method. -func (qs *QSpec) ReadQF(_ *ReadResponse, replies map[uint32]*State) (*State, bool) { - if len(replies) < qs.quorumSize { - return nil, false - } - return newestState(replies), true +func writeQF(responses gorums.Iterator[*WriteResponse], quorum int) (*WriteResponse, error) { + replyCount := int(0) + for response := range responses.IgnoreErrors() { + replyCount++ + if replyCount >= quorum { + return response.Msg + } + } + return nil, errors.New("QCStorage.writeqf: quorum not found") } -// WriteQF is the quorum function for the Write RPC method. -func (qs *QSpec) WriteQF(_ *WriteRequest, replies map[uint32]*WriteResponse) (*WriteResponse, bool) { - if len(replies) < qs.quorumSize { - return nil, false - } - // return the first response we find - var reply *WriteResponse - for _, r := range replies { - reply = r - break +func newestValueOfTwo(s1 *State, s2 *State) *State { + if s1.GetTimestamp() >= s2.GetTimestamp() { + return s1 } - return reply, true -} - -func newestState(replies map[uint32]*State) *State { - var newest *State - for _, s := range replies { - if s.GetTimestamp() >= newest.GetTimestamp() { - newest = s - } - } - return newest + return s2 } ``` ## Invoking Quorum Calls on the Configuration in the StorageClient -In the following code snippet, we create a configuration, including an instance of the `QSpec` defined above, and invoke a quorum call. -The quorum call will return after receiving replies from two servers. -Gorums ignores any outstanding replies. +In the following code snippet, we create a configuration, and invoke a quorum call. +We call a quorum function using the iterator from the quorum call. +The quorum function will return after receiving replies from two servers. Note that Gorums does not cancel any outstanding RPCs, leaving it to the client to manage any cancellations through the `Context` argument to the quorum call. However, canceling RPCs to a replicated server may not be the desired behavior, since then one or more servers may not have seen previous messages. @@ -416,7 +388,8 @@ func ExampleStorageClient() { // Invoke read quorum call: ctx, cancel := context.WithCancel(context.Background()) - reply, err := allNodesConfig.Read(ctx, &ReadRequest{}) + responses := allNodesConfig.Read(ctx, &ReadRequest{}) + reply, err := readQF(responses, 2) if err != nil { log.Fatalln("read rpc returned error:", err) } @@ -430,9 +403,6 @@ Below is an example demonstrating how to work with configurations. These configurations are viewed from the client's perspective, and to actually make quorum calls on these configurations, there must be server endpoints to connect to. We ignore the construction of `mgr` and error handling. -Depending on the application's requirements, the `QSpec` argument may depend on the resulting configuration's size. -In the example below, we simply use fixed quorum sizes. - ```go func ExampleConfigClient() { addrs := []string{ @@ -442,7 +412,6 @@ func ExampleConfigClient() { } // Make configuration c1 from addrs, giving |c1| = |addrs| = 3 c1, _ := mgr.NewConfiguration( - &QSpec{2}, gorums.WithNodeList(addrs), ) @@ -452,31 +421,26 @@ func ExampleConfigClient() { } // Make configuration c2 from newAddrs, giving |c2| = |newAddrs| = 2 c2, _ := mgr.NewConfiguration( - &QSpec{1}, gorums.WithNodeList(newAddrs), ) // Make new configuration c3 from c1 and newAddrs, giving |c3| = |c1| + |newAddrs| = 3+2=5 c3, _ := mgr.NewConfiguration( - &QSpec{3}, c1.WithNewNodes(gorums.WithNodeList(newAddrs)), ) // Make new configuration c4 from c1 and c2, giving |c4| = |c1| + |c2| = 3+2=5 c4, _ := mgr.NewConfiguration( - &QSpec{3}, c1.And(c2), ) // Make new configuration c5 from c1 except the first node from c1, giving |c5| = |c1| - 1 = 3-1 = 2 c5, _ := mgr.NewConfiguration( - &QSpec{1}, c1.WithoutNodes(c1.NodeIDs()[0]), ) // Make new configuration c6 from c3 except c1, giving |c6| = |c3| - |c1| = 5-3 = 2 c6, _ := mgr.NewConfiguration( - &QSpec{1}, c3.Except(c1), ) } From 523554f25627c1e9cb3d81fbb5074eb980d69436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Salhus?= Date: Thu, 8 May 2025 14:59:41 +0200 Subject: [PATCH 11/27] example cleanup --- examples/storage/client.go | 92 +++++++++++++------------------------- examples/storage/repl.go | 35 --------------- 2 files changed, 32 insertions(+), 95 deletions(-) diff --git a/examples/storage/client.go b/examples/storage/client.go index 4418517f2..617fa8193 100644 --- a/examples/storage/client.go +++ b/examples/storage/client.go @@ -1,10 +1,12 @@ package main import ( + "errors" "log" "github.com/relab/gorums" "github.com/relab/gorums/examples/storage/proto" + pb "github.com/relab/gorums/examples/storage/proto" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) @@ -29,59 +31,6 @@ func runClient(addresses []string) error { return Repl(mgr, cfg) } -type qspec struct { - cfgSize int -} - -// ReadQCQF is the quorum function for the ReadQC -// ordered quorum call method. The in parameter is the request object -// supplied to the ReadQC method at call time, and may or may not -// be used by the quorum function. If the in parameter is not needed -// you should implement your quorum function with '_ *ReadRequest'. -func (q qspec) ReadQCQF( - _ *proto.ReadRequest, - replies map[uint32]*proto.ReadResponse, -) (*proto.ReadResponse, bool) { - // wait until at least half of the replicas have responded - if len(replies) <= q.cfgSize/2 { - return nil, false - } - // return the value with the most recent timestamp - return newestValue(replies), true -} - -// WriteQCQF is the quorum function for the WriteQC -// ordered quorum call method. The in parameter is the request object -// supplied to the WriteQC method at call time, and may or may not -// be used by the quorum function. If the in parameter is not needed -// you should implement your quorum function with '_ *WriteRequest'. -func (q qspec) WriteQCQF(in *proto.WriteRequest, replies map[uint32]*proto.WriteResponse) (*proto.WriteResponse, bool) { - // wait until at least half of the replicas have responded and have updated their value - if numUpdated(replies) > q.cfgSize/2 { - return proto.WriteResponse_builder{New: true}.Build(), true - } - // if all replicas have responded, there must have been another write before ours - // that had a newer timestamp - if len(replies) == q.cfgSize { - return proto.WriteResponse_builder{New: false}.Build(), true - } - return nil, false -} - -// newestValue returns the reply that had the most recent timestamp -func newestValue(values map[uint32]*proto.ReadResponse) *proto.ReadResponse { - if len(values) < 1 { - return nil - } - var newest *proto.ReadResponse - for _, v := range values { - if v.GetTime().AsTime().After(newest.GetTime().AsTime()) { - newest = v - } - } - return newest -} - // newestValue returns the reply that had the most recent timestamp func newestValueOfTwo(v1, v2 *proto.ReadResponse) *proto.ReadResponse { if v1 == nil { @@ -101,13 +50,36 @@ func isUpdated(r *proto.WriteResponse) bool { return r.GetNew() } -// numUpdated returns the number of replicas that updated their value -func numUpdated(replies map[uint32]*proto.WriteResponse) int { - count := 0 - for _, r := range replies { - if r.GetNew() { - count++ +func writeQF(replies gorums.Iterator[*pb.WriteResponse], cfgSize int) (*pb.WriteResponse, error) { + replyCount := int(0) + updated := int(0) + for response := range replies.IgnoreErrors() { + replyCount++ + if isUpdated(response.Msg) { + updated++ + } + if updated > cfgSize/2 { + return proto.WriteResponse_builder{New: true}.Build(), nil + } + // if all replicas have responded, there must have been another write before ours + // that had a newer timestamp + if replyCount == cfgSize { + return proto.WriteResponse_builder{New: false}.Build(), nil + } + } + return nil, errors.New("storage.writeqc: incomplete response") +} + +func readQF(replies gorums.Iterator[*pb.ReadResponse], quorum int) (*pb.ReadResponse, error) { + var newest *pb.ReadResponse + replyCount := int(0) + for reply := range replies.IgnoreErrors() { + newest = newestValueOfTwo(newest, reply.Msg) + replyCount++ + if replyCount <= quorum { + continue } + return newest, nil } - return count + return nil, errors.New("storage.readqc: quorum not found") } diff --git a/examples/storage/repl.go b/examples/storage/repl.go index 2e5ed74ee..59ed01176 100644 --- a/examples/storage/repl.go +++ b/examples/storage/repl.go @@ -12,7 +12,6 @@ import ( "github.com/google/shlex" "github.com/relab/gorums" - "github.com/relab/gorums/examples/storage/proto" pb "github.com/relab/gorums/examples/storage/proto" "golang.org/x/term" "google.golang.org/protobuf/types/known/timestamppb" @@ -249,20 +248,6 @@ func (repl) writeRPC(args []string, node *pb.Node) { fmt.Println("Write OK") } -func readQF(replies gorums.Iterator[*pb.ReadResponse], quorum int) (*pb.ReadResponse, error) { - var newest *pb.ReadResponse - replyCount := int(0) - for reply := range replies.IgnoreErrors() { - newest = newestValueOfTwo(newest, reply.Msg) - replyCount++ - if replyCount <= quorum { - continue - } - return newest, nil - } - return nil, errors.New("storage.readqc: quorum not found") -} - func (repl) readQC(args []string, cfg *pb.Configuration) { if len(args) < 1 { fmt.Println("Read requires a key to read.") @@ -285,26 +270,6 @@ func (repl) readQC(args []string, cfg *pb.Configuration) { fmt.Printf("%s = %s\n", args[0], resp.GetValue()) } -func writeQF(replies gorums.Iterator[*pb.WriteResponse], cfgSize int) (*pb.WriteResponse, error) { - replyCount := int(0) - updated := int(0) - for response := range replies.IgnoreErrors() { - replyCount++ - if isUpdated(response.Msg) { - updated++ - } - if updated > cfgSize/2 { - return proto.WriteResponse_builder{New: true}.Build(), nil - } - // if all replicas have responded, there must have been another write before ours - // that had a newer timestamp - if replyCount == cfgSize { - return proto.WriteResponse_builder{New: false}.Build(), nil - } - } - return nil, errors.New("storage.writeqc: incomplete response") -} - func (repl) writeQC(args []string, cfg *pb.Configuration) { if len(args) < 2 { fmt.Println("Write requires a key and a value to write.") From f350194c48735573bfde874da460be6aa167019e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Salhus?= Date: Fri, 9 May 2025 17:31:45 +0200 Subject: [PATCH 12/27] close channel after iterating, avoiding benchmark memory leak --- quorumcall.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/quorumcall.go b/quorumcall.go index 1e16e9a45..ff9cab518 100644 --- a/quorumcall.go +++ b/quorumcall.go @@ -50,16 +50,15 @@ func QuorumCall[responseType proto.Message]( ) } - if d.ServerStream { + return func(yield func(Response[responseType]) bool) { + replies := int(0) + errors := int(0) + + defer close(replyChan) for _, n := range c { defer n.channel.deleteRouter(md.GetMessageID()) } - } - replies := int(0) - errors := int(0) - - return func(yield func(Response[responseType]) bool) { for { if d.ServerStream { if errors >= nodes { From eba77d416880de30d537e577653f09fd39aadbef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Salhus?= Date: Fri, 9 May 2025 17:35:00 +0200 Subject: [PATCH 13/27] protoc updates --- benchmark/benchmark.pb.go | 125 +++++++----------- benchmark/benchmark_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/dev/zorums.pb.go | 113 +++++----------- .../dev/zorums_client_gorums.pb.go | 2 +- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_quorumcall_gorums.pb.go | 2 +- .../dev/zorums_rpc_gorums.pb.go | 2 +- .../dev/zorums_server_gorums.pb.go | 2 +- .../dev/zorums_types_gorums.pb.go | 2 +- .../dev/zorums_unicast_gorums.pb.go | 2 +- examples/storage/proto/storage_gorums.pb.go | 26 ++-- gorums.pb.go | 45 ++----- internal/correctable/opts.pb.go | 32 ++--- ordering/ordering.pb.go | 47 +++---- tests/config/config.pb.go | 35 ++--- tests/config/config_gorums.pb.go | 2 +- tests/correctable/correctable.pb.go | 42 ++---- tests/correctable/correctable_gorums.pb.go | 2 +- tests/dummy/dummy.pb.go | 23 ++-- tests/dummy/dummy_gorums.pb.go | 2 +- tests/metadata/metadata.pb.go | 38 ++---- tests/metadata/metadata_gorums.pb.go | 2 +- tests/oneway/oneway.pb.go | 39 ++---- tests/oneway/oneway_gorums.pb.go | 2 +- tests/ordering/order.pb.go | 42 +++--- tests/ordering/order_gorums.pb.go | 2 +- tests/qf/qf.pb.go | 35 ++--- tests/qf/qf_gorums.pb.go | 2 +- tests/tls/tls.pb.go | 27 ++-- tests/tls/tls_gorums.pb.go | 2 +- tests/unresponsive/unresponsive.pb.go | 27 ++-- tests/unresponsive/unresponsive_gorums.pb.go | 2 +- 32 files changed, 254 insertions(+), 476 deletions(-) diff --git a/benchmark/benchmark.pb.go b/benchmark/benchmark.pb.go index 70f01876a..10aa6a49d 100644 --- a/benchmark/benchmark.pb.go +++ b/benchmark/benchmark.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: benchmark/benchmark.proto @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" + unsafe "unsafe" ) const ( @@ -528,83 +529,48 @@ func (b0 MemoryStat_builder) Build() *MemoryStat { var File_benchmark_benchmark_proto protoreflect.FileDescriptor -var file_benchmark_benchmark_proto_rawDesc = []byte{ - 0x0a, 0x19, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2f, 0x62, 0x65, 0x6e, 0x63, - 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x62, 0x65, 0x6e, - 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x20, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, - 0x6f, 0x61, 0x64, 0x22, 0x40, 0x0a, 0x08, 0x54, 0x69, 0x6d, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x12, - 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x08, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, - 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x0e, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xad, 0x02, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4f, 0x70, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4f, 0x70, 0x73, - 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x09, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e, - 0x0a, 0x0a, 0x54, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x70, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x01, 0x52, 0x0a, 0x54, 0x68, 0x72, 0x6f, 0x75, 0x67, 0x68, 0x70, 0x75, 0x74, 0x12, 0x1e, - 0x0a, 0x0a, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x41, 0x76, 0x67, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x01, 0x52, 0x0a, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x41, 0x76, 0x67, 0x12, 0x1e, - 0x0a, 0x0a, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x56, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x01, 0x52, 0x0a, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x56, 0x61, 0x72, 0x12, 0x20, - 0x0a, 0x0b, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x50, 0x65, 0x72, 0x4f, 0x70, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0b, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x50, 0x65, 0x72, 0x4f, 0x70, - 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x65, 0x6d, 0x50, 0x65, 0x72, 0x4f, 0x70, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x08, 0x4d, 0x65, 0x6d, 0x50, 0x65, 0x72, 0x4f, 0x70, 0x12, 0x37, 0x0a, 0x0b, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x4d, 0x65, - 0x6d, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x52, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x22, 0x3c, 0x0a, 0x0a, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x53, - 0x74, 0x61, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x06, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x4d, - 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x4d, 0x65, 0x6d, - 0x6f, 0x72, 0x79, 0x32, 0x9c, 0x04, 0x0a, 0x09, 0x42, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, - 0x6b, 0x12, 0x4f, 0x0a, 0x14, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x42, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x17, 0x2e, 0x62, 0x65, 0x6e, 0x63, - 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x53, - 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, - 0x18, 0x01, 0x12, 0x46, 0x0a, 0x13, 0x53, 0x74, 0x6f, 0x70, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x42, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x16, 0x2e, 0x62, 0x65, 0x6e, 0x63, - 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x11, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x49, 0x0a, 0x0e, 0x53, 0x74, - 0x61, 0x72, 0x74, 0x42, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x17, 0x2e, 0x62, - 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, - 0x6b, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x44, 0x0a, 0x0d, 0x53, 0x74, 0x6f, 0x70, 0x42, 0x65, 0x6e, - 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x16, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, - 0x72, 0x6b, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, - 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x4d, 0x65, 0x6d, 0x6f, 0x72, - 0x79, 0x53, 0x74, 0x61, 0x74, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x34, 0x0a, 0x0a, 0x51, - 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0f, 0x2e, 0x62, 0x65, 0x6e, 0x63, - 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x1a, 0x0f, 0x2e, 0x62, 0x65, 0x6e, - 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x22, 0x04, 0xa0, 0xb5, 0x18, - 0x01, 0x12, 0x39, 0x0a, 0x0f, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, - 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0f, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, - 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x1a, 0x0f, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, - 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x34, 0x0a, 0x0a, - 0x53, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0f, 0x2e, 0x62, 0x65, 0x6e, - 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x1a, 0x0f, 0x2e, 0x62, 0x65, - 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x22, 0x04, 0xa0, 0xb5, - 0x18, 0x01, 0x12, 0x3e, 0x0a, 0x09, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, - 0x13, 0x2e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x64, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x98, 0xb5, - 0x18, 0x01, 0x42, 0x28, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x62, 0x65, - 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_benchmark_benchmark_proto_rawDesc = "" + + "\n" + + "\x19benchmark/benchmark.proto\x12\tbenchmark\x1a\x1bgoogle/protobuf/empty.proto\x1a\fgorums.proto\" \n" + + "\x04Echo\x12\x18\n" + + "\apayload\x18\x01 \x01(\fR\apayload\"@\n" + + "\bTimedMsg\x12\x1a\n" + + "\bSendTime\x18\x01 \x01(\x03R\bSendTime\x12\x18\n" + + "\apayload\x18\x02 \x01(\fR\apayload\"\x0e\n" + + "\fStartRequest\"\x0f\n" + + "\rStartResponse\"\r\n" + + "\vStopRequest\"\xad\x02\n" + + "\x06Result\x12\x12\n" + + "\x04Name\x18\x01 \x01(\tR\x04Name\x12\x1a\n" + + "\bTotalOps\x18\x02 \x01(\x04R\bTotalOps\x12\x1c\n" + + "\tTotalTime\x18\x03 \x01(\x03R\tTotalTime\x12\x1e\n" + + "\n" + + "Throughput\x18\x04 \x01(\x01R\n" + + "Throughput\x12\x1e\n" + + "\n" + + "LatencyAvg\x18\x05 \x01(\x01R\n" + + "LatencyAvg\x12\x1e\n" + + "\n" + + "LatencyVar\x18\x06 \x01(\x01R\n" + + "LatencyVar\x12 \n" + + "\vAllocsPerOp\x18\a \x01(\x04R\vAllocsPerOp\x12\x1a\n" + + "\bMemPerOp\x18\b \x01(\x04R\bMemPerOp\x127\n" + + "\vServerStats\x18\t \x03(\v2\x15.benchmark.MemoryStatR\vServerStats\"<\n" + + "\n" + + "MemoryStat\x12\x16\n" + + "\x06Allocs\x18\x01 \x01(\x04R\x06Allocs\x12\x16\n" + + "\x06Memory\x18\x02 \x01(\x04R\x06Memory2\x9c\x04\n" + + "\tBenchmark\x12O\n" + + "\x14StartServerBenchmark\x12\x17.benchmark.StartRequest\x1a\x18.benchmark.StartResponse\"\x04\xa0\xb5\x18\x01\x12F\n" + + "\x13StopServerBenchmark\x12\x16.benchmark.StopRequest\x1a\x11.benchmark.Result\"\x04\xa0\xb5\x18\x01\x12I\n" + + "\x0eStartBenchmark\x12\x17.benchmark.StartRequest\x1a\x18.benchmark.StartResponse\"\x04\xa0\xb5\x18\x01\x12D\n" + + "\rStopBenchmark\x12\x16.benchmark.StopRequest\x1a\x15.benchmark.MemoryStat\"\x04\xa0\xb5\x18\x01\x124\n" + + "\n" + + "QuorumCall\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x129\n" + + "\x0fAsyncQuorumCall\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x124\n" + + "\n" + + "SlowServer\x12\x0f.benchmark.Echo\x1a\x0f.benchmark.Echo\"\x04\xa0\xb5\x18\x01\x12>\n" + + "\tMulticast\x12\x13.benchmark.TimedMsg\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01B(Z!github.com/relab/gorums/benchmark\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_benchmark_benchmark_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_benchmark_benchmark_proto_goTypes = []any{ @@ -651,7 +617,7 @@ func file_benchmark_benchmark_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_benchmark_benchmark_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_benchmark_benchmark_proto_rawDesc), len(file_benchmark_benchmark_proto_rawDesc)), NumEnums: 0, NumMessages: 7, NumExtensions: 0, @@ -662,7 +628,6 @@ func file_benchmark_benchmark_proto_init() { MessageInfos: file_benchmark_benchmark_proto_msgTypes, }.Build() File_benchmark_benchmark_proto = out.File - file_benchmark_benchmark_proto_rawDesc = nil file_benchmark_benchmark_proto_goTypes = nil file_benchmark_benchmark_proto_depIdxs = nil } diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 2154981c1..423bc3dc9 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: benchmark/benchmark.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums.pb.go index d4fa3b759..52c8d2571 100644 --- a/cmd/protoc-gen-gorums/dev/zorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: zorums.proto @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" + unsafe "unsafe" ) const ( @@ -194,82 +195,37 @@ func (b0 MyResponse_builder) Build() *MyResponse { var File_zorums_proto protoreflect.FileDescriptor -var file_zorums_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x7a, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, - 0x64, 0x65, 0x76, 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, - 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, - 0x22, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x52, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x22, 0x22, 0x0a, 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32, 0xbd, 0x07, 0x0a, 0x0d, 0x5a, 0x6f, 0x72, 0x75, - 0x6d, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x47, 0x52, 0x50, - 0x43, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x0a, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, - 0x6c, 0x6c, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x3d, 0x0a, 0x14, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, - 0x61, 0x6c, 0x6c, 0x50, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x72, 0x67, 0x12, 0x0c, 0x2e, - 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, - 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x08, 0xa0, 0xb5, 0x18, 0x01, - 0xa0, 0xb6, 0x18, 0x01, 0x12, 0x3e, 0x0a, 0x0f, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, - 0x6c, 0x6c, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, - 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, - 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x3e, 0x0a, 0x10, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, - 0x6c, 0x6c, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, - 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x37, 0x0a, 0x10, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, - 0x6c, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x30, 0x01, 0x12, 0x45, 0x0a, - 0x1a, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x50, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x72, 0x67, 0x12, 0x0c, 0x2e, 0x64, 0x65, - 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x08, 0xa0, 0xb5, 0x18, 0x01, 0xa0, 0xb6, - 0x18, 0x01, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x15, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, - 0x6c, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x16, - 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0xa0, 0xb5, - 0x18, 0x01, 0x30, 0x01, 0x12, 0x2e, 0x0a, 0x09, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, - 0x74, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, - 0x98, 0xb5, 0x18, 0x01, 0x12, 0x3c, 0x0a, 0x13, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, - 0x74, 0x50, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x72, 0x67, 0x12, 0x0c, 0x2e, 0x64, 0x65, - 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, 0x2e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x08, 0x98, 0xb5, 0x18, 0x01, 0xa0, 0xb6, - 0x18, 0x01, 0x12, 0x2f, 0x0a, 0x0a, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x32, - 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, - 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0x98, - 0xb5, 0x18, 0x01, 0x12, 0x38, 0x0a, 0x0a, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, - 0x33, 0x12, 0x0c, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x98, 0xb5, 0x18, 0x01, 0x12, 0x42, 0x0a, - 0x0a, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x34, 0x12, 0x16, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x98, 0xb5, 0x18, - 0x01, 0x12, 0x2c, 0x0a, 0x07, 0x55, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x0c, 0x2e, 0x64, - 0x65, 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x64, 0x65, 0x76, - 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0x90, 0xb5, 0x18, 0x01, 0x12, - 0x36, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x32, 0x12, 0x0c, 0x2e, 0x64, 0x65, - 0x76, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x22, 0x04, 0x90, 0xb5, 0x18, 0x01, 0x42, 0x20, 0x5a, 0x19, 0x63, 0x6d, 0x64, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, - 0x2f, 0x64, 0x65, 0x76, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_zorums_proto_rawDesc = "" + + "\n" + + "\fzorums.proto\x12\x03dev\x1a\fgorums.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x1f\n" + + "\aRequest\x12\x14\n" + + "\x05Value\x18\x01 \x01(\tR\x05Value\"\"\n" + + "\bResponse\x12\x16\n" + + "\x06Result\x18\x01 \x01(\x03R\x06Result\"\"\n" + + "\n" + + "MyResponse\x12\x14\n" + + "\x05Value\x18\x01 \x01(\tR\x05Value2\xbd\a\n" + + "\rZorumsService\x12)\n" + + "\bGRPCCall\x12\f.dev.Request\x1a\r.dev.Response\"\x00\x12/\n" + + "\n" + + "QuorumCall\x12\f.dev.Request\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x01\x12=\n" + + "\x14QuorumCallPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01\xa0\xb6\x18\x01\x12>\n" + + "\x0fQuorumCallEmpty\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x01\x12>\n" + + "\x10QuorumCallEmpty2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa0\xb5\x18\x01\x127\n" + + "\x10QuorumCallStream\x12\f.dev.Request\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x010\x01\x12E\n" + + "\x1aQuorumCallStreamPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\xa0\xb5\x18\x01\xa0\xb6\x18\x010\x01\x12F\n" + + "\x15QuorumCallStreamEmpty\x12\x16.google.protobuf.Empty\x1a\r.dev.Response\"\x04\xa0\xb5\x18\x010\x01\x12F\n" + + "\x16QuorumCallStreamEmpty2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\xa0\xb5\x18\x010\x01\x12.\n" + + "\tMulticast\x12\f.dev.Request\x1a\r.dev.Response\"\x04\x98\xb5\x18\x01\x12<\n" + + "\x13MulticastPerNodeArg\x12\f.dev.Request\x1a\r.dev.Response\"\b\x98\xb5\x18\x01\xa0\xb6\x18\x01\x12/\n" + + "\n" + + "Multicast2\x12\f.dev.Request\x1a\r.dev.Response\"\x04\x98\xb5\x18\x01\x128\n" + + "\n" + + "Multicast3\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01\x12B\n" + + "\n" + + "Multicast4\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\"\x04\x98\xb5\x18\x01\x12,\n" + + "\aUnicast\x12\f.dev.Request\x1a\r.dev.Response\"\x04\x90\xb5\x18\x01\x126\n" + + "\bUnicast2\x12\f.dev.Request\x1a\x16.google.protobuf.Empty\"\x04\x90\xb5\x18\x01B Z\x19cmd/protoc-gen-gorums/dev\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_zorums_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_zorums_proto_goTypes = []any{ @@ -327,7 +283,7 @@ func file_zorums_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_zorums_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_zorums_proto_rawDesc), len(file_zorums_proto_rawDesc)), NumEnums: 0, NumMessages: 3, NumExtensions: 0, @@ -338,7 +294,6 @@ func file_zorums_proto_init() { MessageInfos: file_zorums_proto_msgTypes, }.Build() File_zorums_proto = out.File - file_zorums_proto_rawDesc = nil file_zorums_proto_goTypes = nil file_zorums_proto_depIdxs = nil } diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index 0e486dca6..4620fe5f3 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index cee71ca7f..d3230a138 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index 66b036f5c..58084f280 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index 1ba3b2c7a..3ac7a8ac7 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index 995d0da57..8a82a5898 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go index c0ed132d7..324c834be 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index 178231aa3..6111961a1 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: zorums.proto diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index c1dff503b..431f2600e 100644 --- a/examples/storage/proto/storage_gorums.pb.go +++ b/examples/storage/proto/storage_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+1369fe4d +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: storage/proto/storage.proto @@ -24,7 +24,6 @@ const ( // procedure calls may be invoked. type Configuration struct { gorums.RawConfiguration - nodes []*Node } // ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. @@ -37,11 +36,6 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error newCfg := &Configuration{ RawConfiguration: rawCfg, } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } return newCfg, nil } @@ -50,7 +44,11 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // // NOTE: mutating the returned slice is not supported. func (c *Configuration) Nodes() []*Node { - return c.nodes + nodes := make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + nodes[i] = &Node{n} + } + return nodes } // And returns a NodeListOption that can be used to create a new configuration combining c and d. @@ -98,12 +96,6 @@ func (m *Manager) NewConfiguration(nodeList gorums.NodeListOption) (c *Configura if err != nil { return nil, err } - - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } return c, nil } @@ -127,7 +119,6 @@ type Node struct { // StorageClient is the client interface for the Storage service. type StorageClient interface { ReadQC(ctx context.Context, in *ReadRequest) gorums.Iterator[*ReadResponse] - WriteQC(ctx context.Context, in *WriteRequest) gorums.Iterator[*WriteResponse] WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) } @@ -147,8 +138,9 @@ var _ StorageNodeClient = (*Node)(nil) // Reference imports to suppress errors if they are not otherwise used. var _ emptypb.Empty -// WriteMulticast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. test +// WriteMulticast is a quorum call invoked on each node in configuration c, + +// with the same argument in, and returns the responses as an iterator. func (c *Configuration) WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, diff --git a/gorums.pb.go b/gorums.pb.go index a542ee9b0..062b1b324 100644 --- a/gorums.pb.go +++ b/gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: gorums.proto @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" + unsafe "unsafe" ) const ( @@ -83,34 +84,17 @@ var ( var File_gorums_proto protoreflect.FileDescriptor -var file_gorums_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, - 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x32, 0x0a, 0x03, 0x72, 0x70, 0x63, 0x12, - 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0xd1, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x72, 0x70, 0x63, 0x3a, 0x3a, 0x0a, 0x07, - 0x75, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd2, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x3a, 0x3e, 0x0a, 0x09, 0x6d, 0x75, 0x6c, 0x74, - 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd3, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6d, - 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x3a, 0x40, 0x0a, 0x0a, 0x71, 0x75, 0x6f, 0x72, - 0x75, 0x6d, 0x63, 0x61, 0x6c, 0x6c, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd4, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, - 0x71, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x63, 0x61, 0x6c, 0x6c, 0x3a, 0x42, 0x0a, 0x0c, 0x70, 0x65, - 0x72, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x61, 0x72, 0x67, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xe4, 0x86, 0x03, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x72, 0x67, 0x42, 0x1e, - 0x5a, 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, - 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, - 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_gorums_proto_rawDesc = "" + + "\n" + + "\fgorums.proto\x12\x06gorums\x1a google/protobuf/descriptor.proto:2\n" + + "\x03rpc\x12\x1e.google.protobuf.MethodOptions\x18ั†\x03 \x01(\bR\x03rpc::\n" + + "\aunicast\x12\x1e.google.protobuf.MethodOptions\x18า†\x03 \x01(\bR\aunicast:>\n" + + "\tmulticast\x12\x1e.google.protobuf.MethodOptions\x18ำ†\x03 \x01(\bR\tmulticast:@\n" + + "\n" + + "quorumcall\x12\x1e.google.protobuf.MethodOptions\x18ิ†\x03 \x01(\bR\n" + + "quorumcall:B\n" + + "\fper_node_arg\x12\x1e.google.protobuf.MethodOptions\x18\xe4\x86\x03 \x01(\bR\n" + + "perNodeArgB\x1eZ\x17github.com/relab/gorums\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_gorums_proto_goTypes = []any{ (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions @@ -137,7 +121,7 @@ func file_gorums_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_gorums_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_gorums_proto_rawDesc), len(file_gorums_proto_rawDesc)), NumEnums: 0, NumMessages: 0, NumExtensions: 5, @@ -148,7 +132,6 @@ func file_gorums_proto_init() { ExtensionInfos: file_gorums_proto_extTypes, }.Build() File_gorums_proto = out.File - file_gorums_proto_rawDesc = nil file_gorums_proto_goTypes = nil file_gorums_proto_depIdxs = nil } diff --git a/internal/correctable/opts.pb.go b/internal/correctable/opts.pb.go index 9810986c1..d5b8e7053 100644 --- a/internal/correctable/opts.pb.go +++ b/internal/correctable/opts.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: internal/correctable/opts.proto @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" + unsafe "unsafe" ) const ( @@ -49,27 +50,11 @@ var ( var File_internal_correctable_opts_proto protoreflect.FileDescriptor -var file_internal_correctable_opts_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x72, 0x72, 0x65, - 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2f, 0x6f, 0x70, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x1a, 0x20, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x3a, 0x41, 0x0a, 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, - 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0xb8, 0x30, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, - 0x62, 0x6c, 0x65, 0x3a, 0x4e, 0x0a, 0x12, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, - 0x6c, 0x65, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb9, 0x30, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x11, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x42, 0x33, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, - 0x62, 0x6c, 0x65, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_internal_correctable_opts_proto_rawDesc = "" + + "\n" + + "\x1finternal/correctable/opts.proto\x12\vcorrectable\x1a google/protobuf/descriptor.proto:A\n" + + "\vcorrectable\x12\x1e.google.protobuf.MethodOptions\x18\xb80 \x01(\bR\vcorrectable:N\n" + + "\x12correctable_stream\x12\x1e.google.protobuf.MethodOptions\x18\xb90 \x01(\bR\x11correctableStreamB3Z,github.com/relab/gorums/internal/correctable\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_internal_correctable_opts_proto_goTypes = []any{ (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions @@ -93,7 +78,7 @@ func file_internal_correctable_opts_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_internal_correctable_opts_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_correctable_opts_proto_rawDesc), len(file_internal_correctable_opts_proto_rawDesc)), NumEnums: 0, NumMessages: 0, NumExtensions: 2, @@ -104,7 +89,6 @@ func file_internal_correctable_opts_proto_init() { ExtensionInfos: file_internal_correctable_opts_proto_extTypes, }.Build() File_internal_correctable_opts_proto = out.File - file_internal_correctable_opts_proto_rawDesc = nil file_internal_correctable_opts_proto_goTypes = nil file_internal_correctable_opts_proto_depIdxs = nil } diff --git a/ordering/ordering.pb.go b/ordering/ordering.pb.go index 1410143db..489bf8de8 100644 --- a/ordering/ordering.pb.go +++ b/ordering/ordering.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: ordering/ordering.proto @@ -11,6 +11,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -208,33 +209,20 @@ func (b0 MetadataEntry_builder) Build() *MetadataEntry { var File_ordering_ordering_proto protoreflect.FileDescriptor -var file_ordering_ordering_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x69, 0x6e, 0x67, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9b, 0x01, 0x0a, - 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, - 0x2a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2d, 0x0a, 0x05, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6f, 0x72, 0x64, - 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x37, 0x0a, 0x0d, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x4b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x32, 0x42, 0x0a, 0x06, 0x47, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x12, 0x38, 0x0a, - 0x0a, 0x4e, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x12, 0x2e, 0x6f, 0x72, - 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, - 0x12, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x28, 0x01, 0x30, 0x01, 0x42, 0x27, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, - 0x6d, 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x92, 0x03, 0x02, 0x08, 0x02, - 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_ordering_ordering_proto_rawDesc = "" + + "\n" + + "\x17ordering/ordering.proto\x12\bordering\x1a\x17google/rpc/status.proto\"\x9b\x01\n" + + "\bMetadata\x12\x1c\n" + + "\tMessageID\x18\x01 \x01(\x04R\tMessageID\x12\x16\n" + + "\x06Method\x18\x02 \x01(\tR\x06Method\x12*\n" + + "\x06Status\x18\x03 \x01(\v2\x12.google.rpc.StatusR\x06Status\x12-\n" + + "\x05Entry\x18\x04 \x03(\v2\x17.ordering.MetadataEntryR\x05Entry\"7\n" + + "\rMetadataEntry\x12\x10\n" + + "\x03Key\x18\x01 \x01(\tR\x03Key\x12\x14\n" + + "\x05Value\x18\x02 \x01(\tR\x05Value2B\n" + + "\x06Gorums\x128\n" + + "\n" + + "NodeStream\x12\x12.ordering.Metadata\x1a\x12.ordering.Metadata(\x010\x01B'Z github.com/relab/gorums/ordering\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_ordering_ordering_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_ordering_ordering_proto_goTypes = []any{ @@ -263,7 +251,7 @@ func file_ordering_ordering_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_ordering_ordering_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_ordering_ordering_proto_rawDesc), len(file_ordering_ordering_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -274,7 +262,6 @@ func file_ordering_ordering_proto_init() { MessageInfos: file_ordering_ordering_proto_msgTypes, }.Build() File_ordering_ordering_proto = out.File - file_ordering_ordering_proto_rawDesc = nil file_ordering_ordering_proto_goTypes = nil file_ordering_ordering_proto_depIdxs = nil } diff --git a/tests/config/config.pb.go b/tests/config/config.pb.go index 09b0f1bd4..845e635c9 100644 --- a/tests/config/config.pb.go +++ b/tests/config/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: config/config.proto @@ -11,6 +11,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -150,24 +151,17 @@ func (b0 Response_builder) Build() *Response { var File_config_config_proto protoreflect.FileDescriptor -var file_config_config_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x0c, 0x67, - 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1b, 0x0a, 0x07, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x22, 0x30, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x32, 0x3f, 0x0a, 0x0a, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x54, 0x65, 0x73, 0x74, 0x12, 0x31, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x12, 0x0f, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x42, 0x2b, 0x5a, 0x24, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, - 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_config_config_proto_rawDesc = "" + + "\n" + + "\x13config/config.proto\x12\x06config\x1a\fgorums.proto\"\x1b\n" + + "\aRequest\x12\x10\n" + + "\x03Num\x18\x01 \x01(\x04R\x03Num\"0\n" + + "\bResponse\x12\x12\n" + + "\x04Name\x18\x01 \x01(\tR\x04Name\x12\x10\n" + + "\x03Num\x18\x02 \x01(\x04R\x03Num2?\n" + + "\n" + + "ConfigTest\x121\n" + + "\x06Config\x12\x0f.config.Request\x1a\x10.config.Response\"\x04\xa0\xb5\x18\x01B+Z$github.com/relab/gorums/tests/config\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_config_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_config_config_proto_goTypes = []any{ @@ -193,7 +187,7 @@ func file_config_config_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_config_config_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_config_config_proto_rawDesc), len(file_config_config_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -204,7 +198,6 @@ func file_config_config_proto_init() { MessageInfos: file_config_config_proto_msgTypes, }.Build() File_config_config_proto = out.File - file_config_config_proto_rawDesc = nil file_config_config_proto_goTypes = nil file_config_config_proto_depIdxs = nil } diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index dc5d002ca..c01e787c8 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: config/config.proto diff --git a/tests/correctable/correctable.pb.go b/tests/correctable/correctable.pb.go index 90abddaa2..4c0057287 100644 --- a/tests/correctable/correctable.pb.go +++ b/tests/correctable/correctable.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: correctable/correctable.proto @@ -11,6 +11,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -122,33 +123,15 @@ func (b0 CorrectableResponse_builder) Build() *CorrectableResponse { var File_correctable_correctable_proto protoreflect.FileDescriptor -var file_correctable_correctable_proto_rawDesc = []byte{ - 0x0a, 0x1d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2f, 0x63, 0x6f, - 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x1a, 0x0c, 0x67, 0x6f, - 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x43, 0x6f, - 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x22, 0x2b, 0x0a, 0x13, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x32, 0xc9, 0x01, - 0x0a, 0x0f, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x65, 0x73, - 0x74, 0x12, 0x56, 0x0a, 0x0b, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, - 0x12, 0x1f, 0x2e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x43, - 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x20, 0x2e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, - 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x5e, 0x0a, 0x11, 0x43, 0x6f, 0x72, - 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1f, - 0x2e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x72, - 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x20, 0x2e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x43, 0x6f, - 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x30, 0x01, 0x42, 0x30, 0x5a, 0x29, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, - 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x72, 0x72, 0x65, - 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_correctable_correctable_proto_rawDesc = "" + + "\n" + + "\x1dcorrectable/correctable.proto\x12\vcorrectable\x1a\fgorums.proto\"\x14\n" + + "\x12CorrectableRequest\"+\n" + + "\x13CorrectableResponse\x12\x14\n" + + "\x05Level\x18\x01 \x01(\x05R\x05Level2\xc9\x01\n" + + "\x0fCorrectableTest\x12V\n" + + "\vCorrectable\x12\x1f.correctable.CorrectableRequest\x1a .correctable.CorrectableResponse\"\x04\xa0\xb5\x18\x01\x12^\n" + + "\x11CorrectableStream\x12\x1f.correctable.CorrectableRequest\x1a .correctable.CorrectableResponse\"\x04\xa0\xb5\x18\x010\x01B0Z)github.com/relab/gorums/tests/correctable\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_correctable_correctable_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_correctable_correctable_proto_goTypes = []any{ @@ -176,7 +159,7 @@ func file_correctable_correctable_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_correctable_correctable_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_correctable_correctable_proto_rawDesc), len(file_correctable_correctable_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -187,7 +170,6 @@ func file_correctable_correctable_proto_init() { MessageInfos: file_correctable_correctable_proto_msgTypes, }.Build() File_correctable_correctable_proto = out.File - file_correctable_correctable_proto_rawDesc = nil file_correctable_correctable_proto_goTypes = nil file_correctable_correctable_proto_depIdxs = nil } diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index d45c61b89..5d6048277 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: correctable/correctable.proto diff --git a/tests/dummy/dummy.pb.go b/tests/dummy/dummy.pb.go index 7ab69a686..ef88427fa 100644 --- a/tests/dummy/dummy.pb.go +++ b/tests/dummy/dummy.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: dummy/dummy.proto @@ -10,6 +10,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -64,17 +65,12 @@ func (b0 Empty_builder) Build() *Empty { var File_dummy_dummy_proto protoreflect.FileDescriptor -var file_dummy_dummy_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x2f, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x32, 0x2d, 0x0a, 0x05, 0x44, 0x75, 0x6d, 0x6d, 0x79, 0x12, 0x24, 0x0a, 0x04, - 0x54, 0x65, 0x73, 0x74, 0x12, 0x0c, 0x2e, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x1a, 0x0c, 0x2e, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x22, 0x00, 0x42, 0x2a, 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, - 0x73, 0x74, 0x73, 0x2f, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, - 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_dummy_dummy_proto_rawDesc = "" + + "\n" + + "\x11dummy/dummy.proto\x12\x05dummy\"\a\n" + + "\x05Empty2-\n" + + "\x05Dummy\x12$\n" + + "\x04Test\x12\f.dummy.Empty\x1a\f.dummy.Empty\"\x00B*Z#github.com/relab/gorums/tests/dummy\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_dummy_dummy_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_dummy_dummy_proto_goTypes = []any{ @@ -99,7 +95,7 @@ func file_dummy_dummy_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_dummy_dummy_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_dummy_dummy_proto_rawDesc), len(file_dummy_dummy_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -110,7 +106,6 @@ func file_dummy_dummy_proto_init() { MessageInfos: file_dummy_dummy_proto_msgTypes, }.Build() File_dummy_dummy_proto = out.File - file_dummy_dummy_proto_rawDesc = nil file_dummy_dummy_proto_goTypes = nil file_dummy_dummy_proto_depIdxs = nil } diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index 5845c43f2..f2ad4c14d 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: dummy/dummy.proto diff --git a/tests/metadata/metadata.pb.go b/tests/metadata/metadata.pb.go index 43ddce3ae..d86b93e57 100644 --- a/tests/metadata/metadata.pb.go +++ b/tests/metadata/metadata.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: metadata/metadata.proto @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" + unsafe "unsafe" ) const ( @@ -136,28 +137,16 @@ func (b0 IPAddr_builder) Build() *IPAddr { var File_metadata_metadata_proto protoreflect.FileDescriptor -var file_metadata_metadata_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x18, 0x0a, 0x06, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x49, 0x44, 0x22, 0x1c, 0x0a, 0x06, 0x49, 0x50, - 0x41, 0x64, 0x64, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x41, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x41, 0x64, 0x64, 0x72, 0x32, 0x7c, 0x0a, 0x0c, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x54, 0x65, 0x73, 0x74, 0x12, 0x36, 0x0a, 0x08, 0x49, 0x44, 0x46, 0x72, - 0x6f, 0x6d, 0x4d, 0x44, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x6d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x22, 0x00, - 0x12, 0x34, 0x0a, 0x06, 0x57, 0x68, 0x61, 0x74, 0x49, 0x50, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x1a, 0x10, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x49, 0x50, - 0x41, 0x64, 0x64, 0x72, 0x22, 0x00, 0x42, 0x2d, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, - 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, - 0xe8, 0x07, -} +const file_metadata_metadata_proto_rawDesc = "" + + "\n" + + "\x17metadata/metadata.proto\x12\bmetadata\x1a\x1bgoogle/protobuf/empty.proto\"\x18\n" + + "\x06NodeID\x12\x0e\n" + + "\x02ID\x18\x01 \x01(\rR\x02ID\"\x1c\n" + + "\x06IPAddr\x12\x12\n" + + "\x04Addr\x18\x01 \x01(\tR\x04Addr2|\n" + + "\fMetadataTest\x126\n" + + "\bIDFromMD\x12\x16.google.protobuf.Empty\x1a\x10.metadata.NodeID\"\x00\x124\n" + + "\x06WhatIP\x12\x16.google.protobuf.Empty\x1a\x10.metadata.IPAddr\"\x00B-Z&github.com/relab/gorums/tests/metadata\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_metadata_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_metadata_metadata_proto_goTypes = []any{ @@ -186,7 +175,7 @@ func file_metadata_metadata_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_metadata_metadata_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_metadata_metadata_proto_rawDesc), len(file_metadata_metadata_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -197,7 +186,6 @@ func file_metadata_metadata_proto_init() { MessageInfos: file_metadata_metadata_proto_msgTypes, }.Build() File_metadata_metadata_proto = out.File - file_metadata_metadata_proto_rawDesc = nil file_metadata_metadata_proto_goTypes = nil file_metadata_metadata_proto_depIdxs = nil } diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index e3553f452..28d96bcec 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: metadata/metadata.proto diff --git a/tests/oneway/oneway.pb.go b/tests/oneway/oneway.pb.go index 2f8837b4a..b9b6544b8 100644 --- a/tests/oneway/oneway.pb.go +++ b/tests/oneway/oneway.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: oneway/oneway.proto @@ -11,6 +11,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -122,28 +123,17 @@ func (b0 Empty_builder) Build() *Empty { var File_oneway_oneway_proto protoreflect.FileDescriptor -var file_oneway_oneway_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x1a, 0x0c, 0x67, - 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1b, 0x0a, 0x07, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x32, 0xae, 0x01, 0x0a, 0x0a, 0x4f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x54, 0x65, 0x73, 0x74, - 0x12, 0x2f, 0x0a, 0x07, 0x55, 0x6e, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x0f, 0x2e, 0x6f, 0x6e, - 0x65, 0x77, 0x61, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x6f, - 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, 0x90, 0xb5, 0x18, - 0x01, 0x12, 0x31, 0x0a, 0x09, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, 0x74, 0x12, 0x0f, - 0x2e, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0d, 0x2e, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x04, - 0x98, 0xb5, 0x18, 0x01, 0x12, 0x3c, 0x0a, 0x10, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x63, 0x61, 0x73, - 0x74, 0x50, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0f, 0x2e, 0x6f, 0x6e, 0x65, 0x77, 0x61, - 0x79, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x6f, 0x6e, 0x65, 0x77, - 0x61, 0x79, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x08, 0x98, 0xb5, 0x18, 0x01, 0xa0, 0xb6, - 0x18, 0x01, 0x42, 0x2b, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, - 0x73, 0x74, 0x73, 0x2f, 0x6f, 0x6e, 0x65, 0x77, 0x61, 0x79, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, - 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_oneway_oneway_proto_rawDesc = "" + + "\n" + + "\x13oneway/oneway.proto\x12\x06oneway\x1a\fgorums.proto\"\x1b\n" + + "\aRequest\x12\x10\n" + + "\x03Num\x18\x01 \x01(\x04R\x03Num\"\a\n" + + "\x05Empty2\xae\x01\n" + + "\n" + + "OnewayTest\x12/\n" + + "\aUnicast\x12\x0f.oneway.Request\x1a\r.oneway.Empty\"\x04\x90\xb5\x18\x01\x121\n" + + "\tMulticast\x12\x0f.oneway.Request\x1a\r.oneway.Empty\"\x04\x98\xb5\x18\x01\x12<\n" + + "\x10MulticastPerNode\x12\x0f.oneway.Request\x1a\r.oneway.Empty\"\b\x98\xb5\x18\x01\xa0\xb6\x18\x01B+Z$github.com/relab/gorums/tests/oneway\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_oneway_oneway_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_oneway_oneway_proto_goTypes = []any{ @@ -173,7 +163,7 @@ func file_oneway_oneway_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_oneway_oneway_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_oneway_oneway_proto_rawDesc), len(file_oneway_oneway_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -184,7 +174,6 @@ func file_oneway_oneway_proto_init() { MessageInfos: file_oneway_oneway_proto_msgTypes, }.Build() File_oneway_oneway_proto = out.File - file_oneway_oneway_proto_rawDesc = nil file_oneway_oneway_proto_goTypes = nil file_oneway_oneway_proto_depIdxs = nil } diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index cd07d6c86..9e3648f5b 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: oneway/oneway.proto diff --git a/tests/ordering/order.pb.go b/tests/ordering/order.pb.go index f19367b14..c766ab6da 100644 --- a/tests/ordering/order.pb.go +++ b/tests/ordering/order.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: ordering/order.proto @@ -11,6 +11,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -136,30 +137,18 @@ func (b0 Response_builder) Build() *Response { var File_ordering_order_proto protoreflect.FileDescriptor -var file_ordering_order_proto_rawDesc = []byte{ - 0x0a, 0x14, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, - 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1b, - 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x22, 0x24, 0x0a, 0x08, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x6e, 0x4f, 0x72, 0x64, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x49, 0x6e, 0x4f, 0x72, 0x64, 0x65, - 0x72, 0x32, 0xac, 0x01, 0x0a, 0x0a, 0x47, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x54, 0x65, 0x73, 0x74, - 0x12, 0x31, 0x0a, 0x02, 0x51, 0x43, 0x12, 0x11, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, - 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6f, 0x72, 0x64, 0x65, - 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, - 0xb5, 0x18, 0x01, 0x12, 0x36, 0x0a, 0x07, 0x51, 0x43, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x12, 0x11, - 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x12, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x12, 0x33, 0x0a, 0x08, 0x55, - 0x6e, 0x61, 0x72, 0x79, 0x52, 0x50, 0x43, 0x12, 0x11, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, - 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6f, 0x72, 0x64, - 0x65, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x42, 0x2d, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, - 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, - 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, - 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_ordering_order_proto_rawDesc = "" + + "\n" + + "\x14ordering/order.proto\x12\bordering\x1a\fgorums.proto\"\x1b\n" + + "\aRequest\x12\x10\n" + + "\x03Num\x18\x01 \x01(\x04R\x03Num\"$\n" + + "\bResponse\x12\x18\n" + + "\aInOrder\x18\x01 \x01(\bR\aInOrder2\xac\x01\n" + + "\n" + + "GorumsTest\x121\n" + + "\x02QC\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x04\xa0\xb5\x18\x01\x126\n" + + "\aQCAsync\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x04\xa0\xb5\x18\x01\x123\n" + + "\bUnaryRPC\x12\x11.ordering.Request\x1a\x12.ordering.Response\"\x00B-Z&github.com/relab/gorums/tests/ordering\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_ordering_order_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_ordering_order_proto_goTypes = []any{ @@ -189,7 +178,7 @@ func file_ordering_order_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_ordering_order_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_ordering_order_proto_rawDesc), len(file_ordering_order_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -200,7 +189,6 @@ func file_ordering_order_proto_init() { MessageInfos: file_ordering_order_proto_msgTypes, }.Build() File_ordering_order_proto = out.File - file_ordering_order_proto_rawDesc = nil file_ordering_order_proto_goTypes = nil file_ordering_order_proto_depIdxs = nil } diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index 7e6463e84..2fdb89dd2 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: ordering/order.proto diff --git a/tests/qf/qf.pb.go b/tests/qf/qf.pb.go index 0b8b29998..af177a133 100644 --- a/tests/qf/qf.pb.go +++ b/tests/qf/qf.pb.go @@ -2,7 +2,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: qf/qf.proto @@ -13,6 +13,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -138,25 +139,16 @@ func (b0 Response_builder) Build() *Response { var File_qf_qf_proto protoreflect.FileDescriptor -var file_qf_qf_proto_rawDesc = []byte{ - 0x0a, 0x0b, 0x71, 0x66, 0x2f, 0x71, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x71, - 0x66, 0x1a, 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x1f, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x22, 0x22, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, - 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x32, 0x69, 0x0a, 0x0e, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x46, 0x75, - 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x52, 0x65, 0x71, - 0x12, 0x0b, 0x2e, 0x71, 0x66, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, - 0x71, 0x66, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, - 0x01, 0x12, 0x2c, 0x0a, 0x09, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x12, 0x0b, - 0x2e, 0x71, 0x66, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x71, 0x66, - 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x04, 0xa0, 0xb5, 0x18, 0x01, 0x42, - 0x27, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, - 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, - 0x2f, 0x71, 0x66, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_qf_qf_proto_rawDesc = "" + + "\n" + + "\vqf/qf.proto\x12\x02qf\x1a\fgorums.proto\"\x1f\n" + + "\aRequest\x12\x14\n" + + "\x05Value\x18\x01 \x01(\x03R\x05Value\"\"\n" + + "\bResponse\x12\x16\n" + + "\x06Result\x18\x01 \x01(\x03R\x06Result2i\n" + + "\x0eQuorumFunction\x12)\n" + + "\x06UseReq\x12\v.qf.Request\x1a\f.qf.Response\"\x04\xa0\xb5\x18\x01\x12,\n" + + "\tIgnoreReq\x12\v.qf.Request\x1a\f.qf.Response\"\x04\xa0\xb5\x18\x01B'Z github.com/relab/gorums/tests/qf\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_qf_qf_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_qf_qf_proto_goTypes = []any{ @@ -184,7 +176,7 @@ func file_qf_qf_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_qf_qf_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_qf_qf_proto_rawDesc), len(file_qf_qf_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -195,7 +187,6 @@ func file_qf_qf_proto_init() { MessageInfos: file_qf_qf_proto_msgTypes, }.Build() File_qf_qf_proto = out.File - file_qf_qf_proto_rawDesc = nil file_qf_qf_proto_goTypes = nil file_qf_qf_proto_depIdxs = nil } diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 44aef00ec..cbb880ecb 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: qf/qf.proto diff --git a/tests/tls/tls.pb.go b/tests/tls/tls.pb.go index 567a53ebf..0dfe543fe 100644 --- a/tests/tls/tls.pb.go +++ b/tests/tls/tls.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: tls/tls.proto @@ -10,6 +10,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -121,19 +122,14 @@ func (b0 Response_builder) Build() *Response { var File_tls_tls_proto protoreflect.FileDescriptor -var file_tls_tls_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x74, 0x6c, 0x73, 0x2f, 0x74, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x03, 0x74, 0x6c, 0x73, 0x22, 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, - 0x1a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x4f, - 0x4b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x4f, 0x4b, 0x32, 0x2f, 0x0a, 0x03, 0x54, - 0x4c, 0x53, 0x12, 0x28, 0x0a, 0x07, 0x54, 0x65, 0x73, 0x74, 0x54, 0x4c, 0x53, 0x12, 0x0c, 0x2e, - 0x74, 0x6c, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x74, 0x6c, - 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x28, 0x5a, 0x21, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, - 0x2f, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x74, 0x6c, - 0x73, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x70, 0xe8, 0x07, -} +const file_tls_tls_proto_rawDesc = "" + + "\n" + + "\rtls/tls.proto\x12\x03tls\"\t\n" + + "\aRequest\"\x1a\n" + + "\bResponse\x12\x0e\n" + + "\x02OK\x18\x01 \x01(\bR\x02OK2/\n" + + "\x03TLS\x12(\n" + + "\aTestTLS\x12\f.tls.Request\x1a\r.tls.Response\"\x00B(Z!github.com/relab/gorums/tests/tls\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_tls_tls_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_tls_tls_proto_goTypes = []any{ @@ -159,7 +155,7 @@ func file_tls_tls_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_tls_tls_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_tls_tls_proto_rawDesc), len(file_tls_tls_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -170,7 +166,6 @@ func file_tls_tls_proto_init() { MessageInfos: file_tls_tls_proto_msgTypes, }.Build() File_tls_tls_proto = out.File - file_tls_tls_proto_rawDesc = nil file_tls_tls_proto_goTypes = nil file_tls_tls_proto_depIdxs = nil } diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 9d4f8ceb6..f66b8c3a6 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: tls/tls.proto diff --git a/tests/unresponsive/unresponsive.pb.go b/tests/unresponsive/unresponsive.pb.go index bd367e97c..15cd35237 100644 --- a/tests/unresponsive/unresponsive.pb.go +++ b/tests/unresponsive/unresponsive.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 +// protoc-gen-go v1.36.6 // protoc v6.30.2 // source: unresponsive/unresponsive.proto @@ -10,6 +10,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -64,21 +65,12 @@ func (b0 Empty_builder) Build() *Empty { var File_unresponsive_unresponsive_proto protoreflect.FileDescriptor -var file_unresponsive_unresponsive_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x2f, 0x75, - 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x0c, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x22, - 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x4e, 0x0a, 0x0c, 0x55, 0x6e, 0x72, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x12, 0x3e, 0x0a, 0x10, 0x54, 0x65, 0x73, 0x74, - 0x55, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x12, 0x13, 0x2e, 0x75, - 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x1a, 0x13, 0x2e, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x31, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x62, 0x2f, 0x67, 0x6f, 0x72, - 0x75, 0x6d, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x75, 0x6e, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, -} +const file_unresponsive_unresponsive_proto_rawDesc = "" + + "\n" + + "\x1funresponsive/unresponsive.proto\x12\funresponsive\"\a\n" + + "\x05Empty2N\n" + + "\fUnresponsive\x12>\n" + + "\x10TestUnresponsive\x12\x13.unresponsive.Empty\x1a\x13.unresponsive.Empty\"\x00B1Z*github.com/relab/gorums/tests/unresponsive\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_unresponsive_unresponsive_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_unresponsive_unresponsive_proto_goTypes = []any{ @@ -103,7 +95,7 @@ func file_unresponsive_unresponsive_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_unresponsive_unresponsive_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_unresponsive_unresponsive_proto_rawDesc), len(file_unresponsive_unresponsive_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -114,7 +106,6 @@ func file_unresponsive_unresponsive_proto_init() { MessageInfos: file_unresponsive_unresponsive_proto_msgTypes, }.Build() File_unresponsive_unresponsive_proto = out.File - file_unresponsive_unresponsive_proto_rawDesc = nil file_unresponsive_unresponsive_proto_goTypes = nil file_unresponsive_unresponsive_proto_depIdxs = nil } diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index bbab90ac1..ec0b15921 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+206a5710 +// protoc-gen-gorums v0.9.0-devel+f350194c // protoc v6.30.2 // source: unresponsive/unresponsive.proto From 43f9197da4585bd80112d7ae84cad6dc759aa020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Salhus?= Date: Fri, 9 May 2025 19:01:30 +0200 Subject: [PATCH 14/27] Metadata parse id from string to uint32 correctly --- tests/metadata/metadata_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/metadata/metadata_test.go b/tests/metadata/metadata_test.go index dde393456..429d52809 100644 --- a/tests/metadata/metadata_test.go +++ b/tests/metadata/metadata_test.go @@ -27,7 +27,7 @@ func (srv testSrv) IDFromMD(ctx gorums.ServerCtx, _ *emptypb.Empty) (resp *NodeI if len(v) < 1 { return nil, status.Error(codes.NotFound, "missing metadata field: id") } - id, err := strconv.Atoi(v[0]) + id, err := strconv.ParseUint(v[0], 10, 32) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "value of id field: %q is not a number: %v", v[0], err) } From 3313e9835f8180b463fd4cff553392d64bf8fdb8 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 12:01:02 +0200 Subject: [PATCH 15/27] remove generated datatypes --- benchmark/benchmark_gorums.pb.go | 26 +--------------- .../dev/zorums_client_gorums.pb.go | 2 +- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_quorumcall_gorums.pb.go | 2 +- .../dev/zorums_rpc_gorums.pb.go | 2 +- .../dev/zorums_server_gorums.pb.go | 2 +- .../dev/zorums_types_gorums.pb.go | 31 ------------------- .../dev/zorums_unicast_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/gengorums/gorums.go | 1 - .../gengorums/gorums_func_map.go | 11 ------- .../gengorums/template_datatypes.go | 14 --------- examples/storage/proto/storage_gorums.pb.go | 14 +-------- tests/config/config_gorums.pb.go | 8 +---- tests/correctable/correctable_gorums.pb.go | 8 +---- tests/dummy/dummy_gorums.pb.go | 2 +- tests/metadata/metadata_gorums.pb.go | 2 +- tests/oneway/oneway_gorums.pb.go | 2 +- tests/ordering/order_gorums.pb.go | 8 +---- tests/qf/qf_gorums.pb.go | 8 +---- tests/tls/tls_gorums.pb.go | 2 +- tests/unresponsive/unresponsive_gorums.pb.go | 2 +- 21 files changed, 17 insertions(+), 134 deletions(-) delete mode 100644 cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go delete mode 100644 cmd/protoc-gen-gorums/gengorums/template_datatypes.go diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 423bc3dc9..f23370b85 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: benchmark/benchmark.proto @@ -296,27 +296,3 @@ func RegisterBenchmarkServer(srv *gorums.Server, impl BenchmarkServer) { impl.Multicast(ctx, req) }) } - -type internalEcho struct { - nid uint32 - reply *Echo - err error -} - -type internalMemoryStat struct { - nid uint32 - reply *MemoryStat - err error -} - -type internalResult struct { - nid uint32 - reply *Result - err error -} - -type internalStartResponse struct { - nid uint32 - reply *StartResponse - err error -} diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index 4620fe5f3..2c8e47c21 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index d3230a138..9b370b965 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index 58084f280..c7e9d83b9 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index 3ac7a8ac7..0b6b69d9b 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index 8a82a5898..963d5a900 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go deleted file mode 100644 index 324c834be..000000000 --- a/cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go +++ /dev/null @@ -1,31 +0,0 @@ -// Code generated by protoc-gen-gorums. DO NOT EDIT. -// versions: -// protoc-gen-gorums v0.9.0-devel+f350194c -// protoc v6.30.2 -// source: zorums.proto - -package dev - -import ( - gorums "github.com/relab/gorums" - emptypb "google.golang.org/protobuf/types/known/emptypb" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = gorums.EnforceVersion(9 - gorums.MinVersion) - // Verify that the gorums runtime is sufficiently up-to-date. - _ = gorums.EnforceVersion(gorums.MaxVersion - 9) -) - -type internalEmpty struct { - nid uint32 - reply *emptypb.Empty - err error -} - -type internalResponse struct { - nid uint32 - reply *Response - err error -} diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index 6111961a1..d0abbc752 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/gengorums/gorums.go b/cmd/protoc-gen-gorums/gengorums/gorums.go index 4e2929718..f20fdaaab 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -238,7 +238,6 @@ func callTypeName(ext *protoimpl.ExtensionInfo) string { // The entries in this map is used to generate dev/zorums_{type}.pb.go // files for the different keys. var gorumsCallTypesInfo = map[string]*callTypeInfo{ - "types": {template: dataTypes}, "server": {template: server}, "client": {template: client}, diff --git a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go index d34185a26..5cdf49d64 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go @@ -95,7 +95,6 @@ var funcMap = template.FuncMap{ "out": out, "outType": outType, "internalOut": internalOut, - "mapInternalOutType": mapInternalOutType, "unexport": unexport, "contains": strings.Contains, "field": field, @@ -130,16 +129,6 @@ func internalOut(out string) string { return fmt.Sprintf("internal%s", field(out)) } -func mapInternalOutType(g *protogen.GeneratedFile, services []*protogen.Service) (s map[string]string) { - return mapType(g, services, func(g *protogen.GeneratedFile, method *protogen.Method, s map[string]string) { - if hasMethodOption(method, callTypesWithInternal...) { - out := out(g, method) - intOut := internalOut(out) - s[intOut] = out - } - }) -} - // field derives an embedded field name from the given typeName. // If typeName contains a package, this will be removed. func field(typeName string) string { diff --git a/cmd/protoc-gen-gorums/gengorums/template_datatypes.go b/cmd/protoc-gen-gorums/gengorums/template_datatypes.go deleted file mode 100644 index 1e96e4acf..000000000 --- a/cmd/protoc-gen-gorums/gengorums/template_datatypes.go +++ /dev/null @@ -1,14 +0,0 @@ -package gengorums - -var internalOutDataType = ` -{{$_ := use "gorums.EnforceVersion" .GenFile}} -{{range $intOut, $out := mapInternalOutType .GenFile .Services}} -type {{$intOut}} struct { - nid uint32 - reply *{{$out}} - err error -} -{{end}} -` - -var dataTypes = internalOutDataType diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index 431f2600e..2f2e95360 100644 --- a/examples/storage/proto/storage_gorums.pb.go +++ b/examples/storage/proto/storage_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: storage/proto/storage.proto @@ -242,15 +242,3 @@ func RegisterStorageServer(srv *gorums.Server, impl StorageServer) { impl.WriteMulticast(ctx, req) }) } - -type internalReadResponse struct { - nid uint32 - reply *ReadResponse - err error -} - -type internalWriteResponse struct { - nid uint32 - reply *WriteResponse - err error -} diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index c01e787c8..5ea2915ab 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: config/config.proto @@ -149,9 +149,3 @@ func RegisterConfigTestServer(srv *gorums.Server, impl ConfigTestServer) { gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) }) } - -type internalResponse struct { - nid uint32 - reply *Response - err error -} diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 5d6048277..61d1c4aa0 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: correctable/correctable.proto @@ -180,9 +180,3 @@ func RegisterCorrectableTestServer(srv *gorums.Server, impl CorrectableTestServe } }) } - -type internalCorrectableResponse struct { - nid uint32 - reply *CorrectableResponse - err error -} diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index f2ad4c14d..4d27881fe 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: dummy/dummy.proto diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index 28d96bcec..0b02b5cf2 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: metadata/metadata.proto diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index 9e3648f5b..5f4d77501 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: oneway/oneway.proto diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index 2fdb89dd2..82e49bd08 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: ordering/order.proto @@ -201,9 +201,3 @@ func RegisterGorumsTestServer(srv *gorums.Server, impl GorumsTestServer) { gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) }) } - -type internalResponse struct { - nid uint32 - reply *Response - err error -} diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index cbb880ecb..a8e6c9460 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: qf/qf.proto @@ -170,9 +170,3 @@ func RegisterQuorumFunctionServer(srv *gorums.Server, impl QuorumFunctionServer) gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) }) } - -type internalResponse struct { - nid uint32 - reply *Response - err error -} diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index f66b8c3a6..9a5e65efa 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: tls/tls.proto diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index ec0b15921..083ca0c02 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+f350194c +// protoc-gen-gorums v0.9.0-devel+43f9197d // protoc v6.30.2 // source: unresponsive/unresponsive.proto From a2e824c02906ba7e81a16c4ce9f4dc83f4c70f48 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 12:11:33 +0200 Subject: [PATCH 16/27] remove unused template functions --- .../gengorums/gorums_func_map.go | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go index 5cdf49d64..bd51879b7 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go @@ -77,15 +77,9 @@ var funcMap = template.FuncMap{ "isStream": func(method *protogen.Method) bool { return method.Desc.IsStreamingServer() }, - "docName": func(method *protogen.Method) string { - return callType(method).docName - }, "fullName": func(method *protogen.Method) string { return fmt.Sprintf("/%s/%s", method.Parent.Desc.FullName(), method.Desc.Name()) }, - "serviceName": func(method *protogen.Method) string { - return string(method.Parent.Desc.Name()) - }, "in": func(g *protogen.GeneratedFile, method *protogen.Method) string { return g.QualifiedGoIdent(method.Input.GoIdent) }, @@ -93,38 +87,19 @@ var funcMap = template.FuncMap{ return hasMethodOption(method, gorums.E_Multicast, gorums.E_Unicast) }, "out": out, - "outType": outType, "internalOut": internalOut, "unexport": unexport, "contains": strings.Contains, - "field": field, "configurationsServices": configurationsServices, "configurationMethods": configurationMethods, "nodeServices": nodeServices, "nodeMethods": nodeMethods, } -type mapFunc func(*protogen.GeneratedFile, *protogen.Method, map[string]string) - -// mapType returns a map of types as defined by the function mapFn. -func mapType(g *protogen.GeneratedFile, services []*protogen.Service, mapFn mapFunc) (s map[string]string) { - s = make(map[string]string) - for _, service := range services { - for _, method := range service.Methods { - mapFn(g, method, s) - } - } - return s -} - func out(g *protogen.GeneratedFile, method *protogen.Method) string { return g.QualifiedGoIdent(method.Output.GoIdent) } -func outType(method *protogen.Method, out string) string { - return fmt.Sprintf("%s%s", callType(method).outPrefix, field(out)) -} - func internalOut(out string) string { return fmt.Sprintf("internal%s", field(out)) } From 8a07eb8e234889e438c014ea87beb7b76248dadb Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 12:13:48 +0200 Subject: [PATCH 17/27] remove unused hasAllMethodOptions --- cmd/protoc-gen-gorums/gengorums/gorums.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/cmd/protoc-gen-gorums/gengorums/gorums.go b/cmd/protoc-gen-gorums/gengorums/gorums.go index f20fdaaab..26d82c831 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -311,17 +311,6 @@ func hasMethodOption(method *protogen.Method, methodOptions ...*protoimpl.Extens return false } -// hasAllMethodOption returns true if the method has all of the given method options -func hasAllMethodOption(method *protogen.Method, methodOptions ...*protoimpl.ExtensionInfo) bool { - ext := protoimpl.X.MessageOf(method.Desc.Options()).Interface() - for _, callType := range methodOptions { - if !proto.HasExtension(ext, callType) { - return false - } - } - return true -} - // validateOptions returns an error if the extension options // for the provided method are incompatible. func validateOptions(method *protogen.Method) error { From 2bd49c51cc910b2b62ffabe0469f9549bd865ecb Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 12:16:26 +0200 Subject: [PATCH 18/27] deepsource fix: CRT-A0001 --- channel.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/channel.go b/channel.go index 071b74365..528861a17 100644 --- a/channel.go +++ b/channel.go @@ -327,11 +327,11 @@ func (c *channel) reconnect(maxRetries float64) { return } delay := float64(backoffCfg.BaseDelay) - max := float64(backoffCfg.MaxDelay) - for r := retries; delay < max && r > 0; r-- { + maxDelay := float64(backoffCfg.MaxDelay) + for r := retries; delay < maxDelay && r > 0; r-- { delay *= backoffCfg.Multiplier } - delay = math.Min(delay, max) + delay = math.Min(delay, maxDelay) delay *= 1 + backoffCfg.Jitter*(rand.Float64()*2-1) select { case <-time.After(time.Duration(delay)): From e5c1c4aa3f2c1ec2a67cb820ea8d7962acf05a86 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 12:50:28 +0200 Subject: [PATCH 19/27] deepsource fixes --- cmd/protoc-gen-gorums/dev/config.go | 2 +- cmd/protoc-gen-gorums/gengorums/gorums.go | 3 +-- encoding.go | 4 ++-- iterator.go | 2 +- tests/correctable/correctable_test.go | 12 ++++++------ tests/qf/qf_test.go | 4 ++-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/cmd/protoc-gen-gorums/dev/config.go b/cmd/protoc-gen-gorums/dev/config.go index 17bdafb81..0d26586b7 100644 --- a/cmd/protoc-gen-gorums/dev/config.go +++ b/cmd/protoc-gen-gorums/dev/config.go @@ -27,7 +27,7 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // order as they were provided in the creation of the Manager. // // NOTE: mutating the returned slice is not supported. -func (c *Configuration) Nodes() []*Node { +func (c Configuration) Nodes() []*Node { nodes := make([]*Node, c.Size()) for i, n := range c.RawConfiguration { nodes[i] = &Node{n} diff --git a/cmd/protoc-gen-gorums/gengorums/gorums.go b/cmd/protoc-gen-gorums/gengorums/gorums.go index 26d82c831..5681fccc5 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -314,8 +314,7 @@ func hasMethodOption(method *protogen.Method, methodOptions ...*protoimpl.Extens // validateOptions returns an error if the extension options // for the provided method are incompatible. func validateOptions(method *protogen.Method) error { - switch { - case !hasMethodOption(method, gorums.E_Multicast) && method.Desc.IsStreamingClient(): + if !hasMethodOption(method, gorums.E_Multicast) && method.Desc.IsStreamingClient() { return optionErrorf("is required for client-server stream methods", method, gorums.E_Multicast) } return nil diff --git a/encoding.go b/encoding.go index d3844fc03..6a16edac6 100644 --- a/encoding.go +++ b/encoding.go @@ -50,11 +50,11 @@ func NewCodec() *Codec { } // Name returns the name of the Codec. -func (c Codec) Name() string { +func (_ Codec) Name() string { return ContentSubtype } -func (c Codec) String() string { +func (_ Codec) String() string { return ContentSubtype } diff --git a/iterator.go b/iterator.go index 8689d704f..fd8d2baab 100644 --- a/iterator.go +++ b/iterator.go @@ -27,7 +27,7 @@ func NewResponse[messageType proto.Message](msg messageType, err error, nid uint } } -// The Unpack methods lets you destructure the response in a single line +// Unpack destructures the response func (r Response[messageType]) Unpack() (messageType, error, uint32) { return r.Msg, r.Err, r.Nid } diff --git a/tests/correctable/correctable_test.go b/tests/correctable/correctable_test.go index 0d00372d4..5232ad0f5 100644 --- a/tests/correctable/correctable_test.go +++ b/tests/correctable/correctable_test.go @@ -14,8 +14,8 @@ import ( // n is the number of replicas, and div is a divider. // the target level is n, and the level is calculated by the quorum function // by dividing the sum of levels from the servers with the divider. -func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration, int, int) *gorums.Correctable[int]) { - addrs, teardown := gorums.TestSetup(t, n, func(i int) gorums.ServerIface { +func run(t *testing.T, n, div int, corr func(context.Context, *Configuration, int, int) *gorums.Correctable[int]) { + addrs, teardown := gorums.TestSetup(t, n, func(_ int) gorums.ServerIface { gorumsSrv := gorums.NewServer() RegisterCorrectableTestServer(gorumsSrv, &testSrv{n}) return gorumsSrv @@ -77,7 +77,7 @@ func (q qspec) corrQF(responses gorums.Iterator[*CorrectableResponse], levelSet } func TestCorrectable(t *testing.T) { - run(t, 4, 1, func(ctx context.Context, c *Configuration, n int, div int) *gorums.Correctable[int] { + run(t, 4, 1, func(ctx context.Context, c *Configuration, n, div int) *gorums.Correctable[int] { corr := c.Correctable(ctx, &CorrectableRequest{}) qspec := qspec{div, n} return gorums.IterCorrectable(corr, qspec.corrQF) @@ -85,7 +85,7 @@ func TestCorrectable(t *testing.T) { } func TestCorrectableStream(t *testing.T) { - run(t, 4, 4, func(ctx context.Context, c *Configuration, n int, div int) *gorums.Correctable[int] { + run(t, 4, 4, func(ctx context.Context, c *Configuration, n, div int) *gorums.Correctable[int] { corr := c.CorrectableStream(ctx, &CorrectableRequest{}) qspec := qspec{div, n} return gorums.IterCorrectable(corr, qspec.corrQF) @@ -96,7 +96,7 @@ type testSrv struct { n int } -func (srv testSrv) CorrectableStream(_ gorums.ServerCtx, request *CorrectableRequest, send func(response *CorrectableResponse) error) error { +func (srv testSrv) CorrectableStream(_ gorums.ServerCtx, _ *CorrectableRequest, send func(response *CorrectableResponse) error) error { for i := range srv.n { err := send(CorrectableResponse_builder{Level: int32(i + 1)}.Build()) if err != nil { @@ -106,6 +106,6 @@ func (srv testSrv) CorrectableStream(_ gorums.ServerCtx, request *CorrectableReq return nil } -func (srv testSrv) Correctable(_ gorums.ServerCtx, request *CorrectableRequest) (response *CorrectableResponse, err error) { +func (_ testSrv) Correctable(_ gorums.ServerCtx, _ *CorrectableRequest) (response *CorrectableResponse, err error) { return CorrectableResponse_builder{Level: 1}.Build(), nil } diff --git a/tests/qf/qf_test.go b/tests/qf/qf_test.go index 0346661bf..49efe68e7 100644 --- a/tests/qf/qf_test.go +++ b/tests/qf/qf_test.go @@ -251,11 +251,11 @@ func BenchmarkQF(b *testing.B) { type testSrv struct{} -func (s testSrv) UseReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { +func (_ testSrv) UseReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { return Response_builder{Result: req.GetValue()}.Build(), nil } -func (s testSrv) IgnoreReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { +func (_ testSrv) IgnoreReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { return Response_builder{Result: req.GetValue()}.Build(), nil } From b866c06dc6cbebe2b95334075933e823a0334713 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 13:23:18 +0200 Subject: [PATCH 20/27] more deepsource fixes --- cmd/protoc-gen-gorums/dev/config.go | 6 ++-- cmd/protoc-gen-gorums/gengorums/gorums.go | 36 ------------------- .../gengorums/template_static.go | 2 +- encoding.go | 4 +-- tests/config/config_test.go | 2 +- tests/correctable/correctable_test.go | 2 +- tests/oneway/oneway_test.go | 8 ++--- tests/qf/qf_test.go | 4 +-- 8 files changed, 14 insertions(+), 50 deletions(-) diff --git a/cmd/protoc-gen-gorums/dev/config.go b/cmd/protoc-gen-gorums/dev/config.go index 0d26586b7..fa96aa8d4 100644 --- a/cmd/protoc-gen-gorums/dev/config.go +++ b/cmd/protoc-gen-gorums/dev/config.go @@ -27,7 +27,7 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // order as they were provided in the creation of the Manager. // // NOTE: mutating the returned slice is not supported. -func (c Configuration) Nodes() []*Node { +func (c *Configuration) Nodes() []*Node { nodes := make([]*Node, c.Size()) for i, n := range c.RawConfiguration { nodes[i] = &Node{n} @@ -36,12 +36,12 @@ func (c Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/cmd/protoc-gen-gorums/gengorums/gorums.go b/cmd/protoc-gen-gorums/gengorums/gorums.go index 5681fccc5..69ae2d9cc 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -147,34 +147,6 @@ func genGorumsMethods(gorumsType string, data servicesData, callTypeInfo *callTy } } -// callType returns call type information for the given method. -// If the given method has specified a Gorums method option that -// correspond to a call type, this call type is returned. Further, -// if the call type has a sub call type, then this is returned instead. -func callType(method *protogen.Method) *callTypeInfo { - for _, callTypeInfo := range callTypeOptions(method) { - callType := callTypeInfo.deriveCallType(method) - if callType.check(method) { - return callType - } - } - panic(fmt.Sprintf("unknown call type for method %s\n", method.GoName)) -} - -// callTypeOptions returns all Gorums call types for the given method. -func callTypeOptions(method *protogen.Method) []*callTypeInfo { - methExt := protoimpl.X.MessageOf(method.Desc.Options()).Interface() - var options []*callTypeInfo - for _, callType := range gorumsCallTypesInfo { - if callType.extInfo != nil { - if proto.HasExtension(methExt, callType.extInfo) { - options = append(options, callType) - } - } - } - return options -} - // hasGorumsMethods returns true if one of the methods in the set of services // has a Gorums call type. func hasGorumsMethods(services []*protogen.Service) bool { @@ -199,7 +171,6 @@ type callTypeInfo struct { extInfo *protoimpl.ExtensionInfo docName string template string - outPrefix string chkFn func(m *protogen.Method) bool nestedCallType map[string]*callTypeInfo } @@ -283,13 +254,6 @@ var gorumsCallTypes = []*protoimpl.ExtensionInfo{ gorums.E_Unicast, } -// callTypesWithInternal should list all available call types that -// has a quorum function and hence need an internal type that wraps -// the return type with additional information. -var callTypesWithInternal = []*protoimpl.ExtensionInfo{ - gorums.E_Quorumcall, -} - // hasGorumsCallType returns true if the given method has specified // one of the call types supported by Gorums. func hasGorumsCallType(method *protogen.Method) bool { diff --git a/cmd/protoc-gen-gorums/gengorums/template_static.go b/cmd/protoc-gen-gorums/gengorums/template_static.go index ea183512e..02a98687b 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_static.go +++ b/cmd/protoc-gen-gorums/gengorums/template_static.go @@ -34,7 +34,7 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // order as they were provided in the creation of the Manager. // // NOTE: mutating the returned slice is not supported. -func (c *Configuration) Nodes() []*Node { +func (c Configuration) Nodes() []*Node { nodes := make([]*Node, c.Size()) for i, n := range c.RawConfiguration { nodes[i] = &Node{n} diff --git a/encoding.go b/encoding.go index 6a16edac6..93faa0165 100644 --- a/encoding.go +++ b/encoding.go @@ -50,11 +50,11 @@ func NewCodec() *Codec { } // Name returns the name of the Codec. -func (_ Codec) Name() string { +func (Codec) Name() string { return ContentSubtype } -func (_ Codec) String() string { +func (Codec) String() string { return ContentSubtype } diff --git a/tests/config/config_test.go b/tests/config/config_test.go index c1b2ca484..fb3274c48 100644 --- a/tests/config/config_test.go +++ b/tests/config/config_test.go @@ -14,7 +14,7 @@ type cfgSrv struct { name string } -func (srv cfgSrv) Config(ctx gorums.ServerCtx, req *Request) (resp *Response, err error) { +func (srv cfgSrv) Config(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { return Response_builder{ Name: srv.name, Num: req.GetNum(), diff --git a/tests/correctable/correctable_test.go b/tests/correctable/correctable_test.go index 5232ad0f5..13d542876 100644 --- a/tests/correctable/correctable_test.go +++ b/tests/correctable/correctable_test.go @@ -106,6 +106,6 @@ func (srv testSrv) CorrectableStream(_ gorums.ServerCtx, _ *CorrectableRequest, return nil } -func (_ testSrv) Correctable(_ gorums.ServerCtx, _ *CorrectableRequest) (response *CorrectableResponse, err error) { +func (testSrv) Correctable(_ gorums.ServerCtx, _ *CorrectableRequest) (response *CorrectableResponse, err error) { return CorrectableResponse_builder{Level: 1}.Build(), nil } diff --git a/tests/oneway/oneway_test.go b/tests/oneway/oneway_test.go index 229d83208..4604c9fab 100644 --- a/tests/oneway/oneway_test.go +++ b/tests/oneway/oneway_test.go @@ -18,7 +18,7 @@ type onewaySrv struct { received chan *oneway.Request } -func (s *onewaySrv) Unicast(ctx gorums.ServerCtx, r *oneway.Request) { +func (s *onewaySrv) Unicast(_ gorums.ServerCtx, r *oneway.Request) { if s.benchmark { return } @@ -26,7 +26,7 @@ func (s *onewaySrv) Unicast(ctx gorums.ServerCtx, r *oneway.Request) { s.wg.Done() } -func (s *onewaySrv) Multicast(ctx gorums.ServerCtx, r *oneway.Request) { +func (s *onewaySrv) Multicast(_ gorums.ServerCtx, r *oneway.Request) { if s.benchmark { return } @@ -34,7 +34,7 @@ func (s *onewaySrv) Multicast(ctx gorums.ServerCtx, r *oneway.Request) { s.wg.Done() } -func (s *onewaySrv) MulticastPerNode(ctx gorums.ServerCtx, r *oneway.Request) { +func (s *onewaySrv) MulticastPerNode(_ gorums.ServerCtx, r *oneway.Request) { if s.benchmark { return } @@ -141,7 +141,7 @@ func TestMulticastPerNode(t *testing.T) { f := func(msg *oneway.Request, id uint32) *oneway.Request { return oneway.Request_builder{Num: add(msg.GetNum(), id)}.Build() } - ignoreNodes := []int{} + var ignoreNodes []int ignore := func(id uint32) bool { for _, ignore := range ignoreNodes { return id == uint32(ignore) diff --git a/tests/qf/qf_test.go b/tests/qf/qf_test.go index 49efe68e7..224c4f8ce 100644 --- a/tests/qf/qf_test.go +++ b/tests/qf/qf_test.go @@ -251,11 +251,11 @@ func BenchmarkQF(b *testing.B) { type testSrv struct{} -func (_ testSrv) UseReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { +func (testSrv) UseReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { return Response_builder{Result: req.GetValue()}.Build(), nil } -func (_ testSrv) IgnoreReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { +func (testSrv) IgnoreReq(_ gorums.ServerCtx, req *Request) (resp *Response, err error) { return Response_builder{Result: req.GetValue()}.Build(), nil } From 09c177d2b4cfaa5c2fda757e1a81ad213642d071 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 13:23:29 +0200 Subject: [PATCH 21/27] recompile protos --- benchmark/benchmark_gorums.pb.go | 6 +++--- cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/gengorums/template_static.go | 6 +++--- examples/storage/proto/storage_gorums.pb.go | 6 +++--- tests/config/config_gorums.pb.go | 6 +++--- tests/correctable/correctable_gorums.pb.go | 6 +++--- tests/dummy/dummy_gorums.pb.go | 6 +++--- tests/metadata/metadata_gorums.pb.go | 6 +++--- tests/oneway/oneway_gorums.pb.go | 6 +++--- tests/ordering/order_gorums.pb.go | 6 +++--- tests/qf/qf_gorums.pb.go | 6 +++--- tests/tls/tls_gorums.pb.go | 6 +++--- tests/unresponsive/unresponsive_gorums.pb.go | 6 +++--- 18 files changed, 42 insertions(+), 42 deletions(-) diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index f23370b85..6ab20323d 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: benchmark/benchmark.proto @@ -52,13 +52,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index 2c8e47c21..8e8083e0a 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index 9b370b965..c94774450 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index c7e9d83b9..9a0ab7d5f 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index 0b6b69d9b..54afd7c7c 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index 963d5a900..8976ad7e8 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index d0abbc752..6f5d7ce73 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/gengorums/template_static.go b/cmd/protoc-gen-gorums/gengorums/template_static.go index 02a98687b..a782b6682 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_static.go +++ b/cmd/protoc-gen-gorums/gengorums/template_static.go @@ -34,7 +34,7 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*Configuration, error // order as they were provided in the creation of the Manager. // // NOTE: mutating the returned slice is not supported. -func (c Configuration) Nodes() []*Node { +func (c *Configuration) Nodes() []*Node { nodes := make([]*Node, c.Size()) for i, n := range c.RawConfiguration { nodes[i] = &Node{n} @@ -43,13 +43,13 @@ func (c Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index 2f2e95360..214b5efd7 100644 --- a/examples/storage/proto/storage_gorums.pb.go +++ b/examples/storage/proto/storage_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: storage/proto/storage.proto @@ -52,13 +52,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index 5ea2915ab..39df1d53f 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: config/config.proto @@ -51,13 +51,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 61d1c4aa0..a78cb0dbd 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: correctable/correctable.proto @@ -53,13 +53,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index 4d27881fe..59ee93b1c 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: dummy/dummy.proto @@ -51,13 +51,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index 0b02b5cf2..db83d8749 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: metadata/metadata.proto @@ -52,13 +52,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index 5f4d77501..1d58ef34a 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: oneway/oneway.proto @@ -52,13 +52,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index 82e49bd08..76bfb0cf7 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: ordering/order.proto @@ -51,13 +51,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index a8e6c9460..5837d99cf 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: qf/qf.proto @@ -51,13 +51,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 9a5e65efa..6148ea8df 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: tls/tls.proto @@ -51,13 +51,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index 083ca0c02..559a9a9b8 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+43f9197d +// protoc-gen-gorums v0.9.0-devel+e5c1c4aa // protoc v6.30.2 // source: unresponsive/unresponsive.proto @@ -51,13 +51,13 @@ func (c *Configuration) Nodes() []*Node { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c Configuration) And(d *Configuration) gorums.NodeListOption { +func (c *Configuration) And(d *Configuration) gorums.NodeListOption { return c.RawConfiguration.And(d.RawConfiguration) } // Except returns a NodeListOption that can be used to create a new configuration // from c without the nodes in rm. -func (c Configuration) Except(rm *Configuration) gorums.NodeListOption { +func (c *Configuration) Except(rm *Configuration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } From a005ccc0a991acb61f41a8124d74ba67c4c30fa7 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 17:31:44 +0200 Subject: [PATCH 22/27] rename Iterator to Responses --- async.go | 4 +-- benchmark/benchmark.go | 2 +- benchmark/benchmark_gorums.pb.go | 30 +++++++++---------- benchmark/qspec.go | 6 ++-- .../dev/zorums_client_gorums.pb.go | 18 +++++------ .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_quorumcall_gorums.pb.go | 18 +++++------ .../dev/zorums_rpc_gorums.pb.go | 2 +- .../dev/zorums_server_gorums.pb.go | 2 +- .../dev/zorums_unicast_gorums.pb.go | 2 +- .../gengorums/template_client.go | 2 +- .../gengorums/template_quorumcall.go | 2 +- correctable.go | 4 +-- doc/method-options.md | 4 +-- doc/user-guide.md | 20 ++++++------- examples/storage/client.go | 4 +-- examples/storage/proto/storage_gorums.pb.go | 8 ++--- iterator.go | 8 ++--- quorumcall.go | 2 +- tests/config/config_gorums.pb.go | 6 ++-- tests/correctable/correctable_gorums.pb.go | 10 +++---- tests/correctable/correctable_test.go | 2 +- tests/dummy/dummy_gorums.pb.go | 2 +- tests/metadata/metadata_gorums.pb.go | 2 +- tests/oneway/oneway_gorums.pb.go | 2 +- tests/ordering/order_gorums.pb.go | 10 +++---- tests/ordering/order_test.go | 4 +-- tests/qf/qf_gorums.pb.go | 10 +++---- tests/qf/qf_test.go | 4 +-- tests/tls/tls_gorums.pb.go | 2 +- tests/unresponsive/unresponsive_gorums.pb.go | 2 +- 31 files changed, 98 insertions(+), 98 deletions(-) diff --git a/async.go b/async.go index af59e9fc8..6773fa67c 100644 --- a/async.go +++ b/async.go @@ -31,8 +31,8 @@ func (f *Async[resultType]) Done() bool { // IterAsync lets you use a quorum call as an async call. func IterAsync[responseType proto.Message, resultType any]( - iter Iterator[responseType], - asyncFunc func(Iterator[responseType]) resultType, + iter Responses[responseType], + asyncFunc func(Responses[responseType]) resultType, ) Async[resultType] { async := Async[resultType]{ c: make(chan struct{}), diff --git a/benchmark/benchmark.go b/benchmark/benchmark.go index 34747800c..37423c711 100644 --- a/benchmark/benchmark.go +++ b/benchmark/benchmark.go @@ -33,7 +33,7 @@ type Bench struct { type ( benchFunc func(Options) (*Result, error) - qcFunc func(context.Context, *Echo) gorums.Iterator[*Echo] + qcFunc func(context.Context, *Echo) gorums.Responses[*Echo] serverFunc func(context.Context, *TimedMsg) ) diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 6ab20323d..135ca1bcc 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: benchmark/benchmark.proto @@ -118,13 +118,13 @@ type Node struct { // BenchmarkClient is the client interface for the Benchmark service. type BenchmarkClient interface { - StartServerBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] - StopServerBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*Result] - StartBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] - StopBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*MemoryStat] - QuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] - AsyncQuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] - SlowServer(ctx context.Context, in *Echo) gorums.Iterator[*Echo] + StartServerBenchmark(ctx context.Context, in *StartRequest) gorums.Responses[*StartResponse] + StopServerBenchmark(ctx context.Context, in *StopRequest) gorums.Responses[*Result] + StartBenchmark(ctx context.Context, in *StartRequest) gorums.Responses[*StartResponse] + StopBenchmark(ctx context.Context, in *StopRequest) gorums.Responses[*MemoryStat] + QuorumCall(ctx context.Context, in *Echo) gorums.Responses[*Echo] + AsyncQuorumCall(ctx context.Context, in *Echo) gorums.Responses[*Echo] + SlowServer(ctx context.Context, in *Echo) gorums.Responses[*Echo] Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption) } @@ -149,7 +149,7 @@ func (c *Configuration) Multicast(ctx context.Context, in *TimedMsg, opts ...gor // StartServerBenchmark is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] { +func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartRequest) gorums.Responses[*StartResponse] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StartServerBenchmark", @@ -162,7 +162,7 @@ func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartReque // StopServerBenchmark is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*Result] { +func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest) gorums.Responses[*Result] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StopServerBenchmark", @@ -175,7 +175,7 @@ func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest // StartBenchmark is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) gorums.Iterator[*StartResponse] { +func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) gorums.Responses[*StartResponse] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StartBenchmark", @@ -188,7 +188,7 @@ func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) go // StopBenchmark is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) gorums.Iterator[*MemoryStat] { +func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) gorums.Responses[*MemoryStat] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StopBenchmark", @@ -199,7 +199,7 @@ func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) goru } // benchmarks -func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] { +func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) gorums.Responses[*Echo] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.QuorumCall", @@ -212,7 +212,7 @@ func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) gorums.Iterato // AsyncQuorumCall is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) gorums.Iterator[*Echo] { +func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) gorums.Responses[*Echo] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.AsyncQuorumCall", @@ -225,7 +225,7 @@ func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) gorums.It // SlowServer is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) SlowServer(ctx context.Context, in *Echo) gorums.Iterator[*Echo] { +func (c *Configuration) SlowServer(ctx context.Context, in *Echo) gorums.Responses[*Echo] { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.SlowServer", diff --git a/benchmark/qspec.go b/benchmark/qspec.go index 9e9aed0c4..2cdd1f91d 100644 --- a/benchmark/qspec.go +++ b/benchmark/qspec.go @@ -9,7 +9,7 @@ import ( // stopServerBenchmarkQF is the quorum function for the StopServerBenchmark quorumcall. // It requires a response from all nodes. -func stopServerBenchmarkQF(replies gorums.Iterator[*Result], cfgSize int) (*Result, error) { +func stopServerBenchmarkQF(replies gorums.Responses[*Result], cfgSize int) (*Result, error) { // combine results, calculating averages and pooled variance resp := &Result_builder{} replyCount := 0 @@ -44,7 +44,7 @@ func stopServerBenchmarkQF(replies gorums.Iterator[*Result], cfgSize int) (*Resu // stopBenchmarkQF is the quorum function for the StopBenchmark quorumcall. // It requires a response from all nodes. -func stopBenchmarkQF(replies gorums.Iterator[*MemoryStat], cfgSize int) ([]*MemoryStat, error) { +func stopBenchmarkQF(replies gorums.Responses[*MemoryStat], cfgSize int) ([]*MemoryStat, error) { replyList := make([]*MemoryStat, 0) replyCount := 0 for reply := range replies.IgnoreErrors() { @@ -60,7 +60,7 @@ func stopBenchmarkQF(replies gorums.Iterator[*MemoryStat], cfgSize int) ([]*Memo // qf is a generic quorum function which does not return anything. // It requires a response from a specified quorum amount of nodes. -func qf[responseType proto.Message](replies gorums.Iterator[responseType], quorum int) error { +func qf[responseType proto.Message](replies gorums.Responses[responseType], quorum int) error { replyCount := 0 for range replies.IgnoreErrors() { replyCount++ diff --git a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go index 8e8083e0a..11cd7b2f6 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: zorums.proto @@ -21,14 +21,14 @@ const ( // ZorumsServiceClient is the client interface for the ZorumsService service. type ZorumsServiceClient interface { - QuorumCall(ctx context.Context, in *Request) gorums.Iterator[*Response] - QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] - QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] - QuorumCallEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] - QuorumCallStream(ctx context.Context, in *Request) gorums.Iterator[*Response] - QuorumCallStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] - QuorumCallStreamEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] - QuorumCallStreamEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] + QuorumCall(ctx context.Context, in *Request) gorums.Responses[*Response] + QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Responses[*Response] + QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) gorums.Responses[*Response] + QuorumCallEmpty2(ctx context.Context, in *Request) gorums.Responses[*emptypb.Empty] + QuorumCallStream(ctx context.Context, in *Request) gorums.Responses[*Response] + QuorumCallStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Responses[*Response] + QuorumCallStreamEmpty(ctx context.Context, in *emptypb.Empty) gorums.Responses[*Response] + QuorumCallStreamEmpty2(ctx context.Context, in *Request) gorums.Responses[*emptypb.Empty] Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) MulticastPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) Multicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) diff --git a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go index c94774450..3aafa55f1 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go index 9a0ab7d5f..6d110d1bc 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: zorums.proto @@ -21,7 +21,7 @@ const ( ) // QuorumCall plain. -func (c *Configuration) QuorumCall(ctx context.Context, in *Request) gorums.Iterator[*Response] { +func (c *Configuration) QuorumCall(ctx context.Context, in *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCall", @@ -32,7 +32,7 @@ func (c *Configuration) QuorumCall(ctx context.Context, in *Request) gorums.Iter } // QuorumCall with per_node_arg option. -func (c *Configuration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] { +func (c *Configuration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallPerNodeArg", @@ -46,7 +46,7 @@ func (c *Configuration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f } // QuorumCallEmpty for testing imported message type. -func (c *Configuration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] { +func (c *Configuration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallEmpty", @@ -57,7 +57,7 @@ func (c *Configuration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) } // QuorumCallEmpty2 for testing imported message type. -func (c *Configuration) QuorumCallEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] { +func (c *Configuration) QuorumCallEmpty2(ctx context.Context, in *Request) gorums.Responses[*emptypb.Empty] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallEmpty2", @@ -68,7 +68,7 @@ func (c *Configuration) QuorumCallEmpty2(ctx context.Context, in *Request) gorum } // QuorumCall plain. -func (c *Configuration) QuorumCallStream(ctx context.Context, in *Request) gorums.Iterator[*Response] { +func (c *Configuration) QuorumCallStream(ctx context.Context, in *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallStream", @@ -79,7 +79,7 @@ func (c *Configuration) QuorumCallStream(ctx context.Context, in *Request) gorum } // QuorumCall with per_node_arg option. -func (c *Configuration) QuorumCallStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Iterator[*Response] { +func (c *Configuration) QuorumCallStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallStreamPerNodeArg", @@ -93,7 +93,7 @@ func (c *Configuration) QuorumCallStreamPerNodeArg(ctx context.Context, in *Requ } // QuorumCallEmpty for testing imported message type. -func (c *Configuration) QuorumCallStreamEmpty(ctx context.Context, in *emptypb.Empty) gorums.Iterator[*Response] { +func (c *Configuration) QuorumCallStreamEmpty(ctx context.Context, in *emptypb.Empty) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallStreamEmpty", @@ -104,7 +104,7 @@ func (c *Configuration) QuorumCallStreamEmpty(ctx context.Context, in *emptypb.E } // QuorumCallEmpty2 for testing imported message type. -func (c *Configuration) QuorumCallStreamEmpty2(ctx context.Context, in *Request) gorums.Iterator[*emptypb.Empty] { +func (c *Configuration) QuorumCallStreamEmpty2(ctx context.Context, in *Request) gorums.Responses[*emptypb.Empty] { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallStreamEmpty2", diff --git a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go index 54afd7c7c..4c42f4a34 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go index 8976ad7e8..ab0b0ee71 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go index 6f5d7ce73..5953f236e 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/gengorums/template_client.go b/cmd/protoc-gen-gorums/gengorums/template_client.go index 3b3361d4d..0a10e7466 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_client.go +++ b/cmd/protoc-gen-gorums/gengorums/template_client.go @@ -24,7 +24,7 @@ var clientConfigurationInterface = ` {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}, opts ...{{$callOpt}}) {{- else}} {{- $out := out $genFile .}} - {{- $iterator := use "gorums.Iterator" $genFile}} + {{- $iterator := use "gorums.Responses" $genFile}} {{$method}}(ctx {{$context}}, in *{{in $genFile .}} {{perNodeFnType $genFile . ", f"}}) {{$iterator}}[*{{$out}}] {{- end}} {{- end}} diff --git a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go index e94631a4c..e0509d82d 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go +++ b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go @@ -12,7 +12,7 @@ var commonVariables = ` // Common variables used in several template functions. var quorumCallVariables = ` -{{$iterator := use "gorums.Iterator" .GenFile}} +{{- $iterator := use "gorums.Responses" .GenFile}} ` var quorumCallComment = ` diff --git a/correctable.go b/correctable.go index 3e23aea2f..e9ea4d532 100644 --- a/correctable.go +++ b/correctable.go @@ -85,8 +85,8 @@ func (c *Correctable[resultType]) setDone() { } func IterCorrectable[responseType proto.Message, resultType any]( - iter Iterator[responseType], - corrFunction func(Iterator[responseType], func(resultType, int, error)), + iter Responses[responseType], + corrFunction func(Responses[responseType], func(resultType, int, error)), ) *Correctable[resultType] { corr := &Correctable[resultType]{donech: make(chan struct{}, 1)} go func() { diff --git a/doc/method-options.md b/doc/method-options.md index 7227c7cd1..188ef88e8 100644 --- a/doc/method-options.md +++ b/doc/method-options.md @@ -70,7 +70,7 @@ service Storage { ## Correctable calls -The iterators returned by quorum calls can be passed to the IterCorrectable function along with a callback function, in order to create a correctable object that can be used to get results at multiple levels. +The Response iterator returned by quorum calls can be passed to the IterCorrectable function along with a quorum function, in order to create a correctable object that can be used to get results at multiple levels. ```go type CustomResult struct { @@ -78,7 +78,7 @@ type CustomResult struct { msg *State } // example correctable quorum function that uses a custom result type -func ReadCorrectableQF(responses gorums.Iterator[*State], levelSet func(CustomResult, int, error)) { +func ReadCorrectableQF(responses gorums.Responses[*State], levelSet func(CustomResult, int, error)) { level := 0 for response := range responses.IgnoreErrors() { level++ diff --git a/doc/user-guide.md b/doc/user-guide.md index da149b7bb..426acac26 100644 --- a/doc/user-guide.md +++ b/doc/user-guide.md @@ -280,7 +280,7 @@ While Gorums allows us to call RPCs on individual nodes as we did above, Gorums ## Quorum Calls Instead of invoking an RPC explicitly on all nodes in a configuration, Gorums allows users to invoke a *quorum call* via a method on the `Configuration` type. -If an RPC is invoked as a quorum call, Gorums will invoke the RPCs on all nodes in parallel and return the replies in an iterator. +If an RPC is invoked as a quorum call, Gorums will invoke the RPCs on all nodes in parallel and return the responses. For the Gorums plugin to generate quorum calls we need to specify the `quorumcall` option for our RPC methods in the proto file, as shown below: @@ -300,17 +300,17 @@ service QCStorage { The generated methods have the following client-side interface: ```go -func (c *Configuration) Read(ctx context.Context, in *ReadRequest) gorums.Iterator[*State] -func (c *Configuration) Write(ctx context.Context, in *State) gorums.Iterator[*WriteResponse] +func (c *Configuration) Read(ctx context.Context, in *ReadRequest) gorums.Responses[*State] +func (c *Configuration) Write(ctx context.Context, in *State) gorums.Responses[*WriteResponse] ``` -## The quorum call iterators +## The quorum call responses -The quorum calls return an iterator which is used to process the responses from the quorum call. -Behind the scenes, the RPCs invoked as part of a quorum call return multiple responses. +The quorum calls return a gorums.Responses object which is an iterator used to process the responses from the quorum call. +Getting the responses from the iterator can be done with a for loop just like with a slice. Each of these responses is a struct containing the node id of the server, and contains either a proto message and an error (or both). -If you only care about the successfully received messages you can use the `IgnoreErrors` method on the iterator. -We can create "quorum functions" which takes a quorum call iterator and returns a single result or an error. +If you only care about the successfully received messages you can use the `IgnoreErrors` method. +We can create "quorum functions" which takes the quorum call responses and returns a single result or an error. The example below shows an implementation of a "quorum function" for the `Read` and `Write` quorum calls. Here, `readQF` returns the `*State` with the highest timestamp for a majority of responses. @@ -320,7 +320,7 @@ We decide to ignore all errors, meaning errors do not count towards the quorum. ```go package gorumsexample -func readQF(responses gorums.Iterator[*State], quorum int) (*State, error) { +func readQF(responses gorums.Responses[*State], quorum int) (*State, error) { var newest *pb.ReadResponse replyCount := int(0) for response := range responses.IgnoreErrors() { @@ -337,7 +337,7 @@ func readQF(responses gorums.Iterator[*State], quorum int) (*State, error) { return nil, errors.New("QCStorage.readqf: quorum not found") } -func writeQF(responses gorums.Iterator[*WriteResponse], quorum int) (*WriteResponse, error) { +func writeQF(responses gorums.Responses[*WriteResponse], quorum int) (*WriteResponse, error) { replyCount := int(0) for response := range responses.IgnoreErrors() { replyCount++ diff --git a/examples/storage/client.go b/examples/storage/client.go index 617fa8193..16b7e9127 100644 --- a/examples/storage/client.go +++ b/examples/storage/client.go @@ -50,7 +50,7 @@ func isUpdated(r *proto.WriteResponse) bool { return r.GetNew() } -func writeQF(replies gorums.Iterator[*pb.WriteResponse], cfgSize int) (*pb.WriteResponse, error) { +func writeQF(replies gorums.Responses[*pb.WriteResponse], cfgSize int) (*pb.WriteResponse, error) { replyCount := int(0) updated := int(0) for response := range replies.IgnoreErrors() { @@ -70,7 +70,7 @@ func writeQF(replies gorums.Iterator[*pb.WriteResponse], cfgSize int) (*pb.Write return nil, errors.New("storage.writeqc: incomplete response") } -func readQF(replies gorums.Iterator[*pb.ReadResponse], quorum int) (*pb.ReadResponse, error) { +func readQF(replies gorums.Responses[*pb.ReadResponse], quorum int) (*pb.ReadResponse, error) { var newest *pb.ReadResponse replyCount := int(0) for reply := range replies.IgnoreErrors() { diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index 214b5efd7..de53eb179 100644 --- a/examples/storage/proto/storage_gorums.pb.go +++ b/examples/storage/proto/storage_gorums.pb.go @@ -118,8 +118,8 @@ type Node struct { // StorageClient is the client interface for the Storage service. type StorageClient interface { - ReadQC(ctx context.Context, in *ReadRequest) gorums.Iterator[*ReadResponse] - WriteQC(ctx context.Context, in *WriteRequest) gorums.Iterator[*WriteResponse] + ReadQC(ctx context.Context, in *ReadRequest) gorums.Responses[*ReadResponse] + WriteQC(ctx context.Context, in *WriteRequest) gorums.Responses[*WriteResponse] WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) } @@ -152,7 +152,7 @@ func (c *Configuration) WriteMulticast(ctx context.Context, in *WriteRequest, op // ReadQC executes the Read Quorum Call on a configuration // of Nodes and returns the most recent value. -func (c *Configuration) ReadQC(ctx context.Context, in *ReadRequest) gorums.Iterator[*ReadResponse] { +func (c *Configuration) ReadQC(ctx context.Context, in *ReadRequest) gorums.Responses[*ReadResponse] { cd := gorums.QuorumCallData{ Message: in, Method: "storage.Storage.ReadQC", @@ -164,7 +164,7 @@ func (c *Configuration) ReadQC(ctx context.Context, in *ReadRequest) gorums.Iter // WriteQC executes the Write Quorum Call on a configuration // of Nodes and returns true if a majority of Nodes were updated. -func (c *Configuration) WriteQC(ctx context.Context, in *WriteRequest) gorums.Iterator[*WriteResponse] { +func (c *Configuration) WriteQC(ctx context.Context, in *WriteRequest) gorums.Responses[*WriteResponse] { cd := gorums.QuorumCallData{ Message: in, Method: "storage.Storage.WriteQC", diff --git a/iterator.go b/iterator.go index fd8d2baab..0482de120 100644 --- a/iterator.go +++ b/iterator.go @@ -32,11 +32,11 @@ func (r Response[messageType]) Unpack() (messageType, error, uint32) { return r.Msg, r.Err, r.Nid } -type Iterator[messageType proto.Message] iter.Seq[Response[messageType]] +type Responses[messageType proto.Message] iter.Seq[Response[messageType]] // Filter uses a function to keep/remove messages from a quorum call // can be used to verify/filter responses from servers before computing quorum -func (iterator Iterator[messageType]) Filter(keep func(Response[messageType]) bool) Iterator[messageType] { +func (iterator Responses[messageType]) Filter(keep func(Response[messageType]) bool) Responses[messageType] { return func(yield func(Response[messageType]) bool) { for resp := range iterator { if keep(resp) { @@ -49,7 +49,7 @@ func (iterator Iterator[messageType]) Filter(keep func(Response[messageType]) bo } // IgnoreErrors removes the errors from the iterator -func (iterator Iterator[messageType]) IgnoreErrors() Iterator[messageType] { +func (iterator Responses[messageType]) IgnoreErrors() Responses[messageType] { return func(yield func(Response[messageType]) bool) { for resp := range iterator { if resp.Err != nil { @@ -64,7 +64,7 @@ func (iterator Iterator[messageType]) IgnoreErrors() Iterator[messageType] { // GetQuorum is an example function for an iterator method // it returns a message if it occurs more than a specified amount of times -func (iterator Iterator[messageType]) GetQuorum(quorum int) (messageType, error) { +func (iterator Responses[messageType]) GetQuorum(quorum int) (messageType, error) { type replyFreq struct { val messageType freq int diff --git a/quorumcall.go b/quorumcall.go index ff9cab518..be24dc39b 100644 --- a/quorumcall.go +++ b/quorumcall.go @@ -26,7 +26,7 @@ func QuorumCall[responseType proto.Message]( ctx context.Context, c RawConfiguration, d QuorumCallData, -) Iterator[responseType] { +) Responses[responseType] { nodes := len(c) md := ordering.NewGorumsMetadata(ctx, c.getMsgID(), d.Method) diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index 39df1d53f..2b4be31d9 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: config/config.proto @@ -117,7 +117,7 @@ type Node struct { // ConfigTestClient is the client interface for the ConfigTest service. type ConfigTestClient interface { - Config(ctx context.Context, in *Request) gorums.Iterator[*Response] + Config(ctx context.Context, in *Request) gorums.Responses[*Response] } // enforce interface compliance @@ -126,7 +126,7 @@ var _ ConfigTestClient = (*Configuration)(nil) // Config is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) Config(ctx context.Context, in *Request) gorums.Iterator[*Response] { +func (c *Configuration) Config(ctx context.Context, in *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "config.ConfigTest.Config", diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index a78cb0dbd..db318d8c7 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: correctable/correctable.proto @@ -119,8 +119,8 @@ type Node struct { // CorrectableTestClient is the client interface for the CorrectableTest service. type CorrectableTestClient interface { - Correctable(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] - CorrectableStream(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] + Correctable(ctx context.Context, in *CorrectableRequest) gorums.Responses[*CorrectableResponse] + CorrectableStream(ctx context.Context, in *CorrectableRequest) gorums.Responses[*CorrectableResponse] } // enforce interface compliance @@ -129,7 +129,7 @@ var _ CorrectableTestClient = (*Configuration)(nil) // Correctable is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) Correctable(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] { +func (c *Configuration) Correctable(ctx context.Context, in *CorrectableRequest) gorums.Responses[*CorrectableResponse] { cd := gorums.QuorumCallData{ Message: in, Method: "correctable.CorrectableTest.Correctable", @@ -144,7 +144,7 @@ func (c *Configuration) Correctable(ctx context.Context, in *CorrectableRequest) // with the same argument in, and returns the responses as an iterator. // This is a streaming quorum call, so each can respond with any amount of responses. -func (c *Configuration) CorrectableStream(ctx context.Context, in *CorrectableRequest) gorums.Iterator[*CorrectableResponse] { +func (c *Configuration) CorrectableStream(ctx context.Context, in *CorrectableRequest) gorums.Responses[*CorrectableResponse] { cd := gorums.QuorumCallData{ Message: in, Method: "correctable.CorrectableTest.CorrectableStream", diff --git a/tests/correctable/correctable_test.go b/tests/correctable/correctable_test.go index 13d542876..4c7e3f4f5 100644 --- a/tests/correctable/correctable_test.go +++ b/tests/correctable/correctable_test.go @@ -59,7 +59,7 @@ type qspec struct { doneLevel int } -func (q qspec) corrQF(responses gorums.Iterator[*CorrectableResponse], levelSet func(int, int, error)) { +func (q qspec) corrQF(responses gorums.Responses[*CorrectableResponse], levelSet func(int, int, error)) { sum := 0 for response := range responses { msg, err, _ := response.Unpack() diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index 59ee93b1c..f957096a4 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: dummy/dummy.proto diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index db83d8749..01caa7090 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: metadata/metadata.proto diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index 1d58ef34a..560a62e81 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: oneway/oneway.proto diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index 76bfb0cf7..ea482af07 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: ordering/order.proto @@ -117,8 +117,8 @@ type Node struct { // GorumsTestClient is the client interface for the GorumsTest service. type GorumsTestClient interface { - QC(ctx context.Context, in *Request) gorums.Iterator[*Response] - QCAsync(ctx context.Context, in *Request) gorums.Iterator[*Response] + QC(ctx context.Context, in *Request) gorums.Responses[*Response] + QCAsync(ctx context.Context, in *Request) gorums.Responses[*Response] } // enforce interface compliance @@ -135,7 +135,7 @@ var _ GorumsTestNodeClient = (*Node)(nil) // QC is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) QC(ctx context.Context, in *Request) gorums.Iterator[*Response] { +func (c *Configuration) QC(ctx context.Context, in *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "ordering.GorumsTest.QC", @@ -148,7 +148,7 @@ func (c *Configuration) QC(ctx context.Context, in *Request) gorums.Iterator[*Re // QCAsync is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) QCAsync(ctx context.Context, in *Request) gorums.Iterator[*Response] { +func (c *Configuration) QCAsync(ctx context.Context, in *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "ordering.GorumsTest.QCAsync", diff --git a/tests/ordering/order_test.go b/tests/ordering/order_test.go index 246f248b5..d690ba0cc 100644 --- a/tests/ordering/order_test.go +++ b/tests/ordering/order_test.go @@ -46,7 +46,7 @@ func (s *testSrv) UnaryRPC(_ gorums.ServerCtx, req *Request) (resp *Response, er }.Build(), nil } -func orderQF(ctx context.Context, responses gorums.Iterator[*Response], quorum int) (*Response, error) { +func orderQF(ctx context.Context, responses gorums.Responses[*Response], quorum int) (*Response, error) { replyCount := 0 var orderMsg *Response var firstMsg *Response @@ -161,7 +161,7 @@ func TestQCAsyncOrdering(t *testing.T) { i++ responses := cfg.QCAsync(ctx, Request_builder{Num: uint64(i)}.Build()) wg.Add(1) - go func(responses gorums.Iterator[*Response]) { + go func(responses gorums.Responses[*Response]) { defer wg.Done() resp, err := orderQF(ctx, responses, 4) if err != nil { diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 5837d99cf..1551e8cf0 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: qf/qf.proto @@ -117,8 +117,8 @@ type Node struct { // QuorumFunctionClient is the client interface for the QuorumFunction service. type QuorumFunctionClient interface { - UseReq(ctx context.Context, in *Request) gorums.Iterator[*Response] - IgnoreReq(ctx context.Context, in *Request) gorums.Iterator[*Response] + UseReq(ctx context.Context, in *Request) gorums.Responses[*Response] + IgnoreReq(ctx context.Context, in *Request) gorums.Responses[*Response] } // enforce interface compliance @@ -127,7 +127,7 @@ var _ QuorumFunctionClient = (*Configuration)(nil) // UseReq is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) UseReq(ctx context.Context, in *Request) gorums.Iterator[*Response] { +func (c *Configuration) UseReq(ctx context.Context, in *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "qf.QuorumFunction.UseReq", @@ -140,7 +140,7 @@ func (c *Configuration) UseReq(ctx context.Context, in *Request) gorums.Iterator // IgnoreReq is a quorum call invoked on each node in configuration c, // with the same argument in, and returns the responses as an iterator. -func (c *Configuration) IgnoreReq(ctx context.Context, in *Request) gorums.Iterator[*Response] { +func (c *Configuration) IgnoreReq(ctx context.Context, in *Request) gorums.Responses[*Response] { cd := gorums.QuorumCallData{ Message: in, Method: "qf.QuorumFunction.IgnoreReq", diff --git a/tests/qf/qf_test.go b/tests/qf/qf_test.go index 224c4f8ce..4127a6541 100644 --- a/tests/qf/qf_test.go +++ b/tests/qf/qf_test.go @@ -93,7 +93,7 @@ func (q testQSpec) WithoutReqQF(replies map[uint32]*Response) (*Response, bool) return reply, true } -func IterUseReq(replies gorums.Iterator[*Response], quorum int, req *Request) (*Response, error) { +func IterUseReq(replies gorums.Responses[*Response], quorum int, req *Request) (*Response, error) { replyCount := 0 for reply := range replies.IgnoreErrors() { msg := reply.Msg @@ -107,7 +107,7 @@ func IterUseReq(replies gorums.Iterator[*Response], quorum int, req *Request) (* return nil, errors.New("UseReq: quorum not found") } -func IterIgnoreReq(replies gorums.Iterator[*Response], quorum int) (*Response, error) { +func IterIgnoreReq(replies gorums.Responses[*Response], quorum int) (*Response, error) { replyCount := 0 var firstMsg *Response for reply := range replies.IgnoreErrors() { diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 6148ea8df..175b22d95 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: tls/tls.proto diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index 559a9a9b8..0c3dda950 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+e5c1c4aa +// protoc-gen-gorums v0.9.0-devel+09c177d2 // protoc v6.30.2 // source: unresponsive/unresponsive.proto From 26a40d85782bce41eedac23a0129cf7c788460bc Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 17:34:59 +0200 Subject: [PATCH 23/27] rename IterCorrectable -> NewCorrectable --- correctable.go | 2 +- doc/method-options.md | 6 +++--- tests/correctable/correctable_test.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/correctable.go b/correctable.go index e9ea4d532..12efd0f1b 100644 --- a/correctable.go +++ b/correctable.go @@ -84,7 +84,7 @@ func (c *Correctable[resultType]) setDone() { } } -func IterCorrectable[responseType proto.Message, resultType any]( +func NewCorrectable[responseType proto.Message, resultType any]( iter Responses[responseType], corrFunction func(Responses[responseType], func(resultType, int, error)), ) *Correctable[resultType] { diff --git a/doc/method-options.md b/doc/method-options.md index 188ef88e8..62460cd05 100644 --- a/doc/method-options.md +++ b/doc/method-options.md @@ -70,7 +70,7 @@ service Storage { ## Correctable calls -The Response iterator returned by quorum calls can be passed to the IterCorrectable function along with a quorum function, in order to create a correctable object that can be used to get results at multiple levels. +The Response iterator returned by quorum calls can be passed to the `gorums.NewCorrectable` function along with a quorum function, in order to create a correctable object that can be used to get results at multiple levels. ```go type CustomResult struct { @@ -97,11 +97,11 @@ func ReadCorrectableQF(responses gorums.Responses[*State], levelSet func(CustomR func ReadCorrectable(ctx context.Context, cfg *Configuration, req *ReadRequest) *gorums.Correctable[CustomResult] { responses := cfg.ReadQC(ctx, req) - return gorums.IterCorrectable(responses, ReadCorrectableQF) + return gorums.NewCorrectable(responses, ReadCorrectableQF) } func ReadCorrectableStream(ctx context.Context, cfg *Configuration, req *ReadRequest) *gorums.Correctable[CustomResult] { responses := cfg.ReadStream(ctx, req) - return gorums.IterCorrectable(responses, ReadCorrectableQF) + return gorums.NewCorrectable(responses, ReadCorrectableQF) } ``` diff --git a/tests/correctable/correctable_test.go b/tests/correctable/correctable_test.go index 4c7e3f4f5..3eaa08846 100644 --- a/tests/correctable/correctable_test.go +++ b/tests/correctable/correctable_test.go @@ -80,7 +80,7 @@ func TestCorrectable(t *testing.T) { run(t, 4, 1, func(ctx context.Context, c *Configuration, n, div int) *gorums.Correctable[int] { corr := c.Correctable(ctx, &CorrectableRequest{}) qspec := qspec{div, n} - return gorums.IterCorrectable(corr, qspec.corrQF) + return gorums.NewCorrectable(corr, qspec.corrQF) }) } @@ -88,7 +88,7 @@ func TestCorrectableStream(t *testing.T) { run(t, 4, 4, func(ctx context.Context, c *Configuration, n, div int) *gorums.Correctable[int] { corr := c.CorrectableStream(ctx, &CorrectableRequest{}) qspec := qspec{div, n} - return gorums.IterCorrectable(corr, qspec.corrQF) + return gorums.NewCorrectable(corr, qspec.corrQF) }) } From 17e4b760ab9424c8afacd2980cd2150b6578c5a3 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 17:36:42 +0200 Subject: [PATCH 24/27] rename IterAsync to NewAsync --- async.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/async.go b/async.go index 6773fa67c..62dc14691 100644 --- a/async.go +++ b/async.go @@ -29,8 +29,8 @@ func (f *Async[resultType]) Done() bool { } } -// IterAsync lets you use a quorum call as an async call. -func IterAsync[responseType proto.Message, resultType any]( +// NewAsync lets you use a quorum call as an async call. +func NewAsync[responseType proto.Message, resultType any]( iter Responses[responseType], asyncFunc func(Responses[responseType]) resultType, ) Async[resultType] { From 3a7c9fe4b9eeaf2938085b55e9e892d005dc2eb6 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 17:38:52 +0200 Subject: [PATCH 25/27] add some comments --- correctable.go | 1 + tests/qf/qf_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/correctable.go b/correctable.go index 12efd0f1b..853a22c36 100644 --- a/correctable.go +++ b/correctable.go @@ -84,6 +84,7 @@ func (c *Correctable[resultType]) setDone() { } } +// NewCorrectable lets you use a quorum call as a correctable call. func NewCorrectable[responseType proto.Message, resultType any]( iter Responses[responseType], corrFunction func(Responses[responseType], func(resultType, int, error)), diff --git a/tests/qf/qf_test.go b/tests/qf/qf_test.go index 4127a6541..18e6fdc7a 100644 --- a/tests/qf/qf_test.go +++ b/tests/qf/qf_test.go @@ -207,6 +207,8 @@ func BenchmarkQF(b *testing.B) { } }) + // Iterator versions + b.Run(fmt.Sprintf("IterUseReq_%d", n), func(b *testing.B) { for b.Loop() { iterator := func(yield func(gorums.Response[*Response]) bool) { From 76a0c91cf23741bde5d8616f4d37626986e69e29 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 18:12:02 +0200 Subject: [PATCH 26/27] the dummy node list was used in test, and nil cannot be cast into a pointer --- tests/qf/qf_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qf/qf_test.go b/tests/qf/qf_test.go index 18e6fdc7a..6ffddcddf 100644 --- a/tests/qf/qf_test.go +++ b/tests/qf/qf_test.go @@ -263,7 +263,7 @@ func (testSrv) IgnoreReq(_ gorums.ServerCtx, req *Request) (resp *Response, err func BenchmarkFullStackQF(b *testing.B) { for n := 3; n < 20; n += 2 { - _, stop := gorums.TestSetup(b, n, func(_ int) gorums.ServerIface { + addrs, stop := gorums.TestSetup(b, n, func(_ int) gorums.ServerIface { srv := gorums.NewServer() RegisterQuorumFunctionServer(srv, &testSrv{}) return srv @@ -274,7 +274,7 @@ func BenchmarkFullStackQF(b *testing.B) { ), ) c, err := mgr.NewConfiguration( - gorums.WithNodeList([]string{"127.0.0.1:9080", "127.0.0.1:9081", "127.0.0.1:9082"}), // dummy node list; won't actually be used in test + gorums.WithNodeList(addrs), ) if err != nil { b.Fatal(err) From f25c47d5e1ab3551d18c25a32919bc42d6bafc21 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sat, 10 May 2025 18:31:34 +0200 Subject: [PATCH 27/27] check if the response is nil before casting it to message pointer --- quorumcall.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/quorumcall.go b/quorumcall.go index be24dc39b..d1482bad2 100644 --- a/quorumcall.go +++ b/quorumcall.go @@ -75,7 +75,11 @@ func QuorumCall[responseType proto.Message]( if r.err != nil { errors++ } - if !yield(NewResponse(r.msg.(responseType), r.err, r.nid)) { + var msg responseType + if r.msg != nil { + msg = r.msg.(responseType) + } + if !yield(NewResponse(msg, r.err, r.nid)) { return } case <-ctx.Done():