From d09d76fb12591fc30cd7157dc5cfff0be479aa80 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Mon, 24 Mar 2025 15:58:41 +0100 Subject: [PATCH 01/11] modify protoc-gen-gorums to support multiple services --- Makefile | 2 +- benchmark/benchmark.pb.go | 12 +- benchmark/benchmark_gorums.pb.go | 103 ++++++++++++++++-- cmd/protoc-gen-gorums/dev/config.go | 58 ---------- cmd/protoc-gen-gorums/dev/mgr.go | 79 -------------- cmd/protoc-gen-gorums/dev/node.go | 9 -- cmd/protoc-gen-gorums/dev/zorums.pb.go | 12 +- .../dev/zorums_async_gorums.pb.go | 16 +-- .../dev/zorums_client_gorums.pb.go | 6 +- .../dev/zorums_configuration_gorums.pb.go | 67 ++++++++++++ .../dev/zorums_correctable_gorums.pb.go | 26 ++--- .../dev/zorums_manager_gorums.pb.go | 44 ++++++++ .../dev/zorums_multicast_gorums.pb.go | 12 +- .../dev/zorums_node_gorums.pb.go | 23 ++++ .../dev/zorums_qspec_gorums.pb.go | 6 +- .../dev/zorums_quorumcall_gorums.pb.go | 14 +-- .../dev/zorums_rpc_gorums.pb.go | 4 +- .../dev/zorums_server_gorums.pb.go | 2 +- .../dev/zorums_types_gorums.pb.go | 2 +- .../dev/zorums_unicast_gorums.pb.go | 12 +- cmd/protoc-gen-gorums/gengorums/gorums.go | 11 +- .../gengorums/template_async.go | 2 +- .../gengorums/template_client.go | 6 +- .../gengorums/template_configuration.go | 99 +++++++++++++++++ .../gengorums/template_correctable.go | 2 +- .../gengorums/template_manager.go | 96 ++++++++++++++++ .../gengorums/template_multicast.go | 2 +- .../gengorums/template_node.go | 21 ++++ .../gengorums/template_qspec.go | 10 +- .../gengorums/template_quorumcall.go | 5 +- .../gengorums/template_rpc.go | 10 +- .../gengorums/template_unicast.go | 18 ++- gorums.pb.go | 12 +- internal/correctable/opts.pb.go | 12 +- ordering/ordering.pb.go | 12 +- ordering/ordering_grpc.pb.go | 2 +- tests/config/config.pb.go | 16 +-- tests/config/config_gorums.pb.go | 7 +- tests/correctable/correctable.pb.go | 16 +-- tests/correctable/correctable_gorums.pb.go | 7 +- tests/dummy/dummy.pb.go | 16 +-- tests/dummy/dummy_gorums.pb.go | 11 +- tests/metadata/metadata.pb.go | 16 +-- tests/metadata/metadata_gorums.pb.go | 13 ++- tests/oneway/oneway.pb.go | 16 +-- tests/oneway/oneway_gorums.pb.go | 11 +- tests/ordering/order.pb.go | 16 +-- tests/ordering/order_gorums.pb.go | 11 +- tests/qf/qf.pb.go | 16 +-- tests/qf/qf_gorums.pb.go | 7 +- tests/tls/tls.pb.go | 16 +-- tests/tls/tls_gorums.pb.go | 11 +- tests/unresponsive/unresponsive.pb.go | 16 +-- tests/unresponsive/unresponsive_gorums.pb.go | 11 +- 54 files changed, 703 insertions(+), 359 deletions(-) delete mode 100644 cmd/protoc-gen-gorums/dev/config.go delete mode 100644 cmd/protoc-gen-gorums/dev/mgr.go delete mode 100644 cmd/protoc-gen-gorums/dev/node.go create mode 100644 cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go create mode 100644 cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go create mode 100644 cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go create mode 100644 cmd/protoc-gen-gorums/gengorums/template_configuration.go create mode 100644 cmd/protoc-gen-gorums/gengorums/template_manager.go create mode 100644 cmd/protoc-gen-gorums/gengorums/template_node.go diff --git a/Makefile b/Makefile index fd6b24fa..98d8c8b8 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ benchmark: installgorums $(benchmark_deps) $(static_file): $(static_files) @cp $(static_file) $(static_file).bak - @protoc-gen-gorums --bundle=$(static_file) +# @protoc-gen-gorums --bundle=$(static_file) %.pb.go : %.proto @protoc -I=$(proto_path) \ diff --git a/benchmark/benchmark.pb.go b/benchmark/benchmark.pb.go index 75d12284..dd1e7f9a 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: benchmark/benchmark.proto package benchmark @@ -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 ( @@ -588,7 +587,7 @@ func (b0 MemoryStatList_builder) Build() *MemoryStatList { var File_benchmark_benchmark_proto protoreflect.FileDescriptor -var file_benchmark_benchmark_proto_rawDesc = string([]byte{ +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, @@ -670,7 +669,7 @@ var file_benchmark_benchmark_proto_rawDesc = string([]byte{ 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, 8) var file_benchmark_benchmark_proto_goTypes = []any{ @@ -719,7 +718,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: 8, NumExtensions: 0, @@ -730,6 +729,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 8ea88ed8..d519c86e 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: benchmark/benchmark.proto package benchmark @@ -153,7 +153,7 @@ type Node struct { // 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 { +func (c *BenchmarkConfiguration) AsyncQuorumCall(ctx context.Context, in *Echo) *AsyncEcho { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.AsyncQuorumCall", @@ -183,14 +183,88 @@ type BenchmarkClient interface { } // enforce interface compliance -var _ BenchmarkClient = (*Configuration)(nil) +var _ BenchmarkClient = (*BenchmarkConfiguration)(nil) + +// A BenchmarkConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type BenchmarkConfiguration struct { + gorums.RawConfiguration + qspec BenchmarkQuorumSpec + nodes []*BenchmarkNode +} // BenchmarkQuorumSpecFromRaw returns a new BenchmarkQuorumSpec from the given raw configuration and QuorumSpec. +// +// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// +// cfg1, err := mgr.NewConfiguration(qspec1, opts...) +// cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) +func BenchmarkConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec BenchmarkQuorumSpec) (*BenchmarkConfiguration, error) { + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required QuorumSpec") + } + newCfg := &BenchmarkConfiguration{ + RawConfiguration: rawCfg, + qspec: qspec, + } + // initialize the nodes slice + newCfg.nodes = make([]*BenchmarkNode, newCfg.Size()) + for i, n := range rawCfg { + newCfg.nodes[i] = &BenchmarkNode{n} + } + return newCfg, nil +} + +// Nodes returns a slice of each available node. IDs are returned in the same +// order as they were provided in the creation of the Manager. +// +// NOTE: mutating the returned slice is not supported. +func (c *BenchmarkConfiguration) Nodes() []*BenchmarkNode { + return c.nodes +} + +// And returns a NodeListOption that can be used to create a new configuration combining c and d. +func (c BenchmarkConfiguration) And(d *BenchmarkConfiguration) 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 BenchmarkConfiguration) Except(rm *BenchmarkConfiguration) gorums.NodeListOption { + return c.RawConfiguration.Except(rm.RawConfiguration) +} + +// BenchmarkManager maintains a connection pool of nodes on +// which quorum calls can be performed. +type BenchmarkManager struct { + *gorums.RawManager +} + +// NewBenchmarkManager returns a new BenchmarkManager for managing connection to nodes added +// to the manager. This function accepts manager options used to configure +// various aspects of the manager. +func NewBenchmarkManager(opts ...gorums.ManagerOption) *BenchmarkManager { + return &BenchmarkManager{ + RawManager: gorums.NewRawManager(opts...), + } +} + +// Nodes returns a slice of available nodes on this manager. +// IDs are returned in the order they were added at creation of the manager. +func (m *BenchmarkManager) Nodes() []*BenchmarkNode { + gorumsNodes := m.RawManager.Nodes() + nodes := make([]*BenchmarkNode, len(gorumsNodes)) + for i, n := range gorumsNodes { + nodes[i] = &BenchmarkNode{n} + } + return nodes +} // 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. -func (c *Configuration) Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption) { +func (c *BenchmarkConfiguration) Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.Multicast", @@ -199,8 +273,13 @@ 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 { +// BenchmarkNode holds the node specific methods for the Benchmark service. +type BenchmarkNode struct { + *gorums.RawNode +} + +// BenchmarkQuorumSpec is the interface of quorum functions for Benchmark. +type BenchmarkQuorumSpec interface { gorums.ConfigOption // StartServerBenchmarkQF is the quorum function for the StartServerBenchmark @@ -255,7 +334,7 @@ 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 *BenchmarkConfiguration) StartServerBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StartServerBenchmark", @@ -277,7 +356,7 @@ func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartReque // 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 *BenchmarkConfiguration) StopServerBenchmark(ctx context.Context, in *StopRequest) (resp *Result, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StopServerBenchmark", @@ -299,7 +378,7 @@ func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest // 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 *BenchmarkConfiguration) StartBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StartBenchmark", @@ -321,7 +400,7 @@ func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) (r // 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 *BenchmarkConfiguration) StopBenchmark(ctx context.Context, in *StopRequest) (resp *MemoryStatList, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.StopBenchmark", @@ -342,7 +421,7 @@ func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) (res } // benchmarks -func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) (resp *Echo, err error) { +func (c *BenchmarkConfiguration) QuorumCall(ctx context.Context, in *Echo) (resp *Echo, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.QuorumCall", @@ -364,7 +443,7 @@ func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) (resp *Echo, e // 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 *BenchmarkConfiguration) SlowServer(ctx context.Context, in *Echo) (resp *Echo, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "benchmark.Benchmark.SlowServer", diff --git a/cmd/protoc-gen-gorums/dev/config.go b/cmd/protoc-gen-gorums/dev/config.go deleted file mode 100644 index 99e8e86e..00000000 --- a/cmd/protoc-gen-gorums/dev/config.go +++ /dev/null @@ -1,58 +0,0 @@ -package dev - -import ( - "fmt" - - "github.com/relab/gorums" -) - -// 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 -} - -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. -// -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: -// -// 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") - } - newCfg := &Configuration{ - RawConfiguration: rawCfg, - qspec: qspec, - } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } - return newCfg, nil -} - -// Nodes returns a slice of each available node. IDs are returned in the same -// order as they were provided in the creation of the Manager. -// -// NOTE: mutating the returned slice is not supported. -func (c *Configuration) Nodes() []*Node { - return c.nodes -} - -// 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 { - 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 { - return c.RawConfiguration.Except(rm.RawConfiguration) -} diff --git a/cmd/protoc-gen-gorums/dev/mgr.go b/cmd/protoc-gen-gorums/dev/mgr.go deleted file mode 100644 index 3180a912..00000000 --- a/cmd/protoc-gen-gorums/dev/mgr.go +++ /dev/null @@ -1,79 +0,0 @@ -package dev - -import ( - "fmt" - - "github.com/relab/gorums" - "google.golang.org/grpc/encoding" -) - -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on -// which quorum calls can be performed. -type Manager struct { - *gorums.RawManager -} - -// NewManager returns a new Manager for managing connection to nodes added -// to the manager. This function accepts manager options used to configure -// various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ - RawManager: gorums.NewRawManager(opts...), - } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. -// 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)) - } - 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") - } - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } - return c, nil -} - -// Nodes returns a slice of available nodes on this manager. -// IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { - gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) - for i, n := range gorumsNodes { - nodes[i] = &Node{n} - } - return nodes -} diff --git a/cmd/protoc-gen-gorums/dev/node.go b/cmd/protoc-gen-gorums/dev/node.go deleted file mode 100644 index e5acc464..00000000 --- a/cmd/protoc-gen-gorums/dev/node.go +++ /dev/null @@ -1,9 +0,0 @@ -package dev - -import "github.com/relab/gorums" - -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} diff --git a/cmd/protoc-gen-gorums/dev/zorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums.pb.go index 79c0d66d..5b9f16f7 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -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,7 +194,7 @@ func (b0 MyResponse_builder) Build() *MyResponse { var File_zorums_proto protoreflect.FileDescriptor -var file_zorums_proto_rawDesc = string([]byte{ +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, @@ -346,7 +345,7 @@ var file_zorums_proto_rawDesc = string([]byte{ 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{ @@ -438,7 +437,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, @@ -449,6 +448,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_async_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go index ddc14106..6de7bc6d 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -21,7 +21,7 @@ const ( ) // QuorumCallAsync plain. -func (c *Configuration) QuorumCallAsync(ctx context.Context, in *Request) *AsyncResponse { +func (c *ZorumsServiceConfiguration) QuorumCallAsync(ctx context.Context, in *Request) *AsyncResponse { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallAsync", @@ -39,7 +39,7 @@ func (c *Configuration) QuorumCallAsync(ctx context.Context, in *Request) *Async } // QuorumCallAsyncPerNodeArg with per_node_arg option. -func (c *Configuration) QuorumCallAsyncPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *AsyncResponse { +func (c *ZorumsServiceConfiguration) QuorumCallAsyncPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *AsyncResponse { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallAsyncPerNodeArg", @@ -60,7 +60,7 @@ func (c *Configuration) QuorumCallAsyncPerNodeArg(ctx context.Context, in *Reque } // QuorumCallAsyncCustomReturnType with custom_return_type option. -func (c *Configuration) QuorumCallAsyncCustomReturnType(ctx context.Context, in *Request) *AsyncMyResponse { +func (c *ZorumsServiceConfiguration) QuorumCallAsyncCustomReturnType(ctx context.Context, in *Request) *AsyncMyResponse { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallAsyncCustomReturnType", @@ -78,7 +78,7 @@ func (c *Configuration) QuorumCallAsyncCustomReturnType(ctx context.Context, in } // QuorumCallAsyncCombo with all supported options. -func (c *Configuration) QuorumCallAsyncCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *AsyncMyResponse { +func (c *ZorumsServiceConfiguration) QuorumCallAsyncCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *AsyncMyResponse { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallAsyncCombo", @@ -99,7 +99,7 @@ func (c *Configuration) QuorumCallAsyncCombo(ctx context.Context, in *Request, f } // QuorumCallAsync2 plain; with same return type: Response. -func (c *Configuration) QuorumCallAsync2(ctx context.Context, in *Request) *AsyncResponse { +func (c *ZorumsServiceConfiguration) QuorumCallAsync2(ctx context.Context, in *Request) *AsyncResponse { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallAsync2", @@ -117,7 +117,7 @@ func (c *Configuration) QuorumCallAsync2(ctx context.Context, in *Request) *Asyn } // QuorumCallAsyncEmpty for testing imported message type. -func (c *Configuration) QuorumCallAsyncEmpty(ctx context.Context, in *Request) *AsyncEmpty { +func (c *ZorumsServiceConfiguration) QuorumCallAsyncEmpty(ctx context.Context, in *Request) *AsyncEmpty { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallAsyncEmpty", @@ -136,7 +136,7 @@ func (c *Configuration) QuorumCallAsyncEmpty(ctx context.Context, in *Request) * // QuorumCallAsyncEmpty2 for testing imported message type; with same return // type as QuorumCallAsync: Response. -func (c *Configuration) QuorumCallAsyncEmpty2(ctx context.Context, in *emptypb.Empty) *AsyncResponse { +func (c *ZorumsServiceConfiguration) QuorumCallAsyncEmpty2(ctx context.Context, in *emptypb.Empty) *AsyncResponse { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallAsyncEmpty2", 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 9c0e7d60..d5e20f9b 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -54,7 +54,7 @@ type ZorumsServiceClient interface { } // enforce interface compliance -var _ ZorumsServiceClient = (*Configuration)(nil) +var _ ZorumsServiceClient = (*ZorumsServiceConfiguration)(nil) // ZorumsServiceNodeClient is the single node client interface for the ZorumsService service. type ZorumsServiceNodeClient interface { @@ -64,4 +64,4 @@ type ZorumsServiceNodeClient interface { } // enforce interface compliance -var _ ZorumsServiceNodeClient = (*Node)(nil) +var _ ZorumsServiceNodeClient = (*ZorumsServiceNode)(nil) diff --git a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go new file mode 100644 index 00000000..8641e4a0 --- /dev/null +++ b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go @@ -0,0 +1,67 @@ +// Code generated by protoc-gen-gorums. DO NOT EDIT. +// versions: +// protoc-gen-gorums v0.8.0-devel +// protoc v5.29.2 +// source: zorums.proto + +package dev + +import ( + fmt "fmt" + gorums "github.com/relab/gorums" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = gorums.EnforceVersion(8 - gorums.MinVersion) + // Verify that the gorums runtime is sufficiently up-to-date. + _ = gorums.EnforceVersion(gorums.MaxVersion - 8) +) + +// A ZorumsServiceConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type ZorumsServiceConfiguration struct { + gorums.RawConfiguration + qspec ZorumsServiceQuorumSpec + nodes []*ZorumsServiceNode +} // ZorumsServiceQuorumSpecFromRaw returns a new ZorumsServiceQuorumSpec from the given raw configuration and QuorumSpec. +// +// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// +// cfg1, err := mgr.NewConfiguration(qspec1, opts...) +// cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) +func ZorumsServiceConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec ZorumsServiceQuorumSpec) (*ZorumsServiceConfiguration, error) { + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required QuorumSpec") + } + newCfg := &ZorumsServiceConfiguration{ + RawConfiguration: rawCfg, + qspec: qspec, + } + // initialize the nodes slice + newCfg.nodes = make([]*ZorumsServiceNode, newCfg.Size()) + for i, n := range rawCfg { + newCfg.nodes[i] = &ZorumsServiceNode{n} + } + return newCfg, nil +} + +// Nodes returns a slice of each available node. IDs are returned in the same +// order as they were provided in the creation of the Manager. +// +// NOTE: mutating the returned slice is not supported. +func (c *ZorumsServiceConfiguration) Nodes() []*ZorumsServiceNode { + return c.nodes +} + +// And returns a NodeListOption that can be used to create a new configuration combining c and d. +func (c ZorumsServiceConfiguration) And(d *ZorumsServiceConfiguration) 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 ZorumsServiceConfiguration) Except(rm *ZorumsServiceConfiguration) gorums.NodeListOption { + return c.RawConfiguration.Except(rm.RawConfiguration) +} 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 c29d8603..4313335b 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -21,7 +21,7 @@ const ( ) // Correctable plain. -func (c *Configuration) Correctable(ctx context.Context, in *Request) *CorrectableResponse { +func (c *ZorumsServiceConfiguration) Correctable(ctx context.Context, in *Request) *CorrectableResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.Correctable", @@ -40,7 +40,7 @@ func (c *Configuration) Correctable(ctx context.Context, in *Request) *Correctab } // CorrectablePerNodeArg with per_node_arg option. -func (c *Configuration) CorrectablePerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableResponse { +func (c *ZorumsServiceConfiguration) CorrectablePerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectablePerNodeArg", @@ -62,7 +62,7 @@ func (c *Configuration) CorrectablePerNodeArg(ctx context.Context, in *Request, } // CorrectableCustomReturnType with custom_return_type option. -func (c *Configuration) CorrectableCustomReturnType(ctx context.Context, in *Request) *CorrectableMyResponse { +func (c *ZorumsServiceConfiguration) CorrectableCustomReturnType(ctx context.Context, in *Request) *CorrectableMyResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableCustomReturnType", @@ -81,7 +81,7 @@ func (c *Configuration) CorrectableCustomReturnType(ctx context.Context, in *Req } // CorrectableCombo with all supported options. -func (c *Configuration) CorrectableCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableMyResponse { +func (c *ZorumsServiceConfiguration) CorrectableCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableMyResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableCombo", @@ -103,7 +103,7 @@ func (c *Configuration) CorrectableCombo(ctx context.Context, in *Request, f fun } // CorrectableEmpty for testing imported message type. -func (c *Configuration) CorrectableEmpty(ctx context.Context, in *Request) *CorrectableEmpty { +func (c *ZorumsServiceConfiguration) CorrectableEmpty(ctx context.Context, in *Request) *CorrectableEmpty { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableEmpty", @@ -123,7 +123,7 @@ func (c *Configuration) CorrectableEmpty(ctx context.Context, in *Request) *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 { +func (c *ZorumsServiceConfiguration) CorrectableEmpty2(ctx context.Context, in *emptypb.Empty) *CorrectableResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableEmpty2", @@ -142,7 +142,7 @@ func (c *Configuration) CorrectableEmpty2(ctx context.Context, in *emptypb.Empty } // CorrectableStream plain. -func (c *Configuration) CorrectableStream(ctx context.Context, in *Request) *CorrectableStreamResponse { +func (c *ZorumsServiceConfiguration) CorrectableStream(ctx context.Context, in *Request) *CorrectableStreamResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableStream", @@ -161,7 +161,7 @@ func (c *Configuration) CorrectableStream(ctx context.Context, in *Request) *Cor } // CorrectablePerNodeArg with per_node_arg option. -func (c *Configuration) CorrectableStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableStreamResponse { +func (c *ZorumsServiceConfiguration) CorrectableStreamPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableStreamResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableStreamPerNodeArg", @@ -183,7 +183,7 @@ func (c *Configuration) CorrectableStreamPerNodeArg(ctx context.Context, in *Req } // CorrectableCustomReturnType with custom_return_type option. -func (c *Configuration) CorrectableStreamCustomReturnType(ctx context.Context, in *Request) *CorrectableStreamMyResponse { +func (c *ZorumsServiceConfiguration) CorrectableStreamCustomReturnType(ctx context.Context, in *Request) *CorrectableStreamMyResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableStreamCustomReturnType", @@ -202,7 +202,7 @@ func (c *Configuration) CorrectableStreamCustomReturnType(ctx context.Context, i } // CorrectableCombo with all supported options. -func (c *Configuration) CorrectableStreamCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableStreamMyResponse { +func (c *ZorumsServiceConfiguration) CorrectableStreamCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) *CorrectableStreamMyResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableStreamCombo", @@ -224,7 +224,7 @@ func (c *Configuration) CorrectableStreamCombo(ctx context.Context, in *Request, } // CorrectableEmpty for testing imported message type. -func (c *Configuration) CorrectableStreamEmpty(ctx context.Context, in *Request) *CorrectableStreamEmpty { +func (c *ZorumsServiceConfiguration) CorrectableStreamEmpty(ctx context.Context, in *Request) *CorrectableStreamEmpty { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableStreamEmpty", @@ -244,7 +244,7 @@ func (c *Configuration) CorrectableStreamEmpty(ctx context.Context, in *Request) // CorrectableEmpty2 for testing imported message type; with same return // type as Correctable: Response. -func (c *Configuration) CorrectableStreamEmpty2(ctx context.Context, in *emptypb.Empty) *CorrectableStreamResponse { +func (c *ZorumsServiceConfiguration) CorrectableStreamEmpty2(ctx context.Context, in *emptypb.Empty) *CorrectableStreamResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "dev.ZorumsService.CorrectableStreamEmpty2", diff --git a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go new file mode 100644 index 00000000..6548a8b7 --- /dev/null +++ b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go @@ -0,0 +1,44 @@ +// Code generated by protoc-gen-gorums. DO NOT EDIT. +// versions: +// protoc-gen-gorums v0.8.0-devel +// protoc v5.29.2 +// source: zorums.proto + +package dev + +import ( + gorums "github.com/relab/gorums" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = gorums.EnforceVersion(8 - gorums.MinVersion) + // Verify that the gorums runtime is sufficiently up-to-date. + _ = gorums.EnforceVersion(gorums.MaxVersion - 8) +) + +// ZorumsServiceManager maintains a connection pool of nodes on +// which quorum calls can be performed. +type ZorumsServiceManager struct { + *gorums.RawManager +} + +// NewZorumsServiceManager returns a new ZorumsServiceManager for managing connection to nodes added +// to the manager. This function accepts manager options used to configure +// various aspects of the manager. +func NewZorumsServiceManager(opts ...gorums.ManagerOption) *ZorumsServiceManager { + return &ZorumsServiceManager{ + RawManager: gorums.NewRawManager(opts...), + } +} + +// Nodes returns a slice of available nodes on this manager. +// IDs are returned in the order they were added at creation of the manager. +func (m *ZorumsServiceManager) Nodes() []*ZorumsServiceNode { + gorumsNodes := m.RawManager.Nodes() + nodes := make([]*ZorumsServiceNode, len(gorumsNodes)) + for i, n := range gorumsNodes { + nodes[i] = &ZorumsServiceNode{n} + } + return nodes +} 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 4c078193..d0a85eaa 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -21,7 +21,7 @@ const ( ) // Multicast plain. Response type is not needed here. -func (c *Configuration) Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { +func (c *ZorumsServiceConfiguration) Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.Multicast", @@ -31,7 +31,7 @@ func (c *Configuration) Multicast(ctx context.Context, in *Request, opts ...goru } // MulticastPerNodeArg with per_node_arg option. -func (c *Configuration) MulticastPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) { +func (c *ZorumsServiceConfiguration) MulticastPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.MulticastPerNodeArg", @@ -45,7 +45,7 @@ func (c *Configuration) MulticastPerNodeArg(ctx context.Context, in *Request, f } // Multicast2 is testing whether multiple streams work. -func (c *Configuration) Multicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) { +func (c *ZorumsServiceConfiguration) Multicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.Multicast2", @@ -58,7 +58,7 @@ func (c *Configuration) Multicast2(ctx context.Context, in *Request, opts ...gor var _ emptypb.Empty // Multicast3 is testing imported message type. -func (c *Configuration) Multicast3(ctx context.Context, in *Request, opts ...gorums.CallOption) { +func (c *ZorumsServiceConfiguration) Multicast3(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.Multicast3", @@ -71,7 +71,7 @@ func (c *Configuration) Multicast3(ctx context.Context, in *Request, opts ...gor var _ emptypb.Empty // Multicast4 is testing imported message type. -func (c *Configuration) Multicast4(ctx context.Context, in *emptypb.Empty, opts ...gorums.CallOption) { +func (c *ZorumsServiceConfiguration) Multicast4(ctx context.Context, in *emptypb.Empty, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.Multicast4", diff --git a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go new file mode 100644 index 00000000..98eafb5d --- /dev/null +++ b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go @@ -0,0 +1,23 @@ +// Code generated by protoc-gen-gorums. DO NOT EDIT. +// versions: +// protoc-gen-gorums v0.8.0-devel +// protoc v5.29.2 +// source: zorums.proto + +package dev + +import ( + gorums "github.com/relab/gorums" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = gorums.EnforceVersion(8 - gorums.MinVersion) + // Verify that the gorums runtime is sufficiently up-to-date. + _ = gorums.EnforceVersion(gorums.MaxVersion - 8) +) + +// ZorumsServiceNode holds the node specific methods for the ZorumsService service. +type ZorumsServiceNode struct { + *gorums.RawNode +} 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 2d11a372..1d1e2141 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -18,8 +18,8 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// QuorumSpec is the interface of quorum functions for ZorumsService. -type QuorumSpec interface { +// ZorumsServiceQuorumSpec is the interface of quorum functions for ZorumsService. +type ZorumsServiceQuorumSpec interface { gorums.ConfigOption // QuorumCallQF is the quorum function for the QuorumCall 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 8d87bde6..0cd8c78f 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -21,7 +21,7 @@ const ( ) // QuorumCall plain. -func (c *Configuration) QuorumCall(ctx context.Context, in *Request) (resp *Response, err error) { +func (c *ZorumsServiceConfiguration) QuorumCall(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCall", @@ -42,7 +42,7 @@ func (c *Configuration) QuorumCall(ctx context.Context, in *Request) (resp *Resp } // 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 *ZorumsServiceConfiguration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request) (resp *Response, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallPerNodeArg", @@ -66,7 +66,7 @@ func (c *Configuration) QuorumCallPerNodeArg(ctx context.Context, in *Request, f } // QuorumCall with custom_return_type option. -func (c *Configuration) QuorumCallCustomReturnType(ctx context.Context, in *Request) (resp *MyResponse, err error) { +func (c *ZorumsServiceConfiguration) QuorumCallCustomReturnType(ctx context.Context, in *Request) (resp *MyResponse, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallCustomReturnType", @@ -87,7 +87,7 @@ func (c *Configuration) QuorumCallCustomReturnType(ctx context.Context, in *Requ } // 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 *ZorumsServiceConfiguration) QuorumCallCombo(ctx context.Context, in *Request, f func(*Request, uint32) *Request) (resp *MyResponse, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallCombo", @@ -111,7 +111,7 @@ func (c *Configuration) QuorumCallCombo(ctx context.Context, in *Request, f func } // QuorumCallEmpty for testing imported message type. -func (c *Configuration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) (resp *Response, err error) { +func (c *ZorumsServiceConfiguration) QuorumCallEmpty(ctx context.Context, in *emptypb.Empty) (resp *Response, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallEmpty", @@ -132,7 +132,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) (resp *emptypb.Empty, err error) { +func (c *ZorumsServiceConfiguration) QuorumCallEmpty2(ctx context.Context, in *Request) (resp *emptypb.Empty, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "dev.ZorumsService.QuorumCallEmpty2", 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 acde97e9..4353d2e8 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -20,7 +20,7 @@ const ( // GRPCCall plain gRPC call; testing that Gorums can ignore these, but that // they are added to the _grpc.pb.go generated file. -func (n *Node) GRPCCall(ctx context.Context, in *Request) (resp *Response, err error) { +func (n *ZorumsServiceNode) GRPCCall(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.CallData{ Message: in, Method: "dev.ZorumsService.GRPCCall", 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 3c8c123d..483f4174 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.8.0-devel -// protoc v5.29.3 +// 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 c9906e3c..4f6707da 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.8.0-devel -// protoc v5.29.3 +// 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 e1a084f5..0d8ad68c 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.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: zorums.proto package dev @@ -19,9 +19,8 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// Unicast is a quorum call invoked on all nodes in configuration c, -// with the same argument in, and returns a combined result. -func (n *Node) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { +// Unicast is a one-way call; no replies are processed. +func (n *ZorumsServiceNode) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, Method: "dev.ZorumsService.Unicast", @@ -33,9 +32,8 @@ 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. -func (n *Node) Unicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) { +// Unicast2 is a one-way call; no replies are processed. +func (n *ZorumsServiceNode) Unicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, Method: "dev.ZorumsService.Unicast2", diff --git a/cmd/protoc-gen-gorums/gengorums/gorums.go b/cmd/protoc-gen-gorums/gengorums/gorums.go index 2c80786e..02217523 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -239,10 +239,13 @@ 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}, + "node": {template: node}, + "configuration": {template: configuration}, + "manager": {template: manager}, + "qspec": {template: qspecInterface}, + "types": {template: dataTypes}, + "server": {template: server}, + "client": {template: client}, callTypeName(gorums.E_Rpc): { extInfo: gorums.E_Rpc, diff --git a/cmd/protoc-gen-gorums/gengorums/template_async.go b/cmd/protoc-gen-gorums/gengorums/template_async.go index fa6e842d..d0ef7a9b 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_async.go +++ b/cmd/protoc-gen-gorums/gengorums/template_async.go @@ -21,7 +21,7 @@ var asyncCallComment = ` {{end -}} ` -var asyncSignature = `func (c *Configuration) {{$method}}(` + +var asyncSignature = `func (c *{{$configurationName}}) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}}) ` + `*{{$asyncOut}} {` diff --git a/cmd/protoc-gen-gorums/gengorums/template_client.go b/cmd/protoc-gen-gorums/gengorums/template_client.go index db1e6582..92d78d33 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_client.go +++ b/cmd/protoc-gen-gorums/gengorums/template_client.go @@ -16,6 +16,7 @@ var clientConfigurationInterface = ` {{- range configurationsServices .Services}} {{- $service := .GoName}} {{- $interfaceName := printf "%sClient" $service}} + {{- $configurationName := printf "%sConfiguration" $service}} // {{$interfaceName}} is the client interface for the {{$service}} service. type {{$interfaceName}} interface { {{- range configurationMethods .Methods}} @@ -32,7 +33,7 @@ var clientConfigurationInterface = ` {{- end}} } // enforce interface compliance - var _ {{$interfaceName}} = (*Configuration)(nil) + var _ {{$interfaceName}} = (*{{$configurationName}})(nil) {{- end}} ` @@ -40,6 +41,7 @@ var clientNodeInterface = ` {{- $genFile := .GenFile}} {{- range nodeServices .Services}} {{- $service := .GoName}} + {{- $nodeName := printf "%sNode" $service}} {{- $interfaceName := printf "%sNodeClient" $service}} // {{$interfaceName}} is the single node client interface for the {{$service}} service. type {{$interfaceName}} interface { @@ -54,7 +56,7 @@ var clientNodeInterface = ` {{- end}} } // enforce interface compliance - var _ {{$interfaceName}} = (*Node)(nil) + var _ {{$interfaceName}} = (*{{$nodeName}})(nil) {{- end}} ` diff --git a/cmd/protoc-gen-gorums/gengorums/template_configuration.go b/cmd/protoc-gen-gorums/gengorums/template_configuration.go new file mode 100644 index 00000000..545cbd21 --- /dev/null +++ b/cmd/protoc-gen-gorums/gengorums/template_configuration.go @@ -0,0 +1,99 @@ +package gengorums + +var configurationVars = ` +{{$rawConfiguration := use "gorums.RawConfiguration" .GenFile}} +{{$nodeListOptions := use "gorums.NodeListOption" .GenFile}} +{{$errorf := use "fmt.Errorf" .GenFile}} +` + +var configurationStruct = ` +{{- $genFile := .GenFile}} +{{- range .Services}} + {{- $service := .GoName}} + {{- $managerName := printf "%sManager" $service}} + {{- $configurationName := printf "%sConfiguration" $service}} + {{- $qspecName := printf "%sQuorumSpec" $service}} + {{- $nodeName := printf "%sNode" $service}} + {{- $isQspec := ne (len (qspecMethods .Methods)) 0 -}} + // A {{$configurationName}} represents a static set of nodes on which quorum remote + // procedure calls may be invoked. + type {{$configurationName}} struct { + {{$rawConfiguration}} + {{- if $isQspec}} + qspec {{$qspecName}} + {{- end}} + nodes []*{{$nodeName}} + } +{{- end}} +` + +var configurationFromRaw = ` +{{- $genFile := .GenFile}} +{{- range .Services}} + {{- $service := .GoName}} + {{- $managerName := printf "%sManager" $service}} + {{- $configurationName := printf "%sConfiguration" $service}} + {{- $qspecName := printf "%sQuorumSpec" $service}} + {{- $nodeName := printf "%sNode" $service}} + {{- $isQspec := ne (len (qspecMethods .Methods)) 0 -}} + + // {{$qspecName}}FromRaw returns a new {{$qspecName}} from the given raw configuration{{if $isQspec}} and QuorumSpec{{end}}. + // + // This function may for example be used to "clone" a configuration but install a different QuorumSpec: + // + // cfg1, err := mgr.NewConfiguration(qspec1, opts...) + // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) + func {{$configurationName}}FromRaw(rawCfg {{$rawConfiguration}}{{if $isQspec}}, qspec {{$qspecName}}{{end}}) (*{{$configurationName}}, error) { + {{- if $isQspec}} + // return an error if qspec is nil. + if qspec == nil { + return nil, {{$errorf}}("config: missing required QuorumSpec") + } + {{- end}} + newCfg := &{{$configurationName}}{ + RawConfiguration: rawCfg, + {{- if $isQspec}} + qspec: qspec, + {{- end}} + } + // initialize the nodes slice + newCfg.nodes = make([]*{{$nodeName}}, newCfg.Size()) + for i, n := range rawCfg { + newCfg.nodes[i] = &{{$nodeName}}{n} + } + return newCfg, nil + } + +{{- end}} +` + +var configurationMethodsTemplate = ` +{{- $genFile := .GenFile}} +{{- range .Services}} + {{- $service := .GoName}} + {{- $configurationName := printf "%sConfiguration" $service}} + {{- $nodeName := printf "%sNode" $service}} + + // Nodes returns a slice of each available node. IDs are returned in the same + // order as they were provided in the creation of the Manager. + // + // NOTE: mutating the returned slice is not supported. + func (c *{{$configurationName}}) Nodes() []*{{$nodeName}} { + return c.nodes + } + + // And returns a NodeListOption that can be used to create a new configuration combining c and d. + func (c {{$configurationName}}) And(d *{{$configurationName}}) {{$nodeListOptions}} { + 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 {{$configurationName}}) Except(rm *{{$configurationName}}) {{$nodeListOptions}} { + return c.RawConfiguration.Except(rm.RawConfiguration) + } + +{{- end}} +` + +var configuration = configurationVars + configurationStruct + configurationFromRaw + configurationMethodsTemplate diff --git a/cmd/protoc-gen-gorums/gengorums/template_correctable.go b/cmd/protoc-gen-gorums/gengorums/template_correctable.go index d480de1e..3b59b5a2 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_correctable.go +++ b/cmd/protoc-gen-gorums/gengorums/template_correctable.go @@ -33,7 +33,7 @@ var correctableVar = ` {{$context := use "context.Context" .GenFile}} ` -var correctableSignature = `func (c *Configuration) {{$method}}(` + +var correctableSignature = `func (c *{{$configurationName}}) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}}) ` + `*{{$correctableOut}} {` diff --git a/cmd/protoc-gen-gorums/gengorums/template_manager.go b/cmd/protoc-gen-gorums/gengorums/template_manager.go new file mode 100644 index 00000000..b8f1bd4d --- /dev/null +++ b/cmd/protoc-gen-gorums/gengorums/template_manager.go @@ -0,0 +1,96 @@ +package gengorums + +// gorums need to be imported in the zorums file +var managerVariables = ` +{{$_ := use "gorums.EnforceVersion" .GenFile}} +{{$callOpt := use "gorums.CallOption" .GenFile}} +` + +var managerStructs = ` +{{- $genFile := .GenFile}} +{{- range .Services}} + {{- $service := .GoName}} + {{- $managerName := printf "%sManager" $service}} + // {{$managerName}} maintains a connection pool of nodes on + // which quorum calls can be performed. + type {{$managerName}} struct { + *gorums.RawManager + } +{{- end}} +` + +var managerConstructor = ` +{{- $genFile := .GenFile}} +{{- range .Services}} + {{- $service := .GoName}} + {{- $managerName := printf "%sManager" $service}} + // New{{$managerName}} returns a new {{$managerName}} for managing connection to nodes added + // to the manager. This function accepts manager options used to configure + // various aspects of the manager. + func New{{$managerName}}(opts ...gorums.ManagerOption) *{{$managerName}} { + return &{{$managerName}}{ + RawManager: gorums.NewRawManager(opts...), + } + } +{{- end}} +` + +var managerNewConfiguration = ` +{{- $genFile := .GenFile}} +{{- range .Services}} + {{- $service := .GoName}} + {{- $managerName := printf "%sManager" $service}} + {{- $configurationName := printf "%sConfiguration" $service}} + {{- $qspecName := printf "%sConfiguration" $service}} + {{- $isQspec ne (len (qspecMethods .Methods)) 0 -}} + // New{{$configurationName}} returns a {{$configurationName}} based on the provided list of nodes (required) + {{- if $isQspec}} + // and a quorum specification + {{- end}} + // . + // 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(cfg gorums.NodeListOption, {{if $isQspec}}spec {{$qspecName}}{{end}}) (c *{{$configurationName}}, err error) { + c = &{{$configurationName}}{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err + } + {{- if $isQspec}} + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required {{$qspecName}}") + } + c.qspec = spec + {{- end}} + // initialize the nodes slice + c.nodes = make([]*Node, c.Size()) + for i, n := range c.RawConfiguration { + c.nodes[i] = &Node{n} + } + return c, nil + } +{{- end}} +` + +var managerMethodNodes = ` +{{- $genFile := .GenFile}} +{{- range .Services}} + {{- $service := .GoName}} + {{- $managerName := printf "%sManager" $service}} + {{- $nodeName := printf "%sNode" $service}} + // Nodes returns a slice of available nodes on this manager. + // IDs are returned in the order they were added at creation of the manager. + func (m *{{$managerName}}) Nodes() []*{{$nodeName}} { + gorumsNodes := m.RawManager.Nodes() + nodes := make([]*{{$nodeName}}, len(gorumsNodes)) + for i, n := range gorumsNodes { + nodes[i] = &{{$nodeName}}{n} + } + return nodes + } +{{- end}} +` + +var manager = managerVariables + managerStructs + managerConstructor + managerMethodNodes diff --git a/cmd/protoc-gen-gorums/gengorums/template_multicast.go b/cmd/protoc-gen-gorums/gengorums/template_multicast.go index 40b40c19..dce74a53 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_multicast.go +++ b/cmd/protoc-gen-gorums/gengorums/template_multicast.go @@ -15,7 +15,7 @@ var mcVar = ` {{$callOpt := use "gorums.CallOption" .GenFile}} ` -var multicastSignature = `func (c *Configuration) {{$method}}(` + +var multicastSignature = `func (c *{{$configurationName}}) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}},` + `opts ...{{$callOpt}}) { diff --git a/cmd/protoc-gen-gorums/gengorums/template_node.go b/cmd/protoc-gen-gorums/gengorums/template_node.go new file mode 100644 index 00000000..1680c3d2 --- /dev/null +++ b/cmd/protoc-gen-gorums/gengorums/template_node.go @@ -0,0 +1,21 @@ +package gengorums + +// gorums need to be imported in the zorums file +var nodeVariables = ` +{{$_ := use "gorums.EnforceVersion" .GenFile}} +{{$callOpt := use "gorums.CallOption" .GenFile}} +` + +var nodeStructs = ` +{{- $genFile := .GenFile}} +{{- range .Services}} + {{- $service := .GoName}} + {{- $nodeName := printf "%sNode" $service}} + // {{$nodeName}} holds the node specific methods for the {{$service}} service. + type {{$nodeName}} struct { + *gorums.RawNode + } +{{- end}} +` + +var node = nodeVariables + nodeStructs diff --git a/cmd/protoc-gen-gorums/gengorums/template_qspec.go b/cmd/protoc-gen-gorums/gengorums/template_qspec.go index 3afa740c..67e4a726 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_qspec.go +++ b/cmd/protoc-gen-gorums/gengorums/template_qspec.go @@ -9,13 +9,11 @@ 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 { + {{- $service := .GoName}} + {{- $qspecName := printf "%sQuorumSpec" $service}} + // {{$qspecName}} is the interface of quorum functions for {{.GoName}}. + type {{$qspecName}} interface { {{$configOpt}} {{range qspecMethods .Methods -}} diff --git a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go index 7fd40858..8e07e946 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go +++ b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go @@ -10,6 +10,9 @@ var commonVariables = ` {{$customOut := customOut .GenFile .Method}} {{$customOutField := field $customOut}} {{$unexportOutput := unexport .Method.Output.GoIdent.GoName}} +{{$serviceName := .Method.Parent.GoName}} +{{$nodeName := printf "%sNode" $serviceName}} +{{$configurationName := printf "%sConfiguration" $serviceName}} ` var quorumCallComment = ` @@ -30,7 +33,7 @@ var quorumCallComment = ` {{end -}} ` -var quorumCallSignature = `func (c *Configuration) {{$method}}(` + +var quorumCallSignature = `func (c *{{$configurationName}}) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}})` + `(resp *{{$customOut}}, err error) { diff --git a/cmd/protoc-gen-gorums/gengorums/template_rpc.go b/cmd/protoc-gen-gorums/gengorums/template_rpc.go index ae22a4c7..a934056e 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_rpc.go +++ b/cmd/protoc-gen-gorums/gengorums/template_rpc.go @@ -1,10 +1,5 @@ package gengorums -var rpcSignature = `func (n *Node) {{$method}}(` + - `ctx {{$context}}, in *{{$in}}` + - `{{perNodeFnType .GenFile .Method ", f"}}) (resp *{{$customOut}}, err error) { -` - var rpcVar = ` {{$callData := use "gorums.CallData" .GenFile}} {{$genFile := .GenFile}} @@ -12,6 +7,11 @@ var rpcVar = ` {{$context := use "context.Context" .GenFile}} ` +var rpcSignature = `func (n *{{$nodeName}}) {{$method}}(` + + `ctx {{$context}}, in *{{$in}}` + + `{{perNodeFnType .GenFile .Method ", f"}}) (resp *{{$customOut}}, err error) { +` + var rpcBody = ` cd := {{$callData}}{ Message: in, Method: "{{$fullName}}", diff --git a/cmd/protoc-gen-gorums/gengorums/template_unicast.go b/cmd/protoc-gen-gorums/gengorums/template_unicast.go index 89b2bb89..044a2272 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_unicast.go +++ b/cmd/protoc-gen-gorums/gengorums/template_unicast.go @@ -1,8 +1,20 @@ package gengorums -var unicastVar = rpcVar + `{{$callOpt := use "gorums.CallOption" .GenFile}}` +var unicastVar = rpcVar + ` + {{$callOpt := use "gorums.CallOption" .GenFile}} + {{$nodeName := printf "%sNode" .Method.Parent.GoName}} +` + +var unicastCallComment = ` +{{$comments := .Method.Comments.Leading}} +{{if ne $comments ""}} +{{$comments -}} +{{else}} +// {{$method}} is a one-way call; no replies are processed. +{{end -}} +` -var unicastSignature = `func (n *Node) {{$method}}(` + +var unicastSignature = `func (n *{{$nodeName}}) {{$method}}(` + `ctx {{$context}}, in *{{$in}}, opts ...{{$callOpt}}) { ` @@ -18,6 +30,6 @@ var unicastBody = ` cd := {{$callData}}{ var unicastCall = commonVariables + unicastVar + multicastRefImports + - quorumCallComment + + unicastCallComment + unicastSignature + unicastBody diff --git a/gorums.pb.go b/gorums.pb.go index b25f1ed2..b13fe39e 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: gorums.proto package gorums @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" - unsafe "unsafe" ) const ( @@ -114,7 +113,7 @@ var ( var File_gorums_proto protoreflect.FileDescriptor -var file_gorums_proto_rawDesc = string([]byte{ +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, @@ -154,7 +153,7 @@ var file_gorums_proto_rawDesc = string([]byte{ 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 @@ -184,7 +183,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: 8, @@ -195,6 +194,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 3d89e112..0a87c360 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: internal/correctable/opts.proto package correctable @@ -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,7 +49,7 @@ var ( var File_internal_correctable_opts_proto protoreflect.FileDescriptor -var file_internal_correctable_opts_proto_rawDesc = string([]byte{ +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, @@ -70,7 +69,7 @@ var file_internal_correctable_opts_proto_rawDesc = string([]byte{ 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 @@ -94,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, @@ -105,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 235dcec8..f22a2baf 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: ordering/ordering.proto package ordering @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - unsafe "unsafe" ) const ( @@ -121,7 +120,7 @@ func (b0 Metadata_builder) Build() *Metadata { var File_ordering_ordering_proto protoreflect.FileDescriptor -var file_ordering_ordering_proto_rawDesc = string([]byte{ +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, @@ -141,7 +140,7 @@ var file_ordering_ordering_proto_rawDesc = string([]byte{ 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, 1) var file_ordering_ordering_proto_goTypes = []any{ @@ -168,7 +167,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: 1, NumExtensions: 0, @@ -179,6 +178,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/ordering/ordering_grpc.pb.go b/ordering/ordering_grpc.pb.go index 44271a0a..385adba9 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/tests/config/config.pb.go b/tests/config/config.pb.go index 24676861..15ac7ef9 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: config/config.proto package config @@ -12,7 +12,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -120,7 +119,7 @@ func (x *Response) GetNum() uint64 { var File_config_config_proto protoreflect.FileDescriptor -var file_config_config_proto_rawDesc = string([]byte{ +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, @@ -137,16 +136,16 @@ var file_config_config_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_config_config_proto_rawDescData []byte + file_config_config_proto_rawDescData = file_config_config_proto_rawDesc ) 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))) + file_config_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_config_config_proto_rawDescData) }) return file_config_config_proto_rawDescData } @@ -175,7 +174,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, @@ -186,6 +185,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 72b01212..e4689985 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: config/config.proto package config @@ -157,6 +157,11 @@ type ConfigTestClient interface { // enforce interface compliance var _ ConfigTestClient = (*Configuration)(nil) +// ConfigTestNode holds the node specific methods for the ConfigTest service. +type ConfigTestNode struct { + *gorums.RawNode +} + // QuorumSpec is the interface of quorum functions for ConfigTest. type QuorumSpec interface { gorums.ConfigOption diff --git a/tests/correctable/correctable.pb.go b/tests/correctable/correctable.pb.go index f2047abf..d153562f 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: correctable/correctable.proto package correctable @@ -12,7 +12,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -104,7 +103,7 @@ func (x *CorrectableResponse) GetLevel() int32 { var File_correctable_correctable_proto protoreflect.FileDescriptor -var file_correctable_correctable_proto_rawDesc = string([]byte{ +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, @@ -130,16 +129,16 @@ var file_correctable_correctable_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_correctable_correctable_proto_rawDescData []byte + file_correctable_correctable_proto_rawDescData = file_correctable_correctable_proto_rawDesc ) 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))) + file_correctable_correctable_proto_rawDescData = protoimpl.X.CompressGZIP(file_correctable_correctable_proto_rawDescData) }) return file_correctable_correctable_proto_rawDescData } @@ -170,7 +169,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, @@ -181,6 +180,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 79485afc..553ce058 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: correctable/correctable.proto package correctable @@ -203,6 +203,11 @@ func (c *Configuration) CorrectableStream(ctx context.Context, in *CorrectableRe return &CorrectableStreamCorrectableResponse{corr} } +// CorrectableTestNode holds the node specific methods for the CorrectableTest service. +type CorrectableTestNode struct { + *gorums.RawNode +} + // QuorumSpec is the interface of quorum functions for CorrectableTest. type QuorumSpec interface { gorums.ConfigOption diff --git a/tests/dummy/dummy.pb.go b/tests/dummy/dummy.pb.go index 93525796..7ef7db97 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: dummy/dummy.proto package dummy @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -59,7 +58,7 @@ func (*Empty) Descriptor() ([]byte, []int) { var File_dummy_dummy_proto protoreflect.FileDescriptor -var file_dummy_dummy_proto_rawDesc = string([]byte{ +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, @@ -69,16 +68,16 @@ var file_dummy_dummy_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_dummy_dummy_proto_rawDescData []byte + file_dummy_dummy_proto_rawDescData = file_dummy_dummy_proto_rawDesc ) 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))) + file_dummy_dummy_proto_rawDescData = protoimpl.X.CompressGZIP(file_dummy_dummy_proto_rawDescData) }) return file_dummy_dummy_proto_rawDescData } @@ -106,7 +105,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, @@ -117,6 +116,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 5a0e3a3a..e517855c 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: dummy/dummy.proto package dummy @@ -154,14 +154,19 @@ type DummyNodeClient interface { } // enforce interface compliance -var _ DummyNodeClient = (*Node)(nil) +var _ DummyNodeClient = (*DummyNode)(nil) + +// DummyNode holds the node specific methods for the Dummy service. +type DummyNode struct { + *gorums.RawNode +} // 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. -func (n *Node) Test(ctx context.Context, in *Empty) (resp *Empty, err error) { +func (n *DummyNode) Test(ctx context.Context, in *Empty) (resp *Empty, err error) { cd := gorums.CallData{ Message: in, Method: "dummy.Dummy.Test", diff --git a/tests/metadata/metadata.pb.go b/tests/metadata/metadata.pb.go index 20058ee1..05e67ad1 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: metadata/metadata.proto package metadata @@ -12,7 +12,6 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -112,7 +111,7 @@ func (x *IPAddr) GetAddr() string { var File_metadata_metadata_proto protoreflect.FileDescriptor -var file_metadata_metadata_proto_rawDesc = string([]byte{ +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, @@ -133,16 +132,16 @@ var file_metadata_metadata_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_metadata_metadata_proto_rawDescData []byte + file_metadata_metadata_proto_rawDescData = file_metadata_metadata_proto_rawDesc ) 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))) + file_metadata_metadata_proto_rawDescData = protoimpl.X.CompressGZIP(file_metadata_metadata_proto_rawDescData) }) return file_metadata_metadata_proto_rawDescData } @@ -174,7 +173,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, @@ -185,6 +184,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 7f585aa4..a2d108bf 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: metadata/metadata.proto package metadata @@ -156,13 +156,18 @@ type MetadataTestNodeClient interface { } // enforce interface compliance -var _ MetadataTestNodeClient = (*Node)(nil) +var _ MetadataTestNodeClient = (*MetadataTestNode)(nil) + +// MetadataTestNode holds the node specific methods for the MetadataTest service. +type MetadataTestNode struct { + *gorums.RawNode +} // 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) { +func (n *MetadataTestNode) IDFromMD(ctx context.Context, in *emptypb.Empty) (resp *NodeID, err error) { cd := gorums.CallData{ Message: in, Method: "metadata.MetadataTest.IDFromMD", @@ -176,7 +181,7 @@ func (n *Node) IDFromMD(ctx context.Context, in *emptypb.Empty) (resp *NodeID, e } // WhatIP returns the address of the client that calls it. -func (n *Node) WhatIP(ctx context.Context, in *emptypb.Empty) (resp *IPAddr, err error) { +func (n *MetadataTestNode) WhatIP(ctx context.Context, in *emptypb.Empty) (resp *IPAddr, err error) { cd := gorums.CallData{ Message: in, Method: "metadata.MetadataTest.WhatIP", diff --git a/tests/oneway/oneway.pb.go b/tests/oneway/oneway.pb.go index f4fa6319..18c78284 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: oneway/oneway.proto package oneway @@ -12,7 +12,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -104,7 +103,7 @@ func (*Empty) Descriptor() ([]byte, []int) { var File_oneway_oneway_proto protoreflect.FileDescriptor -var file_oneway_oneway_proto_rawDesc = string([]byte{ +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, @@ -125,16 +124,16 @@ var file_oneway_oneway_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_oneway_oneway_proto_rawDescData []byte + file_oneway_oneway_proto_rawDescData = file_oneway_oneway_proto_rawDesc ) 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))) + file_oneway_oneway_proto_rawDescData = protoimpl.X.CompressGZIP(file_oneway_oneway_proto_rawDescData) }) return file_oneway_oneway_proto_rawDescData } @@ -167,7 +166,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, @@ -178,6 +177,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 ce524ce3..f1ac0cb9 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: oneway/oneway.proto package oneway @@ -164,7 +164,7 @@ type OnewayTestNodeClient interface { } // enforce interface compliance -var _ OnewayTestNodeClient = (*Node)(nil) +var _ OnewayTestNodeClient = (*OnewayTestNode)(nil) // Multicast is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. @@ -195,6 +195,11 @@ func (c *Configuration) MulticastPerNode(ctx context.Context, in *Request, f fun c.RawConfiguration.Multicast(ctx, cd, opts...) } +// OnewayTestNode holds the node specific methods for the OnewayTest service. +type OnewayTestNode struct { + *gorums.RawNode +} + // There are no quorum calls. type QuorumSpec interface{} @@ -225,7 +230,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. -func (n *Node) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { +func (n *OnewayTestNode) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.CallData{ Message: in, Method: "oneway.OnewayTest.Unicast", diff --git a/tests/ordering/order.pb.go b/tests/ordering/order.pb.go index 80f392e6..72d18e8a 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: ordering/order.proto package ordering @@ -12,7 +12,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -112,7 +111,7 @@ func (x *Response) GetInOrder() bool { var File_ordering_order_proto protoreflect.FileDescriptor -var file_ordering_order_proto_rawDesc = string([]byte{ +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, @@ -135,16 +134,16 @@ var file_ordering_order_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_ordering_order_proto_rawDescData []byte + file_ordering_order_proto_rawDescData = file_ordering_order_proto_rawDesc ) 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))) + file_ordering_order_proto_rawDescData = protoimpl.X.CompressGZIP(file_ordering_order_proto_rawDescData) }) return file_ordering_order_proto_rawDescData } @@ -177,7 +176,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, @@ -188,6 +187,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 992a19cb..5afde699 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: ordering/order.proto package ordering @@ -184,7 +184,12 @@ type GorumsTestNodeClient interface { } // enforce interface compliance -var _ GorumsTestNodeClient = (*Node)(nil) +var _ GorumsTestNodeClient = (*GorumsTestNode)(nil) + +// GorumsTestNode holds the node specific methods for the GorumsTest service. +type GorumsTestNode struct { + *gorums.RawNode +} // QuorumSpec is the interface of quorum functions for GorumsTest. type QuorumSpec interface { @@ -229,7 +234,7 @@ func (c *Configuration) QC(ctx context.Context, in *Request) (resp *Response, er // UnaryRPC is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. -func (n *Node) UnaryRPC(ctx context.Context, in *Request) (resp *Response, err error) { +func (n *GorumsTestNode) UnaryRPC(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.CallData{ Message: in, Method: "ordering.GorumsTest.UnaryRPC", diff --git a/tests/qf/qf.pb.go b/tests/qf/qf.pb.go index b61d2711..6da39825 100644 --- a/tests/qf/qf.pb.go +++ b/tests/qf/qf.pb.go @@ -2,8 +2,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: qf/qf.proto package qf @@ -14,7 +14,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -114,7 +113,7 @@ func (x *Response) GetResult() int64 { var File_qf_qf_proto protoreflect.FileDescriptor -var file_qf_qf_proto_rawDesc = string([]byte{ +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, @@ -132,16 +131,16 @@ var file_qf_qf_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_qf_qf_proto_rawDescData []byte + file_qf_qf_proto_rawDescData = file_qf_qf_proto_rawDesc ) 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))) + file_qf_qf_proto_rawDescData = protoimpl.X.CompressGZIP(file_qf_qf_proto_rawDescData) }) return file_qf_qf_proto_rawDescData } @@ -172,7 +171,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, @@ -183,6 +182,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 e14766be..90899b05 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: qf/qf.proto package qf @@ -158,6 +158,11 @@ type QuorumFunctionClient interface { // enforce interface compliance var _ QuorumFunctionClient = (*Configuration)(nil) +// QuorumFunctionNode holds the node specific methods for the QuorumFunction service. +type QuorumFunctionNode struct { + *gorums.RawNode +} + // QuorumSpec is the interface of quorum functions for QuorumFunction. type QuorumSpec interface { gorums.ConfigOption diff --git a/tests/tls/tls.pb.go b/tests/tls/tls.pb.go index 78345b12..e7b3fec7 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: tls/tls.proto package tls @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -103,7 +102,7 @@ func (x *Response) GetOK() bool { var File_tls_tls_proto protoreflect.FileDescriptor -var file_tls_tls_proto_rawDesc = string([]byte{ +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, @@ -115,16 +114,16 @@ var file_tls_tls_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_tls_tls_proto_rawDescData []byte + file_tls_tls_proto_rawDescData = file_tls_tls_proto_rawDesc ) 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))) + file_tls_tls_proto_rawDescData = protoimpl.X.CompressGZIP(file_tls_tls_proto_rawDescData) }) return file_tls_tls_proto_rawDescData } @@ -153,7 +152,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, @@ -164,6 +163,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 f60cab7a..1adac2df 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: tls/tls.proto package tls @@ -154,14 +154,19 @@ type TLSNodeClient interface { } // enforce interface compliance -var _ TLSNodeClient = (*Node)(nil) +var _ TLSNodeClient = (*TLSNode)(nil) + +// TLSNode holds the node specific methods for the TLS service. +type TLSNode struct { + *gorums.RawNode +} // 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. -func (n *Node) TestTLS(ctx context.Context, in *Request) (resp *Response, err error) { +func (n *TLSNode) TestTLS(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.CallData{ Message: in, Method: "tls.TLS.TestTLS", diff --git a/tests/unresponsive/unresponsive.pb.go b/tests/unresponsive/unresponsive.pb.go index b498897f..0b180d4d 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.5 -// protoc v5.29.3 +// protoc-gen-go v1.36.3 +// protoc v5.29.2 // source: unresponsive/unresponsive.proto package unresponsive @@ -11,7 +11,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -59,7 +58,7 @@ func (*Empty) Descriptor() ([]byte, []int) { var File_unresponsive_unresponsive_proto protoreflect.FileDescriptor -var file_unresponsive_unresponsive_proto_rawDesc = string([]byte{ +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, @@ -73,16 +72,16 @@ var file_unresponsive_unresponsive_proto_rawDesc = string([]byte{ 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_rawDescOnce sync.Once - file_unresponsive_unresponsive_proto_rawDescData []byte + file_unresponsive_unresponsive_proto_rawDescData = file_unresponsive_unresponsive_proto_rawDesc ) 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))) + file_unresponsive_unresponsive_proto_rawDescData = protoimpl.X.CompressGZIP(file_unresponsive_unresponsive_proto_rawDescData) }) return file_unresponsive_unresponsive_proto_rawDescData } @@ -110,7 +109,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, @@ -121,6 +120,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 5043c29f..53b27ba6 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: unresponsive/unresponsive.proto package unresponsive @@ -154,14 +154,19 @@ type UnresponsiveNodeClient interface { } // enforce interface compliance -var _ UnresponsiveNodeClient = (*Node)(nil) +var _ UnresponsiveNodeClient = (*UnresponsiveNode)(nil) + +// UnresponsiveNode holds the node specific methods for the Unresponsive service. +type UnresponsiveNode struct { + *gorums.RawNode +} // 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. -func (n *Node) TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) { +func (n *UnresponsiveNode) TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) { cd := gorums.CallData{ Message: in, Method: "unresponsive.Unresponsive.TestUnresponsive", From e7d94b6774b8f2a65f1d783dbc0cfdb047d786a4 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Mon, 24 Mar 2025 16:02:39 +0100 Subject: [PATCH 02/11] remove multi-service error --- cmd/protoc-gen-gorums/gengorums/gorums.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmd/protoc-gen-gorums/gengorums/gorums.go b/cmd/protoc-gen-gorums/gengorums/gorums.go index 02217523..ed6364e9 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -78,12 +78,6 @@ func gorumsGuard(file *protogen.File) bool { // there is nothing for this plugin to do return false } - if len(file.Services) > 1 { - // To build multiple services, make separate proto files and - // run the plugin separately for each proto file. - // These cannot share the same Go package. - log.Fatalln("Gorums does not support multiple services in the same proto file.") - } // fail generator if a Gorums reserved identifier is used as a message name. for _, msg := range file.Messages { msgName := fmt.Sprintf("%v", msg.Desc.Name()) From 891ced21332f5a4613cac08b5b9657e807cf6085 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Mon, 24 Mar 2025 16:35:16 +0100 Subject: [PATCH 03/11] fix compiler errors --- Makefile | 2 +- benchmark/benchmark.go | 10 +- benchmark/benchmark_gorums.pb.go | 152 ++---------- cmd/benchmark/main.go | 4 +- .../dev/zorums_manager_gorums.pb.go | 24 ++ .../gengorums/template_configuration.go | 3 +- .../gengorums/template_manager.go | 17 +- .../gengorums/template_static.go | 134 +---------- .../failing/reservednames/reserved.pb.go | 217 ++++++++++++++++++ .../reservednames/reserved_gorums.pb.go | 215 +++++++++++++++++ rpc_test.go | 4 +- tests/config/config_gorums.pb.go | 126 ++++------ tests/config/config_test.go | 12 +- tests/correctable/correctable_gorums.pb.go | 184 ++++++--------- tests/correctable/correctable_test.go | 10 +- tests/dummy/dummy_gorums.pb.go | 120 +++------- tests/metadata/metadata_gorums.pb.go | 122 +++------- tests/metadata/metadata_test.go | 6 +- tests/oneway/oneway_gorums.pb.go | 145 ++++-------- tests/oneway/oneway_test.go | 8 +- tests/ordering/order_gorums.pb.go | 184 ++++++--------- tests/ordering/order_test.go | 8 +- tests/qf/qf_gorums.pb.go | 130 ++++------- tests/qf/qf_test.go | 4 +- tests/tls/tls_gorums.pb.go | 120 +++------- tests/tls/tls_test.go | 2 +- tests/unresponsive/unreponsive_test.go | 2 +- tests/unresponsive/unresponsive_gorums.pb.go | 120 +++------- 28 files changed, 969 insertions(+), 1116 deletions(-) create mode 100644 internal/testprotos/failing/reservednames/reserved.pb.go create mode 100644 internal/testprotos/failing/reservednames/reserved_gorums.pb.go diff --git a/Makefile b/Makefile index 98d8c8b8..fd6b24fa 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ benchmark: installgorums $(benchmark_deps) $(static_file): $(static_files) @cp $(static_file) $(static_file).bak -# @protoc-gen-gorums --bundle=$(static_file) + @protoc-gen-gorums --bundle=$(static_file) %.pb.go : %.proto @protoc -I=$(proto_path) \ diff --git a/benchmark/benchmark.go b/benchmark/benchmark.go index e1eae0a5..18631cc2 100644 --- a/benchmark/benchmark.go +++ b/benchmark/benchmark.go @@ -37,7 +37,7 @@ type ( serverFunc func(context.Context, *TimedMsg) ) -func runQCBenchmark(opts Options, cfg *Configuration, f qcFunc) (*Result, error) { +func runQCBenchmark(opts Options, cfg *BenchmarkConfiguration, f qcFunc) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() msg := Echo_builder{Payload: make([]byte, opts.Payload)}.Build() @@ -103,7 +103,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 *BenchmarkConfiguration, f asyncQCFunc) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() msg := Echo_builder{Payload: make([]byte, opts.Payload)}.Build() @@ -187,7 +187,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 *BenchmarkConfiguration, f serverFunc) (*Result, error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() payload := make([]byte, opts.Payload) @@ -241,7 +241,7 @@ 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 *BenchmarkConfiguration) []Bench { m := []Bench{ { Name: "QuorumCall", @@ -270,7 +270,7 @@ 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) { +func RunBenchmarks(benchRegex *regexp.Regexp, options Options, cfg *BenchmarkConfiguration) ([]*Result, error) { benchmarks := GetBenchmarks(cfg) var results []*Result for _, b := range benchmarks { diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index d519c86e..fa2d7443 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -10,7 +10,6 @@ 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" ) @@ -22,134 +21,6 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 -} - -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. -// -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: -// -// 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") - } - newCfg := &Configuration{ - RawConfiguration: rawCfg, - qspec: qspec, - } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } - return newCfg, nil -} - -// Nodes returns a slice of each available node. IDs are returned in the same -// order as they were provided in the creation of the Manager. -// -// NOTE: mutating the returned slice is not supported. -func (c *Configuration) Nodes() []*Node { - return c.nodes -} - -// 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 { - 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 { - return c.RawConfiguration.Except(rm.RawConfiguration) -} - -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on -// which quorum calls can be performed. -type Manager struct { - *gorums.RawManager -} - -// NewManager returns a new Manager for managing connection to nodes added -// to the manager. This function accepts manager options used to configure -// various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ - RawManager: gorums.NewRawManager(opts...), - } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. -// 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)) - } - 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") - } - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } - return c, nil -} - -// Nodes returns a slice of available nodes on this manager. -// IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { - gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) - for i, n := range gorumsNodes { - nodes[i] = &Node{n} - } - return nodes -} - -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -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. @@ -246,6 +117,29 @@ func NewBenchmarkManager(opts ...gorums.ManagerOption) *BenchmarkManager { return &BenchmarkManager{ RawManager: gorums.NewRawManager(opts...), } +} // NewBenchmarkConfiguration returns a BenchmarkConfiguration based on the provided list of nodes (required) +// and a quorum specification +// . +// 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 *BenchmarkManager) NewConfiguration(cfg gorums.NodeListOption, qspec BenchmarkQuorumSpec) (c *BenchmarkConfiguration, err error) { + c = &BenchmarkConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err + } + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required BenchmarkQuorumSpec") + } + c.qspec = qspec + // initialize the nodes slice + c.nodes = make([]*BenchmarkNode, c.Size()) + for i, n := range c.RawConfiguration { + c.nodes[i] = &BenchmarkNode{n} + } + return c, nil } // Nodes returns a slice of available nodes on this manager. diff --git a/cmd/benchmark/main.go b/cmd/benchmark/main.go index 6b1456be..00c58648 100644 --- a/cmd/benchmark/main.go +++ b/cmd/benchmark/main.go @@ -196,7 +196,7 @@ func main() { gorums.WithSendBufferSize(*sendBuffer), } - mgr := benchmark.NewManager(mgrOpts...) + mgr := benchmark.NewBenchmarkManager(mgrOpts...) defer mgr.Close() qspec := &benchmark.QSpec{ @@ -204,7 +204,7 @@ func main() { CfgSize: options.NumNodes, } - cfg, err := mgr.NewConfiguration(qspec, gorums.WithNodeList(remotes[:options.NumNodes])) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(remotes[:options.NumNodes]), qspec) checkf("Failed to create configuration: %v", err) results, err := benchmark.RunBenchmarks(benchReg, options, cfg) diff --git a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go index 6548a8b7..9792aec9 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go @@ -7,6 +7,7 @@ package dev import ( + fmt "fmt" gorums "github.com/relab/gorums" ) @@ -30,6 +31,29 @@ func NewZorumsServiceManager(opts ...gorums.ManagerOption) *ZorumsServiceManager return &ZorumsServiceManager{ RawManager: gorums.NewRawManager(opts...), } +} // NewZorumsServiceConfiguration returns a ZorumsServiceConfiguration based on the provided list of nodes (required) +// and a quorum specification +// . +// 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 *ZorumsServiceManager) NewConfiguration(cfg gorums.NodeListOption, qspec ZorumsServiceQuorumSpec) (c *ZorumsServiceConfiguration, err error) { + c = &ZorumsServiceConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err + } + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required ZorumsServiceQuorumSpec") + } + c.qspec = qspec + // initialize the nodes slice + c.nodes = make([]*ZorumsServiceNode, c.Size()) + for i, n := range c.RawConfiguration { + c.nodes[i] = &ZorumsServiceNode{n} + } + return c, nil } // Nodes returns a slice of available nodes on this manager. diff --git a/cmd/protoc-gen-gorums/gengorums/template_configuration.go b/cmd/protoc-gen-gorums/gengorums/template_configuration.go index 545cbd21..fe3c453f 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_configuration.go +++ b/cmd/protoc-gen-gorums/gengorums/template_configuration.go @@ -3,7 +3,6 @@ package gengorums var configurationVars = ` {{$rawConfiguration := use "gorums.RawConfiguration" .GenFile}} {{$nodeListOptions := use "gorums.NodeListOption" .GenFile}} -{{$errorf := use "fmt.Errorf" .GenFile}} ` var configurationStruct = ` @@ -47,7 +46,7 @@ var configurationFromRaw = ` {{- if $isQspec}} // return an error if qspec is nil. if qspec == nil { - return nil, {{$errorf}}("config: missing required QuorumSpec") + return nil, {{use "fmt.Errorf" $genFile}}("config: missing required QuorumSpec") } {{- end}} newCfg := &{{$configurationName}}{ diff --git a/cmd/protoc-gen-gorums/gengorums/template_manager.go b/cmd/protoc-gen-gorums/gengorums/template_manager.go index b8f1bd4d..afa55455 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_manager.go +++ b/cmd/protoc-gen-gorums/gengorums/template_manager.go @@ -41,8 +41,9 @@ var managerNewConfiguration = ` {{- $service := .GoName}} {{- $managerName := printf "%sManager" $service}} {{- $configurationName := printf "%sConfiguration" $service}} - {{- $qspecName := printf "%sConfiguration" $service}} - {{- $isQspec ne (len (qspecMethods .Methods)) 0 -}} + {{- $qspecName := printf "%sQuorumSpec" $service}} + {{- $nodeName := printf "%sNode" $service}} + {{- $isQspec := ne (len (qspecMethods .Methods)) 0 -}} // New{{$configurationName}} returns a {{$configurationName}} based on the provided list of nodes (required) {{- if $isQspec}} // and a quorum specification @@ -51,7 +52,7 @@ var managerNewConfiguration = ` // 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(cfg gorums.NodeListOption, {{if $isQspec}}spec {{$qspecName}}{{end}}) (c *{{$configurationName}}, err error) { + func (m *{{$managerName}}) NewConfiguration(cfg gorums.NodeListOption{{if $isQspec}}, qspec {{$qspecName}}{{end}}) (c *{{$configurationName}}, err error) { c = &{{$configurationName}}{} c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) if err != nil { @@ -60,14 +61,14 @@ var managerNewConfiguration = ` {{- if $isQspec}} // return an error if qspec is nil. if qspec == nil { - return nil, fmt.Errorf("config: missing required {{$qspecName}}") + return nil, {{use "fmt.Errorf" $genFile}}("config: missing required {{$qspecName}}") } - c.qspec = spec + c.qspec = qspec {{- end}} // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*{{$nodeName}}, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &{{$nodeName}}{n} } return c, nil } @@ -93,4 +94,4 @@ var managerMethodNodes = ` {{- end}} ` -var manager = managerVariables + managerStructs + managerConstructor + managerMethodNodes +var manager = managerVariables + managerStructs + managerConstructor + managerNewConfiguration + managerMethodNodes diff --git a/cmd/protoc-gen-gorums/gengorums/template_static.go b/cmd/protoc-gen-gorums/gengorums/template_static.go index 0bbcd5ef..4143fcf2 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_static.go +++ b/cmd/protoc-gen-gorums/gengorums/template_static.go @@ -5,138 +5,10 @@ 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{} // 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(nil) -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 -} - -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. -// -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: -// -// 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") - } - newCfg := &Configuration{ - RawConfiguration: rawCfg, - qspec: qspec, - } - // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} - } - return newCfg, nil -} - -// Nodes returns a slice of each available node. IDs are returned in the same -// order as they were provided in the creation of the Manager. -// -// NOTE: mutating the returned slice is not supported. -func (c *Configuration) Nodes() []*Node { - return c.nodes -} - -// 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 { - 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 { - return c.RawConfiguration.Except(rm.RawConfiguration) -} - -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on -// which quorum calls can be performed. -type Manager struct { - *gorums.RawManager -} - -// NewManager returns a new Manager for managing connection to nodes added -// to the manager. This function accepts manager options used to configure -// various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ - RawManager: gorums.NewRawManager(opts...), - } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. -// 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)) - } - 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") - } - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } - return c, nil -} - -// Nodes returns a slice of available nodes on this manager. -// IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { - gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) - for i, n := range gorumsNodes { - nodes[i] = &Node{n} - } - return nodes -} - -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -` +var staticCode = `` diff --git a/internal/testprotos/failing/reservednames/reserved.pb.go b/internal/testprotos/failing/reservednames/reserved.pb.go new file mode 100644 index 00000000..974f3b0b --- /dev/null +++ b/internal/testprotos/failing/reservednames/reserved.pb.go @@ -0,0 +1,217 @@ +// Test that Gorums will stop code generation if one of the +// reserved Gorums types are used as a message type. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc v5.29.2 +// source: failing/reservednames/reserved.proto + +package reservednames + +import ( + _ "github.com/relab/gorums" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Configuration struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Conf string `protobuf:"bytes,1,opt,name=Conf"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Configuration) Reset() { + *x = Configuration{} + mi := &file_failing_reservednames_reserved_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Configuration) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Configuration) ProtoMessage() {} + +func (x *Configuration) ProtoReflect() protoreflect.Message { + mi := &file_failing_reservednames_reserved_proto_msgTypes[0] + 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 *Configuration) GetConf() string { + if x != nil { + return x.xxx_hidden_Conf + } + return "" +} + +func (x *Configuration) SetConf(v string) { + x.xxx_hidden_Conf = v +} + +type Configuration_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Conf string +} + +func (b0 Configuration_builder) Build() *Configuration { + m0 := &Configuration{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Conf = b.Conf + return m0 +} + +type Manager struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Mgr string `protobuf:"bytes,1,opt,name=Mgr"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Manager) Reset() { + *x = Manager{} + mi := &file_failing_reservednames_reserved_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Manager) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Manager) ProtoMessage() {} + +func (x *Manager) ProtoReflect() protoreflect.Message { + mi := &file_failing_reservednames_reserved_proto_msgTypes[1] + 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 *Manager) GetMgr() string { + if x != nil { + return x.xxx_hidden_Mgr + } + return "" +} + +func (x *Manager) SetMgr(v string) { + x.xxx_hidden_Mgr = v +} + +type Manager_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Mgr string +} + +func (b0 Manager_builder) Build() *Manager { + m0 := &Manager{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Mgr = b.Mgr + return m0 +} + +var File_failing_reservednames_reserved_proto protoreflect.FileDescriptor + +var file_failing_reservednames_reserved_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x66, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x66, 0x61, 0x69, 0x6c, 0x69, 0x6e, + 0x67, 0x2e, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x1a, + 0x0c, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x23, 0x0a, + 0x0d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, + 0x0a, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x43, 0x6f, + 0x6e, 0x66, 0x22, 0x1b, 0x0a, 0x07, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x12, 0x10, 0x0a, + 0x03, 0x4d, 0x67, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x67, 0x72, 0x32, + 0x80, 0x02, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x12, 0x76, 0x0a, 0x08, + 0x43, 0x6f, 0x6e, 0x66, 0x54, 0x65, 0x73, 0x74, 0x12, 0x36, 0x2e, 0x67, 0x6f, 0x72, 0x75, 0x6d, + 0x73, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x66, 0x61, 0x69, + 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x6e, 0x61, 0x6d, + 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x1a, 0x30, 0x2e, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x66, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x72, 0x65, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x4d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x22, 0x00, 0x12, 0x7c, 0x0a, 0x0a, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, + 0x6c, 0x6c, 0x12, 0x36, 0x2e, 0x67, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x66, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x72, + 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x30, 0x2e, 0x67, 0x6f, 0x72, + 0x75, 0x6d, 0x73, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x66, + 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x22, 0x04, 0xa0, 0xb5, + 0x18, 0x01, 0x42, 0x48, 0x5a, 0x41, 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, 0x74, 0x65, 0x73, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x73, 0x2f, 0x66, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x92, 0x03, 0x02, 0x08, 0x02, 0x62, 0x08, 0x65, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07, +} + +var file_failing_reservednames_reserved_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_failing_reservednames_reserved_proto_goTypes = []any{ + (*Configuration)(nil), // 0: gorums.testprotos.failing.reservednames.Configuration + (*Manager)(nil), // 1: gorums.testprotos.failing.reservednames.Manager +} +var file_failing_reservednames_reserved_proto_depIdxs = []int32{ + 0, // 0: gorums.testprotos.failing.reservednames.Reserved.ConfTest:input_type -> gorums.testprotos.failing.reservednames.Configuration + 0, // 1: gorums.testprotos.failing.reservednames.Reserved.QuorumCall:input_type -> gorums.testprotos.failing.reservednames.Configuration + 1, // 2: gorums.testprotos.failing.reservednames.Reserved.ConfTest:output_type -> gorums.testprotos.failing.reservednames.Manager + 1, // 3: gorums.testprotos.failing.reservednames.Reserved.QuorumCall:output_type -> gorums.testprotos.failing.reservednames.Manager + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] 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 +} + +func init() { file_failing_reservednames_reserved_proto_init() } +func file_failing_reservednames_reserved_proto_init() { + if File_failing_reservednames_reserved_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_failing_reservednames_reserved_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_failing_reservednames_reserved_proto_goTypes, + DependencyIndexes: file_failing_reservednames_reserved_proto_depIdxs, + MessageInfos: file_failing_reservednames_reserved_proto_msgTypes, + }.Build() + File_failing_reservednames_reserved_proto = out.File + file_failing_reservednames_reserved_proto_rawDesc = nil + file_failing_reservednames_reserved_proto_goTypes = nil + file_failing_reservednames_reserved_proto_depIdxs = nil +} diff --git a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go new file mode 100644 index 00000000..66807552 --- /dev/null +++ b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go @@ -0,0 +1,215 @@ +// Code generated by protoc-gen-gorums. DO NOT EDIT. +// versions: +// protoc-gen-gorums v0.8.0-devel +// protoc v5.29.2 +// source: failing/reservednames/reserved.proto + +package reservednames + +import ( + context "context" + fmt "fmt" + gorums "github.com/relab/gorums" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = gorums.EnforceVersion(8 - gorums.MinVersion) + // Verify that the gorums runtime is sufficiently up-to-date. + _ = gorums.EnforceVersion(gorums.MaxVersion - 8) +) + +// ReservedClient is the client interface for the Reserved service. +type ReservedClient interface { + QuorumCall(ctx context.Context, in *Configuration) (resp *Manager, err error) +} + +// enforce interface compliance +var _ ReservedClient = (*ReservedConfiguration)(nil) + +// ReservedNodeClient is the single node client interface for the Reserved service. +type ReservedNodeClient interface { + ConfTest(ctx context.Context, in *Configuration) (resp *Manager, err error) +} + +// enforce interface compliance +var _ ReservedNodeClient = (*ReservedNode)(nil) + +// A ReservedConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type ReservedConfiguration struct { + gorums.RawConfiguration + qspec ReservedQuorumSpec + nodes []*ReservedNode +} // ReservedQuorumSpecFromRaw returns a new ReservedQuorumSpec from the given raw configuration and QuorumSpec. +// +// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// +// cfg1, err := mgr.NewConfiguration(qspec1, opts...) +// cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) +func ReservedConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec ReservedQuorumSpec) (*ReservedConfiguration, error) { + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required QuorumSpec") + } + newCfg := &ReservedConfiguration{ + RawConfiguration: rawCfg, + qspec: qspec, + } + // initialize the nodes slice + newCfg.nodes = make([]*ReservedNode, newCfg.Size()) + for i, n := range rawCfg { + newCfg.nodes[i] = &ReservedNode{n} + } + return newCfg, nil +} + +// Nodes returns a slice of each available node. IDs are returned in the same +// order as they were provided in the creation of the Manager. +// +// NOTE: mutating the returned slice is not supported. +func (c *ReservedConfiguration) Nodes() []*ReservedNode { + return c.nodes +} + +// And returns a NodeListOption that can be used to create a new configuration combining c and d. +func (c ReservedConfiguration) And(d *ReservedConfiguration) 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 ReservedConfiguration) Except(rm *ReservedConfiguration) gorums.NodeListOption { + return c.RawConfiguration.Except(rm.RawConfiguration) +} + +// ReservedManager maintains a connection pool of nodes on +// which quorum calls can be performed. +type ReservedManager struct { + *gorums.RawManager +} + +// NewReservedManager returns a new ReservedManager for managing connection to nodes added +// to the manager. This function accepts manager options used to configure +// various aspects of the manager. +func NewReservedManager(opts ...gorums.ManagerOption) *ReservedManager { + return &ReservedManager{ + RawManager: gorums.NewRawManager(opts...), + } +} // NewReservedConfiguration returns a ReservedConfiguration based on the provided list of nodes (required) +// and a quorum specification +// . +// 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 *ReservedManager) NewConfiguration(cfg gorums.NodeListOption, qspec ReservedQuorumSpec) (c *ReservedConfiguration, err error) { + c = &ReservedConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err + } + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required ReservedQuorumSpec") + } + c.qspec = qspec + // initialize the nodes slice + c.nodes = make([]*ReservedNode, c.Size()) + for i, n := range c.RawConfiguration { + c.nodes[i] = &ReservedNode{n} + } + return c, nil +} + +// Nodes returns a slice of available nodes on this manager. +// IDs are returned in the order they were added at creation of the manager. +func (m *ReservedManager) Nodes() []*ReservedNode { + gorumsNodes := m.RawManager.Nodes() + nodes := make([]*ReservedNode, len(gorumsNodes)) + for i, n := range gorumsNodes { + nodes[i] = &ReservedNode{n} + } + return nodes +} + +// ReservedNode holds the node specific methods for the Reserved service. +type ReservedNode struct { + *gorums.RawNode +} + +// ReservedQuorumSpec is the interface of quorum functions for Reserved. +type ReservedQuorumSpec 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 '_ *Configuration'. + QuorumCallQF(in *Configuration, replies map[uint32]*Manager) (*Manager, bool) +} + +// QuorumCall is a quorum call invoked on all nodes in configuration c, +// with the same argument in, and returns a combined result. +func (c *ReservedConfiguration) QuorumCall(ctx context.Context, in *Configuration) (resp *Manager, err error) { + cd := gorums.QuorumCallData{ + Message: in, + Method: "gorums.testprotos.failing.reservednames.Reserved.QuorumCall", + } + cd.QuorumFunction = func(req protoreflect.ProtoMessage, replies map[uint32]protoreflect.ProtoMessage) (protoreflect.ProtoMessage, bool) { + r := make(map[uint32]*Manager, len(replies)) + for k, v := range replies { + r[k] = v.(*Manager) + } + return c.qspec.QuorumCallQF(req.(*Configuration), r) + } + + res, err := c.RawConfiguration.QuorumCall(ctx, cd) + if err != nil { + return nil, err + } + return res.(*Manager), err +} + +// ConfTest is a quorum call invoked on all nodes in configuration c, +// with the same argument in, and returns a combined result. +func (n *ReservedNode) ConfTest(ctx context.Context, in *Configuration) (resp *Manager, err error) { + cd := gorums.CallData{ + Message: in, + Method: "gorums.testprotos.failing.reservednames.Reserved.ConfTest", + } + + res, err := n.RawNode.RPCCall(ctx, cd) + if err != nil { + return nil, err + } + return res.(*Manager), err +} + +// Reserved is the server-side API for the Reserved Service +type ReservedServer interface { + ConfTest(ctx gorums.ServerCtx, request *Configuration) (response *Manager, err error) + QuorumCall(ctx gorums.ServerCtx, request *Configuration) (response *Manager, err error) +} + +func RegisterReservedServer(srv *gorums.Server, impl ReservedServer) { + srv.RegisterHandler("gorums.testprotos.failing.reservednames.Reserved.ConfTest", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*Configuration) + defer ctx.Release() + resp, err := impl.ConfTest(ctx, req) + gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) + }) + srv.RegisterHandler("gorums.testprotos.failing.reservednames.Reserved.QuorumCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*Configuration) + defer ctx.Release() + resp, err := impl.QuorumCall(ctx, req) + gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) + }) +} + +type internalManager struct { + nid uint32 + reply *Manager + err error +} diff --git a/rpc_test.go b/rpc_test.go index e5b70925..0ad52e11 100644 --- a/rpc_test.go +++ b/rpc_test.go @@ -103,8 +103,8 @@ func initServer() *gorums.Server { return srv } -func gorumsTestMgr() *dummy.Manager { - mgr := dummy.NewManager( +func gorumsTestMgr() *dummy.DummyManager { + mgr := dummy.NewDummyManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), ), diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index e4689985..88c6abcb 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -10,7 +10,6 @@ import ( context "context" fmt "fmt" gorums "github.com/relab/gorums" - encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) @@ -21,34 +20,39 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// ConfigTestClient is the client interface for the ConfigTest service. +type ConfigTestClient interface { + Config(ctx context.Context, in *Request) (resp *Response, err error) } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ ConfigTestClient = (*ConfigTestConfiguration)(nil) + +// A ConfigTestConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type ConfigTestConfiguration struct { + gorums.RawConfiguration + qspec ConfigTestQuorumSpec + nodes []*ConfigTestNode +} // ConfigTestQuorumSpecFromRaw returns a new ConfigTestQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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 { +func ConfigTestConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec ConfigTestQuorumSpec) (*ConfigTestConfiguration, error) { + // return an error if qspec is nil. + if qspec == nil { return nil, fmt.Errorf("config: missing required QuorumSpec") } - newCfg := &Configuration{ + newCfg := &ConfigTestConfiguration{ RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*ConfigTestNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &ConfigTestNode{n} } return newCfg, nil } @@ -57,113 +61,77 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *ConfigTestConfiguration) Nodes() []*ConfigTestNode { return c.nodes } // 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 ConfigTestConfiguration) And(d *ConfigTestConfiguration) 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 ConfigTestConfiguration) Except(rm *ConfigTestConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// ConfigTestManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type ConfigTestManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewConfigTestManager returns a new ConfigTestManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewConfigTestManager(opts ...gorums.ManagerOption) *ConfigTestManager { + return &ConfigTestManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewConfigTestConfiguration returns a ConfigTestConfiguration based on the provided list of nodes (required) +// and a quorum specification +// . // 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)) - } - 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) - } +func (m *ConfigTestManager) NewConfiguration(cfg gorums.NodeListOption, qspec ConfigTestQuorumSpec) (c *ConfigTestConfiguration, err error) { + c = &ConfigTestConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } - // 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") + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required ConfigTestQuorumSpec") } + c.qspec = qspec // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*ConfigTestNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &ConfigTestNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *ConfigTestManager) Nodes() []*ConfigTestNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*ConfigTestNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &ConfigTestNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// ConfigTestClient is the client interface for the ConfigTest service. -type ConfigTestClient interface { - Config(ctx context.Context, in *Request) (resp *Response, err error) -} - -// enforce interface compliance -var _ ConfigTestClient = (*Configuration)(nil) - // ConfigTestNode holds the node specific methods for the ConfigTest service. type ConfigTestNode struct { *gorums.RawNode } -// QuorumSpec is the interface of quorum functions for ConfigTest. -type QuorumSpec interface { +// ConfigTestQuorumSpec is the interface of quorum functions for ConfigTest. +type ConfigTestQuorumSpec interface { gorums.ConfigOption // ConfigQF is the quorum function for the Config @@ -176,7 +144,7 @@ type QuorumSpec interface { // 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) { +func (c *ConfigTestConfiguration) Config(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "config.ConfigTest.Config", diff --git a/tests/config/config_test.go b/tests/config/config_test.go index 6478c261..1c564925 100644 --- a/tests/config/config_test.go +++ b/tests/config/config_test.go @@ -45,7 +45,7 @@ func (q cfgQSpec) ConfigQF(_ *Request, replies map[uint32]*Response) (*Response, // setup returns a new configuration of cfgSize and a corresponding teardown function. // Calling setup multiple times will return a different configuration with different // sets of nodes. -func setup(t *testing.T, mgr *Manager, cfgSize int) (cfg *Configuration, teardown func()) { +func setup(t *testing.T, mgr *ConfigTestManager, cfgSize int) (cfg *ConfigTestConfiguration, teardown func()) { t.Helper() srvs := make([]*cfgSrv, cfgSize) for i := range srvs { @@ -59,7 +59,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), newQSpec(cfgSize)) if err != nil { t.Fatal(err) } @@ -73,7 +73,7 @@ func setup(t *testing.T, mgr *Manager, cfgSize int) (cfg *Configuration, teardow // 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) { + callRPC := func(cfg *ConfigTestConfiguration) { for i := 0; i < 5; i++ { resp, err := cfg.Config(context.Background(), &Request{Num: uint64(i)}) if err != nil { @@ -84,7 +84,7 @@ func TestConfig(t *testing.T) { } } } - mgr := NewManager( + mgr := NewConfigTestManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), ), @@ -101,8 +101,8 @@ func TestConfig(t *testing.T) { newNodeList := c1.And(c2) c3, err := mgr.NewConfiguration( - newQSpec(c1.Size()+c2.Size()), newNodeList, + newQSpec(c1.Size()+c2.Size()), ) if err != nil { t.Fatal(err) @@ -112,8 +112,8 @@ func TestConfig(t *testing.T) { rmNodeList := c3.Except(c1) c4, err := mgr.NewConfiguration( - newQSpec(c2.Size()), rmNodeList, + newQSpec(c2.Size()), ) if err != nil { t.Fatal(err) diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 553ce058..c9a75b12 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -11,7 +11,6 @@ import ( 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" ) @@ -23,34 +22,40 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// 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 } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ CorrectableTestClient = (*CorrectableTestConfiguration)(nil) + +// A CorrectableTestConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type CorrectableTestConfiguration struct { + gorums.RawConfiguration + qspec CorrectableTestQuorumSpec + nodes []*CorrectableTestNode +} // CorrectableTestQuorumSpecFromRaw returns a new CorrectableTestQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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 { +func CorrectableTestConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec CorrectableTestQuorumSpec) (*CorrectableTestConfiguration, error) { + // return an error if qspec is nil. + if qspec == nil { return nil, fmt.Errorf("config: missing required QuorumSpec") } - newCfg := &Configuration{ + newCfg := &CorrectableTestConfiguration{ RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*CorrectableTestNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &CorrectableTestNode{n} } return newCfg, nil } @@ -59,111 +64,25 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *CorrectableTestConfiguration) Nodes() []*CorrectableTestNode { return c.nodes } // 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 CorrectableTestConfiguration) And(d *CorrectableTestConfiguration) 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 CorrectableTestConfiguration) Except(rm *CorrectableTestConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on -// which quorum calls can be performed. -type Manager struct { - *gorums.RawManager -} - -// NewManager returns a new Manager for managing connection to nodes added -// to the manager. This function accepts manager options used to configure -// various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ - RawManager: gorums.NewRawManager(opts...), - } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. -// 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)) - } - 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") - } - // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} - } - return c, nil -} - -// Nodes returns a slice of available nodes on this manager. -// IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { - gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) - for i, n := range gorumsNodes { - nodes[i] = &Node{n} - } - return nodes -} - -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// 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 -} - -// 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 { +func (c *CorrectableTestConfiguration) Correctable(ctx context.Context, in *CorrectableRequest) *CorrectableCorrectableResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "correctable.CorrectableTest.Correctable", @@ -185,7 +104,7 @@ func (c *Configuration) Correctable(ctx context.Context, in *CorrectableRequest) // 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 { +func (c *CorrectableTestConfiguration) CorrectableStream(ctx context.Context, in *CorrectableRequest) *CorrectableStreamCorrectableResponse { cd := gorums.CorrectableCallData{ Message: in, Method: "correctable.CorrectableTest.CorrectableStream", @@ -203,13 +122,62 @@ func (c *Configuration) CorrectableStream(ctx context.Context, in *CorrectableRe return &CorrectableStreamCorrectableResponse{corr} } +// CorrectableTestManager maintains a connection pool of nodes on +// which quorum calls can be performed. +type CorrectableTestManager struct { + *gorums.RawManager +} + +// NewCorrectableTestManager returns a new CorrectableTestManager for managing connection to nodes added +// to the manager. This function accepts manager options used to configure +// various aspects of the manager. +func NewCorrectableTestManager(opts ...gorums.ManagerOption) *CorrectableTestManager { + return &CorrectableTestManager{ + RawManager: gorums.NewRawManager(opts...), + } +} // NewCorrectableTestConfiguration returns a CorrectableTestConfiguration based on the provided list of nodes (required) +// and a quorum specification +// . +// 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 *CorrectableTestManager) NewConfiguration(cfg gorums.NodeListOption, qspec CorrectableTestQuorumSpec) (c *CorrectableTestConfiguration, err error) { + c = &CorrectableTestConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err + } + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required CorrectableTestQuorumSpec") + } + c.qspec = qspec + // initialize the nodes slice + c.nodes = make([]*CorrectableTestNode, c.Size()) + for i, n := range c.RawConfiguration { + c.nodes[i] = &CorrectableTestNode{n} + } + return c, nil +} + +// Nodes returns a slice of available nodes on this manager. +// IDs are returned in the order they were added at creation of the manager. +func (m *CorrectableTestManager) Nodes() []*CorrectableTestNode { + gorumsNodes := m.RawManager.Nodes() + nodes := make([]*CorrectableTestNode, len(gorumsNodes)) + for i, n := range gorumsNodes { + nodes[i] = &CorrectableTestNode{n} + } + return nodes +} + // CorrectableTestNode holds the node specific methods for the CorrectableTest service. type CorrectableTestNode struct { *gorums.RawNode } -// QuorumSpec is the interface of quorum functions for CorrectableTest. -type QuorumSpec interface { +// CorrectableTestQuorumSpec is the interface of quorum functions for CorrectableTest. +type CorrectableTestQuorumSpec interface { gorums.ConfigOption // CorrectableQF is the quorum function for the Correctable diff --git a/tests/correctable/correctable_test.go b/tests/correctable/correctable_test.go index 62e7c7ba..051dbe95 100644 --- a/tests/correctable/correctable_test.go +++ b/tests/correctable/correctable_test.go @@ -14,7 +14,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, *CorrectableTestConfiguration) *gorums.Correctable) { addrs, teardown := gorums.TestSetup(t, n, func(i int) gorums.ServerIface { gorumsSrv := gorums.NewServer() RegisterCorrectableTestServer(gorumsSrv, &testSrv{n}) @@ -22,13 +22,13 @@ func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration }) defer teardown() - mgr := NewManager( + mgr := NewCorrectableTestManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), ), ) - cfg, err := mgr.NewConfiguration(qspec{div, n}, gorums.WithNodeList(addrs)) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(addrs), qspec{div, n}) if err != nil { t.Fatal(err) } @@ -55,14 +55,14 @@ func run(t *testing.T, n int, div int, corr func(context.Context, *Configuration } 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 *CorrectableTestConfiguration) *gorums.Correctable { corr := c.Correctable(ctx, &CorrectableRequest{}) return corr.Correctable }) } 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 *CorrectableTestConfiguration) *gorums.Correctable { corr := c.CorrectableStream(ctx, &CorrectableRequest{}) return corr.Correctable }) diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index e517855c..e756a305 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -8,9 +8,7 @@ package dummy import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" - encoding "google.golang.org/grpc/encoding" ) const ( @@ -20,34 +18,33 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// DummyNodeClient is the single node client interface for the Dummy service. +type DummyNodeClient interface { + Test(ctx context.Context, in *Empty) (resp *Empty, err error) } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ DummyNodeClient = (*DummyNode)(nil) + +// A DummyConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type DummyConfiguration struct { + gorums.RawConfiguration + nodes []*DummyNode +} // DummyQuorumSpecFromRaw returns a new DummyQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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") - } - newCfg := &Configuration{ +func DummyConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*DummyConfiguration, error) { + newCfg := &DummyConfiguration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*DummyNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &DummyNode{n} } return newCfg, nil } @@ -56,114 +53,69 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *DummyConfiguration) Nodes() []*DummyNode { return c.nodes } // 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 DummyConfiguration) And(d *DummyConfiguration) 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 DummyConfiguration) Except(rm *DummyConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// DummyManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type DummyManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewDummyManager returns a new DummyManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewDummyManager(opts ...gorums.ManagerOption) *DummyManager { + return &DummyManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewDummyConfiguration returns a DummyConfiguration based on the provided list of nodes (required) +// . // 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)) - } - 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") +func (m *DummyManager) NewConfiguration(cfg gorums.NodeListOption) (c *DummyConfiguration, err error) { + c = &DummyConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*DummyNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &DummyNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *DummyManager) Nodes() []*DummyNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*DummyNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &DummyNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// DummyNodeClient is the single node client interface for the Dummy service. -type DummyNodeClient interface { - Test(ctx context.Context, in *Empty) (resp *Empty, err error) -} - -// enforce interface compliance -var _ DummyNodeClient = (*DummyNode)(nil) - // DummyNode holds the node specific methods for the Dummy service. type DummyNode struct { *gorums.RawNode } -// 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. func (n *DummyNode) Test(ctx context.Context, in *Empty) (resp *Empty, err error) { diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index a2d108bf..f81013e9 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -8,9 +8,7 @@ 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" ) @@ -21,34 +19,34 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// MetadataTestNodeClient is the single node client interface for the MetadataTest service. +type MetadataTestNodeClient interface { + IDFromMD(ctx context.Context, in *emptypb.Empty) (resp *NodeID, err error) + WhatIP(ctx context.Context, in *emptypb.Empty) (resp *IPAddr, err error) } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ MetadataTestNodeClient = (*MetadataTestNode)(nil) + +// A MetadataTestConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type MetadataTestConfiguration struct { + gorums.RawConfiguration + nodes []*MetadataTestNode +} // MetadataTestQuorumSpecFromRaw returns a new MetadataTestQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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") - } - newCfg := &Configuration{ +func MetadataTestConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*MetadataTestConfiguration, error) { + newCfg := &MetadataTestConfiguration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*MetadataTestNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &MetadataTestNode{n} } return newCfg, nil } @@ -57,115 +55,69 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *MetadataTestConfiguration) Nodes() []*MetadataTestNode { return c.nodes } // 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 MetadataTestConfiguration) And(d *MetadataTestConfiguration) 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 MetadataTestConfiguration) Except(rm *MetadataTestConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// MetadataTestManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type MetadataTestManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewMetadataTestManager returns a new MetadataTestManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewMetadataTestManager(opts ...gorums.ManagerOption) *MetadataTestManager { + return &MetadataTestManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewMetadataTestConfiguration returns a MetadataTestConfiguration based on the provided list of nodes (required) +// . // 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)) - } - 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") +func (m *MetadataTestManager) NewConfiguration(cfg gorums.NodeListOption) (c *MetadataTestConfiguration, err error) { + c = &MetadataTestConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*MetadataTestNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &MetadataTestNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *MetadataTestManager) Nodes() []*MetadataTestNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*MetadataTestNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &MetadataTestNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// MetadataTestNodeClient is the single node client interface for the MetadataTest service. -type MetadataTestNodeClient interface { - IDFromMD(ctx context.Context, in *emptypb.Empty) (resp *NodeID, err error) - WhatIP(ctx context.Context, in *emptypb.Empty) (resp *IPAddr, err error) -} - -// enforce interface compliance -var _ MetadataTestNodeClient = (*MetadataTestNode)(nil) - // MetadataTestNode holds the node specific methods for the MetadataTest service. type MetadataTestNode struct { *gorums.RawNode } -// There are no quorum calls. -type QuorumSpec interface{} - // IDFromMD returns the 'id' field from the metadata. func (n *MetadataTestNode) 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 0a2454ed..726dadcf 100644 --- a/tests/metadata/metadata_test.go +++ b/tests/metadata/metadata_test.go @@ -58,7 +58,7 @@ func TestMetadata(t *testing.T) { "id": fmt.Sprint(want), }) - mgr := NewManager( + mgr := NewMetadataTestManager( gorums.WithMetadata(md), gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), @@ -90,7 +90,7 @@ func TestPerNodeMetadata(t *testing.T) { }) } - mgr := NewManager( + mgr := NewMetadataTestManager( gorums.WithPerNodeMetadata(perNodeMD), gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), @@ -117,7 +117,7 @@ func TestCanGetPeerInfo(t *testing.T) { addrs, teardown := gorums.TestSetup(t, 1, func(_ int) gorums.ServerIface { return initServer(t) }) defer teardown() - mgr := NewManager( + mgr := NewMetadataTestManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), ), diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index f1ac0cb9..94a2b653 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -8,9 +8,7 @@ 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" ) @@ -21,34 +19,42 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// OnewayTestClient is the client interface for the OnewayTest service. +type OnewayTestClient interface { + Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) + MulticastPerNode(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) +} + +// enforce interface compliance +var _ OnewayTestClient = (*OnewayTestConfiguration)(nil) + +// OnewayTestNodeClient is the single node client interface for the OnewayTest service. +type OnewayTestNodeClient interface { + Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ OnewayTestNodeClient = (*OnewayTestNode)(nil) + +// A OnewayTestConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type OnewayTestConfiguration struct { + gorums.RawConfiguration + nodes []*OnewayTestNode +} // OnewayTestQuorumSpecFromRaw returns a new OnewayTestQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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") - } - newCfg := &Configuration{ +func OnewayTestConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*OnewayTestConfiguration, error) { + newCfg := &OnewayTestConfiguration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*OnewayTestNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &OnewayTestNode{n} } return newCfg, nil } @@ -57,118 +63,67 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *OnewayTestConfiguration) Nodes() []*OnewayTestNode { return c.nodes } // 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 OnewayTestConfiguration) And(d *OnewayTestConfiguration) 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 OnewayTestConfiguration) Except(rm *OnewayTestConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// OnewayTestManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type OnewayTestManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewOnewayTestManager returns a new OnewayTestManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewOnewayTestManager(opts ...gorums.ManagerOption) *OnewayTestManager { + return &OnewayTestManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewOnewayTestConfiguration returns a OnewayTestConfiguration based on the provided list of nodes (required) +// . // 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)) - } - 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") +func (m *OnewayTestManager) NewConfiguration(cfg gorums.NodeListOption) (c *OnewayTestConfiguration, err error) { + c = &OnewayTestConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*OnewayTestNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &OnewayTestNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *OnewayTestManager) Nodes() []*OnewayTestNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*OnewayTestNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &OnewayTestNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// OnewayTestClient is the client interface for the OnewayTest service. -type OnewayTestClient interface { - Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) - MulticastPerNode(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) -} - -// enforce interface compliance -var _ OnewayTestClient = (*Configuration)(nil) - -// OnewayTestNodeClient is the single node client interface for the OnewayTest service. -type OnewayTestNodeClient interface { - Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) -} - -// enforce interface compliance -var _ OnewayTestNodeClient = (*OnewayTestNode)(nil) - // Multicast is a quorum call invoked on all nodes in configuration c, // with the same argument in, and returns a combined result. -func (c *Configuration) Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { +func (c *OnewayTestConfiguration) Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "oneway.OnewayTest.Multicast", @@ -182,7 +137,7 @@ func (c *Configuration) Multicast(ctx context.Context, in *Request, opts ...goru // 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. -func (c *Configuration) MulticastPerNode(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) { +func (c *OnewayTestConfiguration) MulticastPerNode(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "oneway.OnewayTest.MulticastPerNode", @@ -200,9 +155,6 @@ type OnewayTestNode struct { *gorums.RawNode } -// 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) @@ -228,8 +180,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. +// Unicast is a one-way call; no replies are processed. func (n *OnewayTestNode) 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 0f5d88d8..20f0700e 100644 --- a/tests/oneway/oneway_test.go +++ b/tests/oneway/oneway_test.go @@ -44,7 +44,7 @@ func (s *onewaySrv) MulticastPerNode(ctx gorums.ServerCtx, r *oneway.Request) { type testQSpec struct{} -func setup(t testing.TB, cfgSize int) (cfg *oneway.Configuration, srvs []*onewaySrv, teardown func()) { +func setup(t testing.TB, cfgSize int) (cfg *oneway.OnewayTestConfiguration, srvs []*onewaySrv, teardown func()) { t.Helper() srvs = make([]*onewaySrv, cfgSize) for i := 0; i < cfgSize; i++ { @@ -61,12 +61,12 @@ func setup(t testing.TB, cfgSize int) (cfg *oneway.Configuration, srvs []*oneway nodeMap[addr] = uint32(i) } - mgr := oneway.NewManager( + mgr := oneway.NewOnewayTestManager( gorums.WithGrpcDialOptions( 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) } @@ -96,7 +96,7 @@ func TestOnewayCalls(t *testing.T) { {name: "MulticastNoSendWaiting", calls: numCalls, servers: 9, sendWait: false}, } - f := func(c *oneway.Configuration) func(context.Context, *oneway.Request, ...gorums.CallOption) { + f := func(c *oneway.OnewayTestConfiguration) func(context.Context, *oneway.Request, ...gorums.CallOption) { if c.Size() == 1 { return c.Nodes()[0].Unicast } diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index 5afde699..029db6a1 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -10,7 +10,6 @@ import ( context "context" fmt "fmt" gorums "github.com/relab/gorums" - encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) @@ -21,34 +20,68 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// 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 *GorumsTestConfiguration) 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} } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// 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 +} + +// enforce interface compliance +var _ GorumsTestClient = (*GorumsTestConfiguration)(nil) + +// GorumsTestNodeClient is the single node client interface for the GorumsTest service. +type GorumsTestNodeClient interface { + UnaryRPC(ctx context.Context, in *Request) (resp *Response, err error) +} + +// enforce interface compliance +var _ GorumsTestNodeClient = (*GorumsTestNode)(nil) + +// A GorumsTestConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type GorumsTestConfiguration struct { + gorums.RawConfiguration + qspec GorumsTestQuorumSpec + nodes []*GorumsTestNode +} // GorumsTestQuorumSpecFromRaw returns a new GorumsTestQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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 { +func GorumsTestConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec GorumsTestQuorumSpec) (*GorumsTestConfiguration, error) { + // return an error if qspec is nil. + if qspec == nil { return nil, fmt.Errorf("config: missing required QuorumSpec") } - newCfg := &Configuration{ + newCfg := &GorumsTestConfiguration{ RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*GorumsTestNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &GorumsTestNode{n} } return newCfg, nil } @@ -57,142 +90,77 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *GorumsTestConfiguration) Nodes() []*GorumsTestNode { return c.nodes } // 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 GorumsTestConfiguration) And(d *GorumsTestConfiguration) 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 GorumsTestConfiguration) Except(rm *GorumsTestConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// GorumsTestManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type GorumsTestManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewGorumsTestManager returns a new GorumsTestManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewGorumsTestManager(opts ...gorums.ManagerOption) *GorumsTestManager { + return &GorumsTestManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewGorumsTestConfiguration returns a GorumsTestConfiguration based on the provided list of nodes (required) +// and a quorum specification +// . // 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)) - } - 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) - } +func (m *GorumsTestManager) NewConfiguration(cfg gorums.NodeListOption, qspec GorumsTestQuorumSpec) (c *GorumsTestConfiguration, err error) { + c = &GorumsTestConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } - // 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") + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required GorumsTestQuorumSpec") } + c.qspec = qspec // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*GorumsTestNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &GorumsTestNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *GorumsTestManager) Nodes() []*GorumsTestNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*GorumsTestNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &GorumsTestNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -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 -} - -// enforce interface compliance -var _ GorumsTestClient = (*Configuration)(nil) - -// GorumsTestNodeClient is the single node client interface for the GorumsTest service. -type GorumsTestNodeClient interface { - UnaryRPC(ctx context.Context, in *Request) (resp *Response, err error) -} - -// enforce interface compliance -var _ GorumsTestNodeClient = (*GorumsTestNode)(nil) - // GorumsTestNode holds the node specific methods for the GorumsTest service. type GorumsTestNode struct { *gorums.RawNode } -// QuorumSpec is the interface of quorum functions for GorumsTest. -type QuorumSpec interface { +// GorumsTestQuorumSpec is the interface of quorum functions for GorumsTest. +type GorumsTestQuorumSpec interface { gorums.ConfigOption // QCQF is the quorum function for the QC @@ -212,7 +180,7 @@ type QuorumSpec interface { // 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) { +func (c *GorumsTestConfiguration) QC(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "ordering.GorumsTest.QC", diff --git a/tests/ordering/order_test.go b/tests/ordering/order_test.go index e1de05bc..47439112 100644 --- a/tests/ordering/order_test.go +++ b/tests/ordering/order_test.go @@ -79,19 +79,19 @@ func (q testQSpec) AsyncHandlerQF(_ *Request, replies map[uint32]*Response) (*Re return q.qf(replies) } -func setup(t *testing.T, cfgSize int) (cfg *Configuration, teardown func()) { +func setup(t *testing.T, cfgSize int) (cfg *GorumsTestConfiguration, teardown func()) { t.Helper() addrs, closeServers := gorums.TestSetup(t, cfgSize, func(_ int) gorums.ServerIface { srv := gorums.NewServer() RegisterGorumsTestServer(srv, &testSrv{}) return srv }) - mgr := NewManager( + mgr := NewGorumsTestManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), ), ) - cfg, err := mgr.NewConfiguration(&testQSpec{cfgSize}, gorums.WithNodeList(addrs)) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(addrs), &testQSpec{cfgSize}) if err != nil { t.Fatal(err) } @@ -204,7 +204,7 @@ func TestMixedOrdering(t *testing.T) { var wg sync.WaitGroup wg.Add(len(nodes)) for _, node := range nodes { - go func(node *Node) { + go func(node *GorumsTestNode) { defer wg.Done() resp, err := node.UnaryRPC(context.Background(), &Request{Num: uint64(i)}) if err != nil { diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 90899b05..1e68a7e5 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -10,7 +10,6 @@ import ( context "context" fmt "fmt" gorums "github.com/relab/gorums" - encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) @@ -21,34 +20,40 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// 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) } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ QuorumFunctionClient = (*QuorumFunctionConfiguration)(nil) + +// A QuorumFunctionConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type QuorumFunctionConfiguration struct { + gorums.RawConfiguration + qspec QuorumFunctionQuorumSpec + nodes []*QuorumFunctionNode +} // QuorumFunctionQuorumSpecFromRaw returns a new QuorumFunctionQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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 { +func QuorumFunctionConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumFunctionQuorumSpec) (*QuorumFunctionConfiguration, error) { + // return an error if qspec is nil. + if qspec == nil { return nil, fmt.Errorf("config: missing required QuorumSpec") } - newCfg := &Configuration{ + newCfg := &QuorumFunctionConfiguration{ RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*QuorumFunctionNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &QuorumFunctionNode{n} } return newCfg, nil } @@ -57,114 +62,77 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *QuorumFunctionConfiguration) Nodes() []*QuorumFunctionNode { return c.nodes } // 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 QuorumFunctionConfiguration) And(d *QuorumFunctionConfiguration) 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 QuorumFunctionConfiguration) Except(rm *QuorumFunctionConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// QuorumFunctionManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type QuorumFunctionManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewQuorumFunctionManager returns a new QuorumFunctionManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewQuorumFunctionManager(opts ...gorums.ManagerOption) *QuorumFunctionManager { + return &QuorumFunctionManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewQuorumFunctionConfiguration returns a QuorumFunctionConfiguration based on the provided list of nodes (required) +// and a quorum specification +// . // 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)) - } - 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) - } +func (m *QuorumFunctionManager) NewConfiguration(cfg gorums.NodeListOption, qspec QuorumFunctionQuorumSpec) (c *QuorumFunctionConfiguration, err error) { + c = &QuorumFunctionConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } - // 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") + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required QuorumFunctionQuorumSpec") } + c.qspec = qspec // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*QuorumFunctionNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &QuorumFunctionNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *QuorumFunctionManager) Nodes() []*QuorumFunctionNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*QuorumFunctionNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &QuorumFunctionNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// 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) -} - -// enforce interface compliance -var _ QuorumFunctionClient = (*Configuration)(nil) - // QuorumFunctionNode holds the node specific methods for the QuorumFunction service. type QuorumFunctionNode struct { *gorums.RawNode } -// QuorumSpec is the interface of quorum functions for QuorumFunction. -type QuorumSpec interface { +// QuorumFunctionQuorumSpec is the interface of quorum functions for QuorumFunction. +type QuorumFunctionQuorumSpec interface { gorums.ConfigOption // UseReqQF is the quorum function for the UseReq @@ -184,7 +152,7 @@ type QuorumSpec interface { // 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) { +func (c *QuorumFunctionConfiguration) UseReq(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "qf.QuorumFunction.UseReq", @@ -206,7 +174,7 @@ func (c *Configuration) UseReq(ctx context.Context, in *Request) (resp *Response // 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) { +func (c *QuorumFunctionConfiguration) IgnoreReq(ctx context.Context, in *Request) (resp *Response, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "qf.QuorumFunction.IgnoreReq", diff --git a/tests/qf/qf_test.go b/tests/qf/qf_test.go index 99c76030..d0ab9380 100644 --- a/tests/qf/qf_test.go +++ b/tests/qf/qf_test.go @@ -194,14 +194,14 @@ func BenchmarkFullStackQF(b *testing.B) { RegisterQuorumFunctionServer(srv, &testSrv{}) return srv }) - mgr := NewManager( + mgr := NewQuorumFunctionManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), ), ) 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 + &testQSpec{quorum: n / 2}, ) if err != nil { b.Fatal(err) diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 1adac2df..f05bdd17 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -8,9 +8,7 @@ package tls import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" - encoding "google.golang.org/grpc/encoding" ) const ( @@ -20,34 +18,33 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// TLSNodeClient is the single node client interface for the TLS service. +type TLSNodeClient interface { + TestTLS(ctx context.Context, in *Request) (resp *Response, err error) } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ TLSNodeClient = (*TLSNode)(nil) + +// A TLSConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type TLSConfiguration struct { + gorums.RawConfiguration + nodes []*TLSNode +} // TLSQuorumSpecFromRaw returns a new TLSQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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") - } - newCfg := &Configuration{ +func TLSConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*TLSConfiguration, error) { + newCfg := &TLSConfiguration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*TLSNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &TLSNode{n} } return newCfg, nil } @@ -56,114 +53,69 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *TLSConfiguration) Nodes() []*TLSNode { return c.nodes } // 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 TLSConfiguration) And(d *TLSConfiguration) 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 TLSConfiguration) Except(rm *TLSConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// TLSManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type TLSManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewTLSManager returns a new TLSManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewTLSManager(opts ...gorums.ManagerOption) *TLSManager { + return &TLSManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewTLSConfiguration returns a TLSConfiguration based on the provided list of nodes (required) +// . // 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)) - } - 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") +func (m *TLSManager) NewConfiguration(cfg gorums.NodeListOption) (c *TLSConfiguration, err error) { + c = &TLSConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*TLSNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &TLSNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *TLSManager) Nodes() []*TLSNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*TLSNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &TLSNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// TLSNodeClient is the single node client interface for the TLS service. -type TLSNodeClient interface { - TestTLS(ctx context.Context, in *Request) (resp *Response, err error) -} - -// enforce interface compliance -var _ TLSNodeClient = (*TLSNode)(nil) - // TLSNode holds the node specific methods for the TLS service. type TLSNode struct { *gorums.RawNode } -// 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. func (n *TLSNode) TestTLS(ctx context.Context, in *Request) (resp *Response, err error) { diff --git a/tests/tls/tls_test.go b/tests/tls/tls_test.go index 5cf8b4cc..b1475f3a 100644 --- a/tests/tls/tls_test.go +++ b/tests/tls/tls_test.go @@ -45,7 +45,7 @@ func TestTLS(t *testing.T) { }) defer teardown() - mgr := NewManager( + mgr := NewTLSManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(cp, "")), ), diff --git a/tests/unresponsive/unreponsive_test.go b/tests/unresponsive/unreponsive_test.go index 9c93a4a1..63b349d7 100644 --- a/tests/unresponsive/unreponsive_test.go +++ b/tests/unresponsive/unreponsive_test.go @@ -28,7 +28,7 @@ func TestUnresponsive(t *testing.T) { }) defer teardown() - mgr := NewManager( + mgr := NewUnresponsiveManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), ), diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index 53b27ba6..cb6d013d 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -8,9 +8,7 @@ package unresponsive import ( context "context" - fmt "fmt" gorums "github.com/relab/gorums" - encoding "google.golang.org/grpc/encoding" ) const ( @@ -20,34 +18,33 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +// UnresponsiveNodeClient is the single node client interface for the Unresponsive service. +type UnresponsiveNodeClient interface { + TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ UnresponsiveNodeClient = (*UnresponsiveNode)(nil) + +// A UnresponsiveConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type UnresponsiveConfiguration struct { + gorums.RawConfiguration + nodes []*UnresponsiveNode +} // UnresponsiveQuorumSpecFromRaw returns a new UnresponsiveQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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") - } - newCfg := &Configuration{ +func UnresponsiveConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*UnresponsiveConfiguration, error) { + newCfg := &UnresponsiveConfiguration{ RawConfiguration: rawCfg, - qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*UnresponsiveNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &UnresponsiveNode{n} } return newCfg, nil } @@ -56,114 +53,69 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *UnresponsiveConfiguration) Nodes() []*UnresponsiveNode { return c.nodes } // 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 UnresponsiveConfiguration) And(d *UnresponsiveConfiguration) 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 UnresponsiveConfiguration) Except(rm *UnresponsiveConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// UnresponsiveManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type UnresponsiveManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewUnresponsiveManager returns a new UnresponsiveManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewUnresponsiveManager(opts ...gorums.ManagerOption) *UnresponsiveManager { + return &UnresponsiveManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewUnresponsiveConfiguration returns a UnresponsiveConfiguration based on the provided list of nodes (required) +// . // 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)) - } - 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") +func (m *UnresponsiveManager) NewConfiguration(cfg gorums.NodeListOption) (c *UnresponsiveConfiguration, err error) { + c = &UnresponsiveConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*UnresponsiveNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &UnresponsiveNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *UnresponsiveManager) Nodes() []*UnresponsiveNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*UnresponsiveNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &UnresponsiveNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// UnresponsiveNodeClient is the single node client interface for the Unresponsive service. -type UnresponsiveNodeClient interface { - TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) -} - -// enforce interface compliance -var _ UnresponsiveNodeClient = (*UnresponsiveNode)(nil) - // UnresponsiveNode holds the node specific methods for the Unresponsive service. type UnresponsiveNode struct { *gorums.RawNode } -// 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. func (n *UnresponsiveNode) TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) { From dea40601a4e99aa6185618add2cb6755a0ac9622 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Mon, 24 Mar 2025 16:47:47 +0100 Subject: [PATCH 04/11] fix tests except for TestFailingProtoFiles --- benchmark/benchmark_gorums.pb.go | 7 +++++++ channel.go | 1 + cmd/protoc-gen-gorums/dev/mgr.go | 12 ++++++++++++ cmd/protoc-gen-gorums/gengorums/template_static.go | 10 ++++++++-- .../failing/reservednames/reserved_gorums.pb.go | 7 +++++++ tests/config/config_gorums.pb.go | 7 +++++++ tests/correctable/correctable_gorums.pb.go | 7 +++++++ tests/dummy/dummy_gorums.pb.go | 7 +++++++ tests/metadata/metadata_gorums.pb.go | 7 +++++++ tests/oneway/oneway_gorums.pb.go | 7 +++++++ tests/ordering/order_gorums.pb.go | 7 +++++++ tests/qf/qf_gorums.pb.go | 7 +++++++ tests/tls/tls_gorums.pb.go | 7 +++++++ tests/unresponsive/unresponsive_gorums.pb.go | 7 +++++++ 14 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 cmd/protoc-gen-gorums/dev/mgr.go diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index fa2d7443..69d21dfc 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -10,6 +10,7 @@ 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" ) @@ -21,6 +22,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // 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. diff --git a/channel.go b/channel.go index 5edf8871..96aec131 100644 --- a/channel.go +++ b/channel.go @@ -99,6 +99,7 @@ func (c *channel) newNodeStream(conn *grpc.ClientConn) error { c.gorumsStream, err = c.gorumsClient.NodeStream(c.streamCtx) c.streamMut.Unlock() if err != nil { + fmt.Println("oops " + err.Error()) return err } c.streamBroken.clear() diff --git a/cmd/protoc-gen-gorums/dev/mgr.go b/cmd/protoc-gen-gorums/dev/mgr.go new file mode 100644 index 00000000..758c12e4 --- /dev/null +++ b/cmd/protoc-gen-gorums/dev/mgr.go @@ -0,0 +1,12 @@ +package dev + +import ( + "github.com/relab/gorums" + "google.golang.org/grpc/encoding" +) + +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} diff --git a/cmd/protoc-gen-gorums/gengorums/template_static.go b/cmd/protoc-gen-gorums/gengorums/template_static.go index 4143fcf2..f60996f9 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_static.go +++ b/cmd/protoc-gen-gorums/gengorums/template_static.go @@ -5,10 +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{} +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(nil) -var staticCode = `` +var staticCode = `func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + +` diff --git a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go index 66807552..dd265a47 100644 --- a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go +++ b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go @@ -10,6 +10,7 @@ import ( context "context" fmt "fmt" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) @@ -20,6 +21,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // ReservedClient is the client interface for the Reserved service. type ReservedClient interface { QuorumCall(ctx context.Context, in *Configuration) (resp *Manager, err error) diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index 88c6abcb..30763d70 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -10,6 +10,7 @@ import ( context "context" fmt "fmt" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) @@ -20,6 +21,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // ConfigTestClient is the client interface for the ConfigTest service. type ConfigTestClient interface { Config(ctx context.Context, in *Request) (resp *Response, err error) diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index c9a75b12..fe60ea01 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -11,6 +11,7 @@ import ( 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" ) @@ -22,6 +23,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // CorrectableTestClient is the client interface for the CorrectableTest service. type CorrectableTestClient interface { Correctable(ctx context.Context, in *CorrectableRequest) *CorrectableCorrectableResponse diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index e756a305..ee2dccd2 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -9,6 +9,7 @@ package dummy import ( context "context" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" ) const ( @@ -18,6 +19,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // DummyNodeClient is the single node client interface for the Dummy service. type DummyNodeClient interface { Test(ctx context.Context, in *Empty) (resp *Empty, err error) diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index f81013e9..823ed257 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -9,6 +9,7 @@ package metadata import ( context "context" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -19,6 +20,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // MetadataTestNodeClient is the single node client interface for the MetadataTest service. type MetadataTestNodeClient interface { IDFromMD(ctx context.Context, in *emptypb.Empty) (resp *NodeID, err error) diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index 94a2b653..281f5152 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -9,6 +9,7 @@ package oneway import ( context "context" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) @@ -19,6 +20,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // OnewayTestClient is the client interface for the OnewayTest service. type OnewayTestClient interface { Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index 029db6a1..fb39ef40 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -10,6 +10,7 @@ import ( context "context" fmt "fmt" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) @@ -20,6 +21,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // 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. diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 1e68a7e5..df1d16e1 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -10,6 +10,7 @@ import ( context "context" fmt "fmt" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) @@ -20,6 +21,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // QuorumFunctionClient is the client interface for the QuorumFunction service. type QuorumFunctionClient interface { UseReq(ctx context.Context, in *Request) (resp *Response, err error) diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index f05bdd17..7633f1c8 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -9,6 +9,7 @@ package tls import ( context "context" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" ) const ( @@ -18,6 +19,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // TLSNodeClient is the single node client interface for the TLS service. type TLSNodeClient interface { TestTLS(ctx context.Context, in *Request) (resp *Response, err error) diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index cb6d013d..178be4c6 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -9,6 +9,7 @@ package unresponsive import ( context "context" gorums "github.com/relab/gorums" + encoding "google.golang.org/grpc/encoding" ) const ( @@ -18,6 +19,12 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + // UnresponsiveNodeClient is the single node client interface for the Unresponsive service. type UnresponsiveNodeClient interface { TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) From e900f0f57e33954b9ee73acc4a87cb4e7259156a Mon Sep 17 00:00:00 2001 From: asbjorn Date: Wed, 26 Mar 2025 11:38:45 +0100 Subject: [PATCH 05/11] update the storage example --- examples/go.mod | 2 +- examples/storage/client.go | 4 +- examples/storage/proto/storage.pb.go | 2 +- examples/storage/proto/storage.proto | 21 +++ examples/storage/proto/storage_gorums.pb.go | 168 +++++++++----------- examples/storage/repl.go | 22 +-- 6 files changed, 110 insertions(+), 109 deletions(-) diff --git a/examples/go.mod b/examples/go.mod index 8fbd6a23..61dc9131 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -4,7 +4,7 @@ go 1.22.1 require ( github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 - github.com/relab/gorums v0.7.0 + github.com/relab/gorums v0.0.0-00010101000000-000000000000 golang.org/x/term v0.28.0 google.golang.org/grpc v1.69.4 google.golang.org/protobuf v1.36.3 diff --git a/examples/storage/client.go b/examples/storage/client.go index cde90ebf..9960d361 100644 --- a/examples/storage/client.go +++ b/examples/storage/client.go @@ -15,13 +15,13 @@ func runClient(addresses []string) error { } // init gorums manager - mgr := proto.NewManager( + mgr := proto.NewStorageManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), // disable TLS ), ) // create configuration containing all nodes - cfg, err := mgr.NewConfiguration(&qspec{cfgSize: len(addresses)}, gorums.WithNodeList(addresses)) + cfg, err := mgr.NewConfiguration(gorums.WithNodeList(addresses), &qspec{cfgSize: len(addresses)}) if err != nil { log.Fatal(err) } diff --git a/examples/storage/proto/storage.pb.go b/examples/storage/proto/storage.pb.go index 7f5da688..3e4cc623 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.3 -// protoc v5.29.3 +// protoc v5.29.2 // source: storage/proto/storage.proto package proto diff --git a/examples/storage/proto/storage.proto b/examples/storage/proto/storage.proto index e96c9a62..580ed153 100644 --- a/examples/storage/proto/storage.proto +++ b/examples/storage/proto/storage.proto @@ -31,6 +31,27 @@ service Storage { } } +service Storage2 { + // ReadRPC executes the Read RPC on a single Node + rpc ReadRPC(ReadRequest) returns (ReadResponse) {} + // WriteRPC executes the Write RPC on a single Node + rpc WriteRPC(WriteRequest) returns (WriteResponse) {} + // ReadQC executes the Read Quorum Call on a configuration + // of Nodes and returns the most recent value. + rpc ReadQC(ReadRequest) returns (ReadResponse) { + option (gorums.quorumcall) = true; + } + // WriteQC executes the Write Quorum Call on a configuration + // of Nodes and returns true if a majority of Nodes were updated. + rpc WriteQC(WriteRequest) returns (WriteResponse) { + option (gorums.quorumcall) = true; + } + + rpc WriteMulticast(WriteRequest) returns (google.protobuf.Empty) { + option (gorums.multicast) = true; + } +} + message ReadRequest { string Key = 1; } message ReadResponse { diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index 2c7bd18a..ce7ce1f7 100644 --- a/examples/storage/proto/storage_gorums.pb.go +++ b/examples/storage/proto/storage_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.3 +// protoc v5.29.2 // source: storage/proto/storage.proto package proto @@ -22,34 +22,56 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 8) ) -// 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 +func init() { + if encoding.GetCodec(gorums.ContentSubtype) == nil { + encoding.RegisterCodec(gorums.NewCodec()) + } +} + +// 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) + WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) } -// ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec. +// enforce interface compliance +var _ StorageClient = (*StorageConfiguration)(nil) + +// StorageNodeClient is the single node client interface for the Storage service. +type StorageNodeClient interface { + ReadRPC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error) + WriteRPC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error) +} + +// enforce interface compliance +var _ StorageNodeClient = (*StorageNode)(nil) + +// A StorageConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type StorageConfiguration struct { + gorums.RawConfiguration + qspec StorageQuorumSpec + nodes []*StorageNode +} // StorageQuorumSpecFromRaw returns a new StorageQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // // 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 { +func StorageConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec StorageQuorumSpec) (*StorageConfiguration, error) { + // return an error if qspec is nil. + if qspec == nil { return nil, fmt.Errorf("config: missing required QuorumSpec") } - newCfg := &Configuration{ + newCfg := &StorageConfiguration{ RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, newCfg.Size()) + newCfg.nodes = make([]*StorageNode, newCfg.Size()) for i, n := range rawCfg { - newCfg.nodes[i] = &Node{n} + newCfg.nodes[i] = &StorageNode{n} } return newCfg, nil } @@ -58,123 +80,76 @@ func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Co // 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 *StorageConfiguration) Nodes() []*StorageNode { return c.nodes } // 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 StorageConfiguration) And(d *StorageConfiguration) 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 StorageConfiguration) Except(rm *StorageConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// Manager maintains a connection pool of nodes on +// StorageManager maintains a connection pool of nodes on // which quorum calls can be performed. -type Manager struct { +type StorageManager struct { *gorums.RawManager } -// NewManager returns a new Manager for managing connection to nodes added +// NewStorageManager returns a new StorageManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. -func NewManager(opts ...gorums.ManagerOption) *Manager { - return &Manager{ +func NewStorageManager(opts ...gorums.ManagerOption) *StorageManager { + return &StorageManager{ RawManager: gorums.NewRawManager(opts...), } -} - -// NewConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. +} // NewStorageConfiguration returns a StorageConfiguration based on the provided list of nodes (required) +// and a quorum specification +// . // 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)) - } - 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) - } +func (m *StorageManager) NewConfiguration(cfg gorums.NodeListOption, qspec StorageQuorumSpec) (c *StorageConfiguration, err error) { + c = &StorageConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err } - // 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") + // return an error if qspec is nil. + if qspec == nil { + return nil, fmt.Errorf("config: missing required StorageQuorumSpec") } + c.qspec = qspec // initialize the nodes slice - c.nodes = make([]*Node, c.Size()) + c.nodes = make([]*StorageNode, c.Size()) for i, n := range c.RawConfiguration { - c.nodes[i] = &Node{n} + c.nodes[i] = &StorageNode{n} } return c, nil } // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. -func (m *Manager) Nodes() []*Node { +func (m *StorageManager) Nodes() []*StorageNode { gorumsNodes := m.RawManager.Nodes() - nodes := make([]*Node, len(gorumsNodes)) + nodes := make([]*StorageNode, len(gorumsNodes)) for i, n := range gorumsNodes { - nodes[i] = &Node{n} + nodes[i] = &StorageNode{n} } return nodes } -// Node encapsulates the state of a node on which a remote procedure call -// can be performed. -type Node struct { - *gorums.RawNode -} - -// 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) - WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) -} - -// enforce interface compliance -var _ StorageClient = (*Configuration)(nil) - -// StorageNodeClient is the single node client interface for the Storage service. -type StorageNodeClient interface { - ReadRPC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error) - WriteRPC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error) -} - -// enforce interface compliance -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. -func (c *Configuration) WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) { +func (c *StorageConfiguration) WriteMulticast(ctx context.Context, in *WriteRequest, opts ...gorums.CallOption) { cd := gorums.QuorumCallData{ Message: in, Method: "storage.Storage.WriteMulticast", @@ -183,8 +158,13 @@ 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 { +// StorageNode holds the node specific methods for the Storage service. +type StorageNode struct { + *gorums.RawNode +} + +// StorageQuorumSpec is the interface of quorum functions for Storage. +type StorageQuorumSpec interface { gorums.ConfigOption // ReadQCQF is the quorum function for the ReadQC @@ -204,7 +184,7 @@ type QuorumSpec interface { // 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 *StorageConfiguration) ReadQC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "storage.Storage.ReadQC", @@ -226,7 +206,7 @@ func (c *Configuration) ReadQC(ctx context.Context, in *ReadRequest) (resp *Read // 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 *StorageConfiguration) WriteQC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error) { cd := gorums.QuorumCallData{ Message: in, Method: "storage.Storage.WriteQC", @@ -247,7 +227,7 @@ func (c *Configuration) WriteQC(ctx context.Context, in *WriteRequest) (resp *Wr } // ReadRPC executes the Read RPC on a single Node -func (n *Node) ReadRPC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error) { +func (n *StorageNode) ReadRPC(ctx context.Context, in *ReadRequest) (resp *ReadResponse, err error) { cd := gorums.CallData{ Message: in, Method: "storage.Storage.ReadRPC", @@ -261,7 +241,7 @@ func (n *Node) ReadRPC(ctx context.Context, in *ReadRequest) (resp *ReadResponse } // WriteRPC executes the Write RPC on a single Node -func (n *Node) WriteRPC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error) { +func (n *StorageNode) WriteRPC(ctx context.Context, in *WriteRequest) (resp *WriteResponse, err error) { cd := gorums.CallData{ Message: in, Method: "storage.Storage.WriteRPC", diff --git a/examples/storage/repl.go b/examples/storage/repl.go index a939013c..4e920e55 100644 --- a/examples/storage/repl.go +++ b/examples/storage/repl.go @@ -52,12 +52,12 @@ The command performs the write quorum call on node 0 and 2 ` type repl struct { - mgr *pb.Manager - cfg *pb.Configuration + mgr *pb.StorageManager + cfg *pb.StorageConfiguration term *term.Terminal } -func newRepl(mgr *pb.Manager, cfg *pb.Configuration) *repl { +func newRepl(mgr *pb.StorageManager, cfg *pb.StorageConfiguration) *repl { return &repl{ mgr: mgr, cfg: cfg, @@ -90,7 +90,7 @@ func (r repl) ReadLine() (string, error) { // Repl runs an interactive Read-eval-print loop, that allows users to run commands that perform // RPCs and quorum calls using the manager and configuration. -func Repl(mgr *pb.Manager, defaultCfg *pb.Configuration) error { +func Repl(mgr *pb.StorageManager, defaultCfg *pb.StorageConfiguration) error { r := newRepl(mgr, defaultCfg) fmt.Println(help) @@ -210,7 +210,7 @@ func (r repl) qcCfg(args []string) { } } -func (repl) readRPC(args []string, node *pb.Node) { +func (repl) readRPC(args []string, node *pb.StorageNode) { if len(args) < 1 { fmt.Println("Read requires a key to read.") return @@ -229,7 +229,7 @@ func (repl) readRPC(args []string, node *pb.Node) { fmt.Printf("%s = %s\n", args[0], resp.GetValue()) } -func (repl) writeRPC(args []string, node *pb.Node) { +func (repl) writeRPC(args []string, node *pb.StorageNode) { if len(args) < 2 { fmt.Println("Write requires a key and a value to write.") return @@ -248,7 +248,7 @@ func (repl) writeRPC(args []string, node *pb.Node) { fmt.Println("Write OK") } -func (repl) readQC(args []string, cfg *pb.Configuration) { +func (repl) readQC(args []string, cfg *pb.StorageConfiguration) { if len(args) < 1 { fmt.Println("Read requires a key to read.") return @@ -267,7 +267,7 @@ func (repl) readQC(args []string, cfg *pb.Configuration) { fmt.Printf("%s = %s\n", args[0], resp.GetValue()) } -func (repl) writeQC(args []string, cfg *pb.Configuration) { +func (repl) writeQC(args []string, cfg *pb.StorageConfiguration) { if len(args) < 2 { fmt.Println("Write requires a key and a value to write.") return @@ -286,7 +286,7 @@ func (repl) writeQC(args []string, cfg *pb.Configuration) { fmt.Println("Write OK") } -func (r repl) parseConfiguration(cfgStr string) (cfg *pb.Configuration) { +func (r repl) parseConfiguration(cfgStr string) (cfg *pb.StorageConfiguration) { // configuration using range syntax if i := strings.Index(cfgStr, ":"); i > -1 { var start, stop int @@ -318,7 +318,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), &qspec{cfgSize: stop - start}) if err != nil { fmt.Printf("Failed to create configuration: %v\n", err) return nil @@ -341,7 +341,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), &qspec{cfgSize: len(selectedNodes)}) if err != nil { fmt.Printf("Failed to create configuration: %v\n", err) return nil From a6f544b94bddef81714c7729f3dbb83d3f09c3fd Mon Sep 17 00:00:00 2001 From: asbjorn Date: Wed, 26 Mar 2025 12:06:30 +0100 Subject: [PATCH 06/11] new zorums no qspec service and newline fix --- cmd/protoc-gen-gorums/dev/zorums.pb.go | 123 ++++++++++++------ cmd/protoc-gen-gorums/dev/zorums.proto | 46 +++++++ .../dev/zorums_client_gorums.pb.go | 22 ++++ .../dev/zorums_configuration_gorums.pb.go | 48 ++++++- .../dev/zorums_manager_gorums.pb.go | 50 ++++++- .../dev/zorums_multicast_gorums.pb.go | 60 +++++++++ .../dev/zorums_node_gorums.pb.go | 5 + .../dev/zorums_rpc_gorums.pb.go | 15 +++ .../dev/zorums_server_gorums.pb.go | 55 ++++++++ .../dev/zorums_unicast_gorums.pb.go | 23 ++++ .../gengorums/template_configuration.go | 6 +- .../gengorums/template_manager.go | 9 +- doc/user-guide.md | 10 +- 13 files changed, 416 insertions(+), 56 deletions(-) diff --git a/cmd/protoc-gen-gorums/dev/zorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums.pb.go index 5b9f16f7..546aec9f 100644 --- a/cmd/protoc-gen-gorums/dev/zorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums.pb.go @@ -342,9 +342,38 @@ var file_zorums_proto_rawDesc = []byte{ 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, + 0x32, 0xc4, 0x03, 0x0a, 0x14, 0x5a, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x4e, 0x6f, 0x51, 0x73, 0x70, + 0x65, 0x63, 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, 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) @@ -388,41 +417,57 @@ var file_zorums_proto_depIdxs = []int32{ 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 + 0, // 33: dev.ZorumsNoQspecService.GRPCCall:input_type -> dev.Request + 0, // 34: dev.ZorumsNoQspecService.Multicast:input_type -> dev.Request + 0, // 35: dev.ZorumsNoQspecService.MulticastPerNodeArg:input_type -> dev.Request + 0, // 36: dev.ZorumsNoQspecService.Multicast2:input_type -> dev.Request + 0, // 37: dev.ZorumsNoQspecService.Multicast3:input_type -> dev.Request + 3, // 38: dev.ZorumsNoQspecService.Multicast4:input_type -> google.protobuf.Empty + 0, // 39: dev.ZorumsNoQspecService.Unicast:input_type -> dev.Request + 0, // 40: dev.ZorumsNoQspecService.Unicast2:input_type -> dev.Request + 1, // 41: dev.ZorumsService.GRPCCall:output_type -> dev.Response + 1, // 42: dev.ZorumsService.QuorumCall:output_type -> dev.Response + 1, // 43: dev.ZorumsService.QuorumCallPerNodeArg:output_type -> dev.Response + 1, // 44: dev.ZorumsService.QuorumCallCustomReturnType:output_type -> dev.Response + 1, // 45: dev.ZorumsService.QuorumCallCombo:output_type -> dev.Response + 1, // 46: dev.ZorumsService.QuorumCallEmpty:output_type -> dev.Response + 3, // 47: dev.ZorumsService.QuorumCallEmpty2:output_type -> google.protobuf.Empty + 1, // 48: dev.ZorumsService.Multicast:output_type -> dev.Response + 1, // 49: dev.ZorumsService.MulticastPerNodeArg:output_type -> dev.Response + 1, // 50: dev.ZorumsService.Multicast2:output_type -> dev.Response + 3, // 51: dev.ZorumsService.Multicast3:output_type -> google.protobuf.Empty + 3, // 52: dev.ZorumsService.Multicast4:output_type -> google.protobuf.Empty + 1, // 53: dev.ZorumsService.QuorumCallAsync:output_type -> dev.Response + 1, // 54: dev.ZorumsService.QuorumCallAsyncPerNodeArg:output_type -> dev.Response + 1, // 55: dev.ZorumsService.QuorumCallAsyncCustomReturnType:output_type -> dev.Response + 1, // 56: dev.ZorumsService.QuorumCallAsyncCombo:output_type -> dev.Response + 1, // 57: dev.ZorumsService.QuorumCallAsync2:output_type -> dev.Response + 3, // 58: dev.ZorumsService.QuorumCallAsyncEmpty:output_type -> google.protobuf.Empty + 1, // 59: dev.ZorumsService.QuorumCallAsyncEmpty2:output_type -> dev.Response + 1, // 60: dev.ZorumsService.Correctable:output_type -> dev.Response + 1, // 61: dev.ZorumsService.CorrectablePerNodeArg:output_type -> dev.Response + 1, // 62: dev.ZorumsService.CorrectableCustomReturnType:output_type -> dev.Response + 1, // 63: dev.ZorumsService.CorrectableCombo:output_type -> dev.Response + 3, // 64: dev.ZorumsService.CorrectableEmpty:output_type -> google.protobuf.Empty + 1, // 65: dev.ZorumsService.CorrectableEmpty2:output_type -> dev.Response + 1, // 66: dev.ZorumsService.CorrectableStream:output_type -> dev.Response + 1, // 67: dev.ZorumsService.CorrectableStreamPerNodeArg:output_type -> dev.Response + 1, // 68: dev.ZorumsService.CorrectableStreamCustomReturnType:output_type -> dev.Response + 1, // 69: dev.ZorumsService.CorrectableStreamCombo:output_type -> dev.Response + 3, // 70: dev.ZorumsService.CorrectableStreamEmpty:output_type -> google.protobuf.Empty + 1, // 71: dev.ZorumsService.CorrectableStreamEmpty2:output_type -> dev.Response + 1, // 72: dev.ZorumsService.Unicast:output_type -> dev.Response + 3, // 73: dev.ZorumsService.Unicast2:output_type -> google.protobuf.Empty + 1, // 74: dev.ZorumsNoQspecService.GRPCCall:output_type -> dev.Response + 1, // 75: dev.ZorumsNoQspecService.Multicast:output_type -> dev.Response + 1, // 76: dev.ZorumsNoQspecService.MulticastPerNodeArg:output_type -> dev.Response + 1, // 77: dev.ZorumsNoQspecService.Multicast2:output_type -> dev.Response + 3, // 78: dev.ZorumsNoQspecService.Multicast3:output_type -> google.protobuf.Empty + 3, // 79: dev.ZorumsNoQspecService.Multicast4:output_type -> google.protobuf.Empty + 1, // 80: dev.ZorumsNoQspecService.Unicast:output_type -> dev.Response + 3, // 81: dev.ZorumsNoQspecService.Unicast2:output_type -> google.protobuf.Empty + 41, // [41:82] is the sub-list for method output_type + 0, // [0:41] 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 @@ -441,7 +486,7 @@ func file_zorums_proto_init() { NumEnums: 0, NumMessages: 3, NumExtensions: 0, - NumServices: 1, + NumServices: 2, }, GoTypes: file_zorums_proto_goTypes, DependencyIndexes: file_zorums_proto_depIdxs, diff --git a/cmd/protoc-gen-gorums/dev/zorums.proto b/cmd/protoc-gen-gorums/dev/zorums.proto index 6edbab62..6dce6330 100644 --- a/cmd/protoc-gen-gorums/dev/zorums.proto +++ b/cmd/protoc-gen-gorums/dev/zorums.proto @@ -212,3 +212,49 @@ service ZorumsService { option (gorums.unicast) = true; } } + +service ZorumsNoQspecService { + + // GRPCCall plain gRPC call; testing that Gorums can ignore these, but that + // they are added to the _grpc.pb.go generated file. + rpc GRPCCall(Request) returns (Response) {} + + // ------------------------------------------------------------------ + // Multicast variants + // The multicast call type does not support the 'custom_return_type' + // option since multicast is one-way and so it doesn't make sense to + // operate on response types. + // ------------------------------------------------------------------ + + // Multicast plain. Response type is not needed here. + rpc Multicast(Request) returns (Response) { + option (gorums.multicast) = true; + } + // MulticastPerNodeArg with per_node_arg option. + rpc MulticastPerNodeArg(Request) returns (Response) { + option (gorums.multicast) = true; + option (gorums.per_node_arg) = true; + } + // Multicast2 is testing whether multiple streams work. + rpc Multicast2(Request) returns (Response) { + option (gorums.multicast) = true; + } + // Multicast3 is testing imported message type. + rpc Multicast3(Request) returns (google.protobuf.Empty) { + option (gorums.multicast) = true; + } + // Multicast4 is testing imported message type. + rpc Multicast4(google.protobuf.Empty) returns (google.protobuf.Empty) { + option (gorums.multicast) = true; + } + + // --------------------------------------------------------------- + // Unicast + // --------------------------------------------------------------- + + rpc Unicast(Request) returns (Response) { option (gorums.unicast) = true; } + + rpc Unicast2(Request) returns (google.protobuf.Empty) { + option (gorums.unicast) = true; + } +} \ No newline at end of file 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 d5e20f9b..c2034a5b 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_client_gorums.pb.go @@ -56,6 +56,18 @@ type ZorumsServiceClient interface { // enforce interface compliance var _ ZorumsServiceClient = (*ZorumsServiceConfiguration)(nil) +// ZorumsNoQspecServiceClient is the client interface for the ZorumsNoQspecService service. +type ZorumsNoQspecServiceClient interface { + 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) +} + +// enforce interface compliance +var _ ZorumsNoQspecServiceClient = (*ZorumsNoQspecServiceConfiguration)(nil) + // ZorumsServiceNodeClient is the single node client interface for the ZorumsService service. type ZorumsServiceNodeClient interface { GRPCCall(ctx context.Context, in *Request) (resp *Response, err error) @@ -65,3 +77,13 @@ type ZorumsServiceNodeClient interface { // enforce interface compliance var _ ZorumsServiceNodeClient = (*ZorumsServiceNode)(nil) + +// ZorumsNoQspecServiceNodeClient is the single node client interface for the ZorumsNoQspecService service. +type ZorumsNoQspecServiceNodeClient interface { + GRPCCall(ctx context.Context, in *Request) (resp *Response, err error) + Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) + Unicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) +} + +// enforce interface compliance +var _ ZorumsNoQspecServiceNodeClient = (*ZorumsNoQspecServiceNode)(nil) diff --git a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go index 8641e4a0..804773da 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go @@ -24,7 +24,16 @@ type ZorumsServiceConfiguration struct { gorums.RawConfiguration qspec ZorumsServiceQuorumSpec nodes []*ZorumsServiceNode -} // ZorumsServiceQuorumSpecFromRaw returns a new ZorumsServiceQuorumSpec from the given raw configuration and QuorumSpec. +} + +// A ZorumsNoQspecServiceConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type ZorumsNoQspecServiceConfiguration struct { + gorums.RawConfiguration + nodes []*ZorumsNoQspecServiceNode +} + +// ZorumsServiceQuorumSpecFromRaw returns a new ZorumsServiceQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -47,6 +56,24 @@ func ZorumsServiceConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec Zor return newCfg, nil } +// ZorumsNoQspecServiceQuorumSpecFromRaw returns a new ZorumsNoQspecServiceQuorumSpec from the given raw configuration. +// +// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// +// cfg1, err := mgr.NewConfiguration(qspec1, opts...) +// cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) +func ZorumsNoQspecServiceConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*ZorumsNoQspecServiceConfiguration, error) { + newCfg := &ZorumsNoQspecServiceConfiguration{ + RawConfiguration: rawCfg, + } + // initialize the nodes slice + newCfg.nodes = make([]*ZorumsNoQspecServiceNode, newCfg.Size()) + for i, n := range rawCfg { + newCfg.nodes[i] = &ZorumsNoQspecServiceNode{n} + } + return newCfg, nil +} + // Nodes returns a slice of each available node. IDs are returned in the same // order as they were provided in the creation of the Manager. // @@ -65,3 +92,22 @@ func (c ZorumsServiceConfiguration) And(d *ZorumsServiceConfiguration) gorums.No func (c ZorumsServiceConfiguration) Except(rm *ZorumsServiceConfiguration) gorums.NodeListOption { return c.RawConfiguration.Except(rm.RawConfiguration) } + +// Nodes returns a slice of each available node. IDs are returned in the same +// order as they were provided in the creation of the Manager. +// +// NOTE: mutating the returned slice is not supported. +func (c *ZorumsNoQspecServiceConfiguration) Nodes() []*ZorumsNoQspecServiceNode { + return c.nodes +} + +// And returns a NodeListOption that can be used to create a new configuration combining c and d. +func (c ZorumsNoQspecServiceConfiguration) And(d *ZorumsNoQspecServiceConfiguration) 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 ZorumsNoQspecServiceConfiguration) Except(rm *ZorumsNoQspecServiceConfiguration) gorums.NodeListOption { + return c.RawConfiguration.Except(rm.RawConfiguration) +} diff --git a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go index 9792aec9..e0ec6ace 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go @@ -24,6 +24,12 @@ type ZorumsServiceManager struct { *gorums.RawManager } +// ZorumsNoQspecServiceManager maintains a connection pool of nodes on +// which quorum calls can be performed. +type ZorumsNoQspecServiceManager struct { + *gorums.RawManager +} + // NewZorumsServiceManager returns a new ZorumsServiceManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. @@ -31,9 +37,18 @@ func NewZorumsServiceManager(opts ...gorums.ManagerOption) *ZorumsServiceManager return &ZorumsServiceManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewZorumsServiceConfiguration returns a ZorumsServiceConfiguration based on the provided list of nodes (required) -// and a quorum specification -// . +} + +// NewZorumsNoQspecServiceManager returns a new ZorumsNoQspecServiceManager for managing connection to nodes added +// to the manager. This function accepts manager options used to configure +// various aspects of the manager. +func NewZorumsNoQspecServiceManager(opts ...gorums.ManagerOption) *ZorumsNoQspecServiceManager { + return &ZorumsNoQspecServiceManager{ + RawManager: gorums.NewRawManager(opts...), + } +} + +// NewZorumsServiceConfiguration returns a ZorumsServiceConfiguration based on the provided list of nodes and a quorum specification. // 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. @@ -56,6 +71,24 @@ func (m *ZorumsServiceManager) NewConfiguration(cfg gorums.NodeListOption, qspec return c, nil } +// NewZorumsNoQspecServiceConfiguration returns a ZorumsNoQspecServiceConfiguration based on the provided list of nodes. +// 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 *ZorumsNoQspecServiceManager) NewConfiguration(cfg gorums.NodeListOption) (c *ZorumsNoQspecServiceConfiguration, err error) { + c = &ZorumsNoQspecServiceConfiguration{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err + } + // initialize the nodes slice + c.nodes = make([]*ZorumsNoQspecServiceNode, c.Size()) + for i, n := range c.RawConfiguration { + c.nodes[i] = &ZorumsNoQspecServiceNode{n} + } + return c, nil +} + // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. func (m *ZorumsServiceManager) Nodes() []*ZorumsServiceNode { @@ -66,3 +99,14 @@ func (m *ZorumsServiceManager) Nodes() []*ZorumsServiceNode { } return nodes } + +// Nodes returns a slice of available nodes on this manager. +// IDs are returned in the order they were added at creation of the manager. +func (m *ZorumsNoQspecServiceManager) Nodes() []*ZorumsNoQspecServiceNode { + gorumsNodes := m.RawManager.Nodes() + nodes := make([]*ZorumsNoQspecServiceNode, len(gorumsNodes)) + for i, n := range gorumsNodes { + nodes[i] = &ZorumsNoQspecServiceNode{n} + } + return nodes +} 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 d0a85eaa..238e988d 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go @@ -79,3 +79,63 @@ func (c *ZorumsServiceConfiguration) Multicast4(ctx context.Context, in *emptypb c.RawConfiguration.Multicast(ctx, cd, opts...) } + +// Multicast plain. Response type is not needed here. +func (c *ZorumsNoQspecServiceConfiguration) Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { + cd := gorums.QuorumCallData{ + Message: in, + Method: "dev.ZorumsNoQspecService.Multicast", + } + + c.RawConfiguration.Multicast(ctx, cd, opts...) +} + +// MulticastPerNodeArg with per_node_arg option. +func (c *ZorumsNoQspecServiceConfiguration) MulticastPerNodeArg(ctx context.Context, in *Request, f func(*Request, uint32) *Request, opts ...gorums.CallOption) { + cd := gorums.QuorumCallData{ + Message: in, + Method: "dev.ZorumsNoQspecService.MulticastPerNodeArg", + } + + cd.PerNodeArgFn = func(req protoreflect.ProtoMessage, nid uint32) protoreflect.ProtoMessage { + return f(req.(*Request), nid) + } + + c.RawConfiguration.Multicast(ctx, cd, opts...) +} + +// Multicast2 is testing whether multiple streams work. +func (c *ZorumsNoQspecServiceConfiguration) Multicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) { + cd := gorums.QuorumCallData{ + Message: in, + Method: "dev.ZorumsNoQspecService.Multicast2", + } + + c.RawConfiguration.Multicast(ctx, cd, opts...) +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ emptypb.Empty + +// Multicast3 is testing imported message type. +func (c *ZorumsNoQspecServiceConfiguration) Multicast3(ctx context.Context, in *Request, opts ...gorums.CallOption) { + cd := gorums.QuorumCallData{ + Message: in, + Method: "dev.ZorumsNoQspecService.Multicast3", + } + + c.RawConfiguration.Multicast(ctx, cd, opts...) +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ emptypb.Empty + +// Multicast4 is testing imported message type. +func (c *ZorumsNoQspecServiceConfiguration) Multicast4(ctx context.Context, in *emptypb.Empty, opts ...gorums.CallOption) { + cd := gorums.QuorumCallData{ + Message: in, + Method: "dev.ZorumsNoQspecService.Multicast4", + } + + c.RawConfiguration.Multicast(ctx, cd, opts...) +} diff --git a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go index 98eafb5d..9f1bb38d 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go @@ -21,3 +21,8 @@ const ( type ZorumsServiceNode struct { *gorums.RawNode } + +// ZorumsNoQspecServiceNode holds the node specific methods for the ZorumsNoQspecService service. +type ZorumsNoQspecServiceNode struct { + *gorums.RawNode +} 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 4353d2e8..5890e86e 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go @@ -32,3 +32,18 @@ func (n *ZorumsServiceNode) GRPCCall(ctx context.Context, in *Request) (resp *Re } return res.(*Response), err } + +// GRPCCall plain gRPC call; testing that Gorums can ignore these, but that +// they are added to the _grpc.pb.go generated file. +func (n *ZorumsNoQspecServiceNode) GRPCCall(ctx context.Context, in *Request) (resp *Response, err error) { + cd := gorums.CallData{ + Message: in, + Method: "dev.ZorumsNoQspecService.GRPCCall", + } + + res, err := n.RawNode.RPCCall(ctx, cd) + if err != nil { + return nil, err + } + return res.(*Response), err +} 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 483f4174..e3ae1432 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go @@ -57,6 +57,18 @@ type ZorumsServiceServer interface { Unicast2(ctx gorums.ServerCtx, request *Request) } +// ZorumsNoQspecService is the server-side API for the ZorumsNoQspecService Service +type ZorumsNoQspecServiceServer interface { + GRPCCall(ctx gorums.ServerCtx, request *Request) (response *Response, err 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) + Unicast(ctx gorums.ServerCtx, request *Request) + Unicast2(ctx gorums.ServerCtx, request *Request) +} + func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { srv.RegisterHandler("dev.ZorumsService.GRPCCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) @@ -286,3 +298,46 @@ func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { impl.Unicast2(ctx, req) }) } +func RegisterZorumsNoQspecServiceServer(srv *gorums.Server, impl ZorumsNoQspecServiceServer) { + srv.RegisterHandler("dev.ZorumsNoQspecService.GRPCCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*Request) + defer ctx.Release() + resp, err := impl.GRPCCall(ctx, req) + gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) + }) + srv.RegisterHandler("dev.ZorumsNoQspecService.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.ZorumsNoQspecService.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.ZorumsNoQspecService.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.ZorumsNoQspecService.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.ZorumsNoQspecService.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.ZorumsNoQspecService.Unicast", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { + req := in.Message.(*Request) + defer ctx.Release() + impl.Unicast(ctx, req) + }) + srv.RegisterHandler("dev.ZorumsNoQspecService.Unicast2", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { + req := in.Message.(*Request) + defer ctx.Release() + impl.Unicast2(ctx, req) + }) +} 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 0d8ad68c..a6699180 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go @@ -41,3 +41,26 @@ func (n *ZorumsServiceNode) Unicast2(ctx context.Context, in *Request, opts ...g n.RawNode.Unicast(ctx, cd, opts...) } + +// Unicast is a one-way call; no replies are processed. +func (n *ZorumsNoQspecServiceNode) Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) { + cd := gorums.CallData{ + Message: in, + Method: "dev.ZorumsNoQspecService.Unicast", + } + + n.RawNode.Unicast(ctx, cd, opts...) +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ emptypb.Empty + +// Unicast2 is a one-way call; no replies are processed. +func (n *ZorumsNoQspecServiceNode) Unicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) { + cd := gorums.CallData{ + Message: in, + Method: "dev.ZorumsNoQspecService.Unicast2", + } + + n.RawNode.Unicast(ctx, cd, opts...) +} diff --git a/cmd/protoc-gen-gorums/gengorums/template_configuration.go b/cmd/protoc-gen-gorums/gengorums/template_configuration.go index fe3c453f..cac1d750 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_configuration.go +++ b/cmd/protoc-gen-gorums/gengorums/template_configuration.go @@ -13,7 +13,8 @@ var configurationStruct = ` {{- $configurationName := printf "%sConfiguration" $service}} {{- $qspecName := printf "%sQuorumSpec" $service}} {{- $nodeName := printf "%sNode" $service}} - {{- $isQspec := ne (len (qspecMethods .Methods)) 0 -}} + {{- $isQspec := ne (len (qspecMethods .Methods)) 0}} + // A {{$configurationName}} represents a static set of nodes on which quorum remote // procedure calls may be invoked. type {{$configurationName}} struct { @@ -23,6 +24,7 @@ var configurationStruct = ` {{- end}} nodes []*{{$nodeName}} } + {{- end}} ` @@ -34,7 +36,7 @@ var configurationFromRaw = ` {{- $configurationName := printf "%sConfiguration" $service}} {{- $qspecName := printf "%sQuorumSpec" $service}} {{- $nodeName := printf "%sNode" $service}} - {{- $isQspec := ne (len (qspecMethods .Methods)) 0 -}} + {{- $isQspec := ne (len (qspecMethods .Methods)) 0}} // {{$qspecName}}FromRaw returns a new {{$qspecName}} from the given raw configuration{{if $isQspec}} and QuorumSpec{{end}}. // diff --git a/cmd/protoc-gen-gorums/gengorums/template_manager.go b/cmd/protoc-gen-gorums/gengorums/template_manager.go index afa55455..362df505 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_manager.go +++ b/cmd/protoc-gen-gorums/gengorums/template_manager.go @@ -43,12 +43,9 @@ var managerNewConfiguration = ` {{- $configurationName := printf "%sConfiguration" $service}} {{- $qspecName := printf "%sQuorumSpec" $service}} {{- $nodeName := printf "%sNode" $service}} - {{- $isQspec := ne (len (qspecMethods .Methods)) 0 -}} - // New{{$configurationName}} returns a {{$configurationName}} based on the provided list of nodes (required) - {{- if $isQspec}} - // and a quorum specification - {{- end}} - // . + {{- $isQspec := ne (len (qspecMethods .Methods)) 0}} + + // New{{$configurationName}} returns a {{$configurationName}} based on the provided list of nodes (required) {{- if $isQspec}}and a quorum specification{{- end}}. // 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. diff --git a/doc/user-guide.md b/doc/user-guide.md index 45d0f272..703c1dd4 100644 --- a/doc/user-guide.md +++ b/doc/user-guide.md @@ -300,8 +300,8 @@ 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 *QCStorageConfiguration) Read(ctx context.Context, in *ReadRequest) (*State, error) +func (c *QCStorageConfiguration) Write(ctx context.Context, in *State) (*WriteResponse, error) ``` ## The QuorumSpec Interface with Quorum Functions @@ -400,15 +400,15 @@ func ExampleStorageClient() { "127.0.0.1:8082", } - mgr := NewManager( + mgr := NewQCStorageManager( gorums.WithGrpcDialOptions( grpc.WithTransportCredentials(insecure.NewCredentials()), ), ) // Create a configuration including all nodes allNodesConfig, err := mgr.NewConfiguration( - &QSpec{2}, gorums.WithNodeList(addrs), + &QSpec{2}, ) if err != nil { log.Fatalln("error creating read config:", err) @@ -417,7 +417,7 @@ func ExampleStorageClient() { // Invoke read quorum call: ctx, cancel := context.WithCancel(context.Background()) reply, err := allNodesConfig.Read(ctx, &ReadRequest{}) - if err != nil { + if err != nil {QCStorage log.Fatalln("read rpc returned error:", err) } cancel() From 40606978aa5076bcb83a1930e972540e6edd6e45 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Wed, 26 Mar 2025 14:48:53 +0100 Subject: [PATCH 07/11] fix last commit --- .../dev/zorums_manager_gorums.pb.go | 4 ++-- examples/storage/proto/storage.proto | 21 ------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go index e0ec6ace..a28c4dfc 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go @@ -48,7 +48,7 @@ func NewZorumsNoQspecServiceManager(opts ...gorums.ManagerOption) *ZorumsNoQspec } } -// NewZorumsServiceConfiguration returns a ZorumsServiceConfiguration based on the provided list of nodes and a quorum specification. +// NewZorumsServiceConfiguration returns a ZorumsServiceConfiguration based on the provided list of nodes (required)and a quorum specification. // 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. @@ -71,7 +71,7 @@ func (m *ZorumsServiceManager) NewConfiguration(cfg gorums.NodeListOption, qspec return c, nil } -// NewZorumsNoQspecServiceConfiguration returns a ZorumsNoQspecServiceConfiguration based on the provided list of nodes. +// NewZorumsNoQspecServiceConfiguration returns a ZorumsNoQspecServiceConfiguration based on the provided list of nodes (required). // 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. diff --git a/examples/storage/proto/storage.proto b/examples/storage/proto/storage.proto index 580ed153..e96c9a62 100644 --- a/examples/storage/proto/storage.proto +++ b/examples/storage/proto/storage.proto @@ -31,27 +31,6 @@ service Storage { } } -service Storage2 { - // ReadRPC executes the Read RPC on a single Node - rpc ReadRPC(ReadRequest) returns (ReadResponse) {} - // WriteRPC executes the Write RPC on a single Node - rpc WriteRPC(WriteRequest) returns (WriteResponse) {} - // ReadQC executes the Read Quorum Call on a configuration - // of Nodes and returns the most recent value. - rpc ReadQC(ReadRequest) returns (ReadResponse) { - option (gorums.quorumcall) = true; - } - // WriteQC executes the Write Quorum Call on a configuration - // of Nodes and returns true if a majority of Nodes were updated. - rpc WriteQC(WriteRequest) returns (WriteResponse) { - option (gorums.quorumcall) = true; - } - - rpc WriteMulticast(WriteRequest) returns (google.protobuf.Empty) { - option (gorums.multicast) = true; - } -} - message ReadRequest { string Key = 1; } message ReadResponse { From d97bfa832ac7aff7393ed86719164ec60c4ddabb Mon Sep 17 00:00:00 2001 From: asbjorn Date: Sun, 27 Apr 2025 18:03:02 +0200 Subject: [PATCH 08/11] improve generated manager/configuration/node method grouping --- benchmark/benchmark.pb.go | 135 ++++----- benchmark/benchmark_gorums.pb.go | 19 +- cmd/protoc-gen-gorums/dev/zorums.pb.go | 257 +++++------------- .../dev/zorums_async_gorums.pb.go | 2 +- .../dev/zorums_client_gorums.pb.go | 22 +- .../dev/zorums_configuration_gorums.pb.go | 52 ++-- .../dev/zorums_correctable_gorums.pb.go | 2 +- .../dev/zorums_manager_gorums.pb.go | 54 ++-- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_node_gorums.pb.go | 2 +- .../dev/zorums_qspec_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 +- .../gengorums/template_client.go | 85 +++--- .../gengorums/template_configuration.go | 129 ++++----- .../gengorums/template_manager.go | 123 ++++----- examples/storage/proto/storage.pb.go | 2 +- examples/storage/proto/storage_gorums.pb.go | 12 +- go.work.sum | 40 +++ gorums.pb.go | 63 ++--- internal/correctable/opts.pb.go | 34 +-- .../failing/reservednames/reserved.pb.go | 2 +- .../reservednames/reserved_gorums.pb.go | 12 +- ordering/ordering.pb.go | 39 +-- ordering/ordering_grpc.pb.go | 2 +- tests/config/config.pb.go | 41 ++- tests/config/config_gorums.pb.go | 19 +- tests/correctable/correctable.pb.go | 48 +--- tests/correctable/correctable_gorums.pb.go | 19 +- tests/dummy/dummy.pb.go | 29 +- tests/dummy/dummy_gorums.pb.go | 19 +- tests/metadata/metadata.pb.go | 44 ++- tests/metadata/metadata_gorums.pb.go | 20 +- tests/oneway/oneway.pb.go | 45 ++- tests/oneway/oneway_gorums.pb.go | 11 +- tests/ordering/order.pb.go | 48 ++-- tests/ordering/order_gorums.pb.go | 12 +- tests/qf/qf.pb.go | 41 ++- tests/qf/qf_gorums.pb.go | 19 +- tests/tls/tls.pb.go | 33 +-- tests/tls/tls_gorums.pb.go | 19 +- tests/unresponsive/unresponsive.pb.go | 33 +-- tests/unresponsive/unresponsive_gorums.pb.go | 19 +- 46 files changed, 688 insertions(+), 933 deletions(-) create mode 100644 go.work.sum diff --git a/benchmark/benchmark.pb.go b/benchmark/benchmark.pb.go index dd1e7f9a..fafb0d18 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: benchmark/benchmark.proto package benchmark @@ -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 ( @@ -587,89 +588,50 @@ func (b0 MemoryStatList_builder) Build() *MemoryStatList { 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, 0x22, 0x49, 0x0a, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, - 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x0b, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x53, - 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, 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, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x32, 0xb2, - 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, 0x56, 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, 0x16, 0xa0, 0xb5, 0x18, 0x01, 0xf2, 0xb6, 0x18, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, - 0x53, 0x74, 0x61, 0x74, 0x4c, 0x69, 0x73, 0x74, 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, 0x3d, - 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, 0x08, 0xa0, 0xb5, 0x18, 0x01, 0xd0, 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\x06Memory\"I\n" + + "\x0eMemoryStatList\x127\n" + + "\vMemoryStats\x18\x01 \x03(\v2\x15.benchmark.MemoryStatR\vMemoryStats2\xb2\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" + + "\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" + + "\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, 8) var file_benchmark_benchmark_proto_goTypes = []any{ @@ -718,7 +680,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: 8, NumExtensions: 0, @@ -729,7 +691,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 69d21dfc..7dd7eb9f 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: benchmark/benchmark.proto package benchmark @@ -63,13 +63,22 @@ type BenchmarkClient interface { // enforce interface compliance var _ BenchmarkClient = (*BenchmarkConfiguration)(nil) +// BenchmarkNodeClient is the single node client interface for the Benchmark service. +type BenchmarkNodeClient interface { +} + +// enforce interface compliance +var _ BenchmarkNodeClient = (*BenchmarkNode)(nil) + // A BenchmarkConfiguration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type BenchmarkConfiguration struct { gorums.RawConfiguration qspec BenchmarkQuorumSpec nodes []*BenchmarkNode -} // BenchmarkQuorumSpecFromRaw returns a new BenchmarkQuorumSpec from the given raw configuration and QuorumSpec. +} + +// BenchmarkQuorumSpecFromRaw returns a new BenchmarkQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -124,9 +133,9 @@ func NewBenchmarkManager(opts ...gorums.ManagerOption) *BenchmarkManager { return &BenchmarkManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewBenchmarkConfiguration returns a BenchmarkConfiguration based on the provided list of nodes (required) -// and a quorum specification -// . +} + +// NewBenchmarkConfiguration returns a BenchmarkConfiguration based on the provided list of nodes (required)and a quorum specification. // 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. diff --git a/cmd/protoc-gen-gorums/dev/zorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums.pb.go index 546aec9f..53923209 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: zorums.proto package dev @@ -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,187 +195,74 @@ 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, 0x86, 0x11, 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, 0x4d, 0x0a, 0x1a, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, - 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x54, 0x79, - 0x70, 0x65, 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, - 0x12, 0xa0, 0xb5, 0x18, 0x01, 0xf2, 0xb6, 0x18, 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x0f, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, - 0x6c, 0x43, 0x6f, 0x6d, 0x62, 0x6f, 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, 0x16, 0xa0, 0xb5, 0x18, 0x01, 0xa0, 0xb6, 0x18, 0x01, 0xf2, 0xb6, 0x18, - 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 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, 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, 0x38, 0x0a, 0x0f, 0x51, 0x75, 0x6f, 0x72, - 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x41, 0x73, 0x79, 0x6e, 0x63, 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, 0xd0, 0xb5, - 0x18, 0x01, 0x12, 0x46, 0x0a, 0x19, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, - 0x41, 0x73, 0x79, 0x6e, 0x63, 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, 0x0c, 0xa0, 0xb5, - 0x18, 0x01, 0xd0, 0xb5, 0x18, 0x01, 0xa0, 0xb6, 0x18, 0x01, 0x12, 0x56, 0x0a, 0x1f, 0x51, 0x75, - 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x43, 0x75, 0x73, - 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x54, 0x79, 0x70, 0x65, 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, 0x16, 0xa0, 0xb5, 0x18, 0x01, - 0xd0, 0xb5, 0x18, 0x01, 0xf2, 0xb6, 0x18, 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x14, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, - 0x41, 0x73, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x62, 0x6f, 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, 0x1a, 0xa0, 0xb5, 0x18, 0x01, 0xd0, 0xb5, 0x18, - 0x01, 0xa0, 0xb6, 0x18, 0x01, 0xf2, 0xb6, 0x18, 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, - 0x6c, 0x41, 0x73, 0x79, 0x6e, 0x63, 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, 0x08, 0xa0, 0xb5, 0x18, 0x01, 0xd0, 0xb5, 0x18, 0x01, 0x12, 0x46, - 0x0a, 0x14, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, 0x43, 0x61, 0x6c, 0x6c, 0x41, 0x73, 0x79, 0x6e, - 0x63, 0x45, 0x6d, 0x70, 0x74, 0x79, 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, 0x08, 0xa0, 0xb5, - 0x18, 0x01, 0xd0, 0xb5, 0x18, 0x01, 0x12, 0x48, 0x0a, 0x15, 0x51, 0x75, 0x6f, 0x72, 0x75, 0x6d, - 0x43, 0x61, 0x6c, 0x6c, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 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, 0x08, 0xa0, 0xb5, 0x18, 0x01, 0xd0, 0xb5, 0x18, 0x01, - 0x12, 0x30, 0x0a, 0x0b, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 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, 0xa8, 0xb5, - 0x18, 0x01, 0x12, 0x3e, 0x0a, 0x15, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, - 0x65, 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, 0xa8, 0xb5, 0x18, 0x01, 0xa0, 0xb6, - 0x18, 0x01, 0x12, 0x4e, 0x0a, 0x1b, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x54, 0x79, 0x70, - 0x65, 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, 0x12, - 0xa8, 0xb5, 0x18, 0x01, 0xf2, 0xb6, 0x18, 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x47, 0x0a, 0x10, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x43, 0x6f, 0x6d, 0x62, 0x6f, 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, 0x16, 0xa8, 0xb5, 0x18, 0x01, 0xa0, 0xb6, 0x18, 0x01, 0xf2, 0xb6, 0x18, - 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x10, 0x43, - 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 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, 0xa8, 0xb5, 0x18, 0x01, 0x12, 0x40, 0x0a, 0x11, 0x43, - 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, - 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, 0xa8, 0xb5, 0x18, 0x01, 0x12, 0x38, 0x0a, - 0x11, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 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, 0xa8, 0xb5, 0x18, 0x01, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x1b, 0x43, 0x6f, 0x72, 0x72, 0x65, - 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 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, 0xa8, 0xb5, 0x18, 0x01, 0xa0, 0xb6, 0x18, 0x01, 0x30, 0x01, 0x12, - 0x56, 0x0a, 0x21, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, - 0x54, 0x79, 0x70, 0x65, 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, 0x12, 0xa8, 0xb5, 0x18, 0x01, 0xf2, 0xb6, 0x18, 0x0a, 0x4d, 0x79, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x4f, 0x0a, 0x16, 0x43, 0x6f, 0x72, 0x72, 0x65, - 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6d, 0x62, - 0x6f, 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, 0x16, - 0xa8, 0xb5, 0x18, 0x01, 0xa0, 0xb6, 0x18, 0x01, 0xf2, 0xb6, 0x18, 0x0a, 0x4d, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x16, 0x43, 0x6f, 0x72, 0x72, - 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x6d, 0x70, - 0x74, 0x79, 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, 0xa8, 0xb5, 0x18, 0x01, 0x30, 0x01, - 0x12, 0x48, 0x0a, 0x17, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 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, 0xa8, 0xb5, 0x18, 0x01, 0x30, 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, - 0x32, 0xc4, 0x03, 0x0a, 0x14, 0x5a, 0x6f, 0x72, 0x75, 0x6d, 0x73, 0x4e, 0x6f, 0x51, 0x73, 0x70, - 0x65, 0x63, 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, 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\x86\x11\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" + + "\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" + + "\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\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" + + "\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\x012\xc4\x03\n" + + "\x14ZorumsNoQspecService\x12)\n" + + "\bGRPCCall\x12\f.dev.Request\x1a\r.dev.Response\"\x00\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{ @@ -482,7 +370,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, @@ -493,7 +381,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_async_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go index 6de7bc6d..2e8a745b 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.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 c2034a5b..80dcd037 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: zorums.proto package dev @@ -56,6 +56,16 @@ type ZorumsServiceClient interface { // enforce interface compliance var _ ZorumsServiceClient = (*ZorumsServiceConfiguration)(nil) +// ZorumsServiceNodeClient is the single node client interface for the ZorumsService service. +type ZorumsServiceNodeClient interface { + GRPCCall(ctx context.Context, in *Request) (resp *Response, err error) + Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) + Unicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) +} + +// enforce interface compliance +var _ ZorumsServiceNodeClient = (*ZorumsServiceNode)(nil) + // ZorumsNoQspecServiceClient is the client interface for the ZorumsNoQspecService service. type ZorumsNoQspecServiceClient interface { Multicast(ctx context.Context, in *Request, opts ...gorums.CallOption) @@ -68,16 +78,6 @@ type ZorumsNoQspecServiceClient interface { // enforce interface compliance var _ ZorumsNoQspecServiceClient = (*ZorumsNoQspecServiceConfiguration)(nil) -// ZorumsServiceNodeClient is the single node client interface for the ZorumsService service. -type ZorumsServiceNodeClient interface { - GRPCCall(ctx context.Context, in *Request) (resp *Response, err error) - Unicast(ctx context.Context, in *Request, opts ...gorums.CallOption) - Unicast2(ctx context.Context, in *Request, opts ...gorums.CallOption) -} - -// enforce interface compliance -var _ ZorumsServiceNodeClient = (*ZorumsServiceNode)(nil) - // ZorumsNoQspecServiceNodeClient is the single node client interface for the ZorumsNoQspecService service. type ZorumsNoQspecServiceNodeClient interface { GRPCCall(ctx context.Context, in *Request) (resp *Response, err error) diff --git a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go index 804773da..0997565e 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: zorums.proto package dev @@ -26,13 +26,6 @@ type ZorumsServiceConfiguration struct { nodes []*ZorumsServiceNode } -// A ZorumsNoQspecServiceConfiguration represents a static set of nodes on which quorum remote -// procedure calls may be invoked. -type ZorumsNoQspecServiceConfiguration struct { - gorums.RawConfiguration - nodes []*ZorumsNoQspecServiceNode -} - // ZorumsServiceQuorumSpecFromRaw returns a new ZorumsServiceQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: @@ -56,24 +49,6 @@ func ZorumsServiceConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec Zor return newCfg, nil } -// ZorumsNoQspecServiceQuorumSpecFromRaw returns a new ZorumsNoQspecServiceQuorumSpec from the given raw configuration. -// -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: -// -// cfg1, err := mgr.NewConfiguration(qspec1, opts...) -// cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ZorumsNoQspecServiceConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*ZorumsNoQspecServiceConfiguration, error) { - newCfg := &ZorumsNoQspecServiceConfiguration{ - RawConfiguration: rawCfg, - } - // initialize the nodes slice - newCfg.nodes = make([]*ZorumsNoQspecServiceNode, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &ZorumsNoQspecServiceNode{n} - } - return newCfg, nil -} - // Nodes returns a slice of each available node. IDs are returned in the same // order as they were provided in the creation of the Manager. // @@ -93,6 +68,31 @@ func (c ZorumsServiceConfiguration) Except(rm *ZorumsServiceConfiguration) gorum return c.RawConfiguration.Except(rm.RawConfiguration) } +// A ZorumsNoQspecServiceConfiguration represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type ZorumsNoQspecServiceConfiguration struct { + gorums.RawConfiguration + nodes []*ZorumsNoQspecServiceNode +} + +// ZorumsNoQspecServiceQuorumSpecFromRaw returns a new ZorumsNoQspecServiceQuorumSpec from the given raw configuration. +// +// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// +// cfg1, err := mgr.NewConfiguration(qspec1, opts...) +// cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) +func ZorumsNoQspecServiceConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*ZorumsNoQspecServiceConfiguration, error) { + newCfg := &ZorumsNoQspecServiceConfiguration{ + RawConfiguration: rawCfg, + } + // initialize the nodes slice + newCfg.nodes = make([]*ZorumsNoQspecServiceNode, newCfg.Size()) + for i, n := range rawCfg { + newCfg.nodes[i] = &ZorumsNoQspecServiceNode{n} + } + return newCfg, nil +} + // Nodes returns a slice of each available node. IDs are returned in the same // order as they were provided in the creation of the Manager. // 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 4313335b..759dfa30 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go index a28c4dfc..eb3cba30 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_manager_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: zorums.proto package dev @@ -24,12 +24,6 @@ type ZorumsServiceManager struct { *gorums.RawManager } -// ZorumsNoQspecServiceManager maintains a connection pool of nodes on -// which quorum calls can be performed. -type ZorumsNoQspecServiceManager struct { - *gorums.RawManager -} - // NewZorumsServiceManager returns a new ZorumsServiceManager for managing connection to nodes added // to the manager. This function accepts manager options used to configure // various aspects of the manager. @@ -39,15 +33,6 @@ func NewZorumsServiceManager(opts ...gorums.ManagerOption) *ZorumsServiceManager } } -// NewZorumsNoQspecServiceManager returns a new ZorumsNoQspecServiceManager for managing connection to nodes added -// to the manager. This function accepts manager options used to configure -// various aspects of the manager. -func NewZorumsNoQspecServiceManager(opts ...gorums.ManagerOption) *ZorumsNoQspecServiceManager { - return &ZorumsNoQspecServiceManager{ - RawManager: gorums.NewRawManager(opts...), - } -} - // NewZorumsServiceConfiguration returns a ZorumsServiceConfiguration based on the provided list of nodes (required)and a quorum specification. // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, @@ -71,6 +56,32 @@ func (m *ZorumsServiceManager) NewConfiguration(cfg gorums.NodeListOption, qspec return c, nil } +// Nodes returns a slice of available nodes on this manager. +// IDs are returned in the order they were added at creation of the manager. +func (m *ZorumsServiceManager) Nodes() []*ZorumsServiceNode { + gorumsNodes := m.RawManager.Nodes() + nodes := make([]*ZorumsServiceNode, len(gorumsNodes)) + for i, n := range gorumsNodes { + nodes[i] = &ZorumsServiceNode{n} + } + return nodes +} + +// ZorumsNoQspecServiceManager maintains a connection pool of nodes on +// which quorum calls can be performed. +type ZorumsNoQspecServiceManager struct { + *gorums.RawManager +} + +// NewZorumsNoQspecServiceManager returns a new ZorumsNoQspecServiceManager for managing connection to nodes added +// to the manager. This function accepts manager options used to configure +// various aspects of the manager. +func NewZorumsNoQspecServiceManager(opts ...gorums.ManagerOption) *ZorumsNoQspecServiceManager { + return &ZorumsNoQspecServiceManager{ + RawManager: gorums.NewRawManager(opts...), + } +} + // NewZorumsNoQspecServiceConfiguration returns a ZorumsNoQspecServiceConfiguration based on the provided list of nodes (required). // Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. // A new configuration can also be created from an existing configuration, @@ -89,17 +100,6 @@ func (m *ZorumsNoQspecServiceManager) NewConfiguration(cfg gorums.NodeListOption return c, nil } -// Nodes returns a slice of available nodes on this manager. -// IDs are returned in the order they were added at creation of the manager. -func (m *ZorumsServiceManager) Nodes() []*ZorumsServiceNode { - gorumsNodes := m.RawManager.Nodes() - nodes := make([]*ZorumsServiceNode, len(gorumsNodes)) - for i, n := range gorumsNodes { - nodes[i] = &ZorumsServiceNode{n} - } - return nodes -} - // Nodes returns a slice of available nodes on this manager. // IDs are returned in the order they were added at creation of the manager. func (m *ZorumsNoQspecServiceManager) Nodes() []*ZorumsNoQspecServiceNode { 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 238e988d..44489ed0 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go index 9f1bb38d..481c6a37 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.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 1d1e2141..186c9c2e 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.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 0cd8c78f..b3218f05 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: zorums.proto package dev 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 5890e86e..43105fdd 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.8.0-devel -// protoc v5.29.2 +// 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 e3ae1432..c316dfb1 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.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 4f6707da..681dc7d1 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.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 a6699180..2557a288 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.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: zorums.proto package dev diff --git a/cmd/protoc-gen-gorums/gengorums/template_client.go b/cmd/protoc-gen-gorums/gengorums/template_client.go index 92d78d33..8c6fda20 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_client.go +++ b/cmd/protoc-gen-gorums/gengorums/template_client.go @@ -11,56 +11,61 @@ var clientVariables = ` {{$callOpt := use "gorums.CallOption" .GenFile}} ` -var clientConfigurationInterface = ` +var clientServicesBegin = ` {{- $genFile := .GenFile}} {{- range configurationsServices .Services}} {{- $service := .GoName}} - {{- $interfaceName := printf "%sClient" $service}} - {{- $configurationName := printf "%sConfiguration" $service}} - // {{$interfaceName}} is the client interface for the {{$service}} service. - type {{$interfaceName}} interface { - {{- range configurationMethods .Methods}} - {{- $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"}}) (resp *{{$customOut}}, err error) - {{- end}} - {{- end}} - } - // enforce interface compliance - var _ {{$interfaceName}} = (*{{$configurationName}})(nil) +` + +var clientServicesEnd = ` {{- end}} ` +var clientConfigurationInterface = ` +{{- $interfaceName := printf "%sClient" $service}} +{{- $configurationName := printf "%sConfiguration" $service}} +// {{$interfaceName}} is the client interface for the {{$service}} service. +type {{$interfaceName}} interface { + {{- range configurationMethods .Methods}} + {{- $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"}}) (resp *{{$customOut}}, err error) + {{- end}} + {{- end}} +} +// enforce interface compliance +var _ {{$interfaceName}} = (*{{$configurationName}})(nil) +` + var clientNodeInterface = ` -{{- $genFile := .GenFile}} -{{- range nodeServices .Services}} - {{- $service := .GoName}} - {{- $nodeName := printf "%sNode" $service}} - {{- $interfaceName := printf "%sNodeClient" $service}} - // {{$interfaceName}} is the single node client interface for the {{$service}} service. - type {{$interfaceName}} interface { - {{- range nodeMethods .Methods}} - {{- $method := .GoName}} - {{- 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) - {{- end}} +{{- $interfaceName := printf "%sNodeClient" $service}} +{{- $nodeName := printf "%sNode" $service}} +// {{$interfaceName}} is the single node client interface for the {{$service}} service. +type {{$interfaceName}} interface { + {{- range nodeMethods .Methods}} + {{- $method := .GoName}} + {{- 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) {{- end}} - } - // enforce interface compliance - var _ {{$interfaceName}} = (*{{$nodeName}})(nil) -{{- end}} + {{- end}} +} +// enforce interface compliance +var _ {{$interfaceName}} = (*{{$nodeName}})(nil) ` -var client = clientVariables + clientConfigurationInterface + clientNodeInterface +var client = clientVariables + + clientServicesBegin + + clientConfigurationInterface + clientNodeInterface + + clientServicesEnd // configurationsServices returns all services containing at least one multi node method. func configurationsServices(services []*protogen.Service) (s []*protogen.Service) { diff --git a/cmd/protoc-gen-gorums/gengorums/template_configuration.go b/cmd/protoc-gen-gorums/gengorums/template_configuration.go index cac1d750..66a60774 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_configuration.go +++ b/cmd/protoc-gen-gorums/gengorums/template_configuration.go @@ -5,96 +5,83 @@ var configurationVars = ` {{$nodeListOptions := use "gorums.NodeListOption" .GenFile}} ` -var configurationStruct = ` +var configurationServicesBegin = ` {{- $genFile := .GenFile}} {{- range .Services}} {{- $service := .GoName}} - {{- $managerName := printf "%sManager" $service}} {{- $configurationName := printf "%sConfiguration" $service}} {{- $qspecName := printf "%sQuorumSpec" $service}} {{- $nodeName := printf "%sNode" $service}} {{- $isQspec := ne (len (qspecMethods .Methods)) 0}} +` - // A {{$configurationName}} represents a static set of nodes on which quorum remote - // procedure calls may be invoked. - type {{$configurationName}} struct { - {{$rawConfiguration}} - {{- if $isQspec}} - qspec {{$qspecName}} - {{- end}} - nodes []*{{$nodeName}} - } - +var configurationServicesEnd = ` {{- end}} ` -var configurationFromRaw = ` -{{- $genFile := .GenFile}} -{{- range .Services}} - {{- $service := .GoName}} - {{- $managerName := printf "%sManager" $service}} - {{- $configurationName := printf "%sConfiguration" $service}} - {{- $qspecName := printf "%sQuorumSpec" $service}} - {{- $nodeName := printf "%sNode" $service}} - {{- $isQspec := ne (len (qspecMethods .Methods)) 0}} +var configurationStruct = ` +// A {{$configurationName}} represents a static set of nodes on which quorum remote +// procedure calls may be invoked. +type {{$configurationName}} struct { + {{$rawConfiguration}} + {{- if $isQspec}} + qspec {{$qspecName}} + {{- end}} + nodes []*{{$nodeName}} +} +` - // {{$qspecName}}FromRaw returns a new {{$qspecName}} from the given raw configuration{{if $isQspec}} and QuorumSpec{{end}}. - // - // This function may for example be used to "clone" a configuration but install a different QuorumSpec: - // - // cfg1, err := mgr.NewConfiguration(qspec1, opts...) - // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) - func {{$configurationName}}FromRaw(rawCfg {{$rawConfiguration}}{{if $isQspec}}, qspec {{$qspecName}}{{end}}) (*{{$configurationName}}, error) { +var configurationFromRaw = ` +// {{$qspecName}}FromRaw returns a new {{$qspecName}} from the given raw configuration{{if $isQspec}} and QuorumSpec{{end}}. +// +// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// +// cfg1, err := mgr.NewConfiguration(qspec1, opts...) +// cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) +func {{$configurationName}}FromRaw(rawCfg {{$rawConfiguration}}{{if $isQspec}}, qspec {{$qspecName}}{{end}}) (*{{$configurationName}}, error) { + {{- if $isQspec}} + // return an error if qspec is nil. + if qspec == nil { + return nil, {{use "fmt.Errorf" $genFile}}("config: missing required QuorumSpec") + } + {{- end}} + newCfg := &{{$configurationName}}{ + RawConfiguration: rawCfg, {{- if $isQspec}} - // return an error if qspec is nil. - if qspec == nil { - return nil, {{use "fmt.Errorf" $genFile}}("config: missing required QuorumSpec") - } + qspec: qspec, {{- end}} - newCfg := &{{$configurationName}}{ - RawConfiguration: rawCfg, - {{- if $isQspec}} - qspec: qspec, - {{- end}} - } - // initialize the nodes slice - newCfg.nodes = make([]*{{$nodeName}}, newCfg.Size()) - for i, n := range rawCfg { - newCfg.nodes[i] = &{{$nodeName}}{n} - } - return newCfg, nil } - -{{- end}} + // initialize the nodes slice + newCfg.nodes = make([]*{{$nodeName}}, newCfg.Size()) + for i, n := range rawCfg { + newCfg.nodes[i] = &{{$nodeName}}{n} + } + return newCfg, nil +} ` var configurationMethodsTemplate = ` -{{- $genFile := .GenFile}} -{{- range .Services}} - {{- $service := .GoName}} - {{- $configurationName := printf "%sConfiguration" $service}} - {{- $nodeName := printf "%sNode" $service}} +// Nodes returns a slice of each available node. IDs are returned in the same +// order as they were provided in the creation of the Manager. +// +// NOTE: mutating the returned slice is not supported. +func (c *{{$configurationName}}) Nodes() []*{{$nodeName}} { + return c.nodes +} - // Nodes returns a slice of each available node. IDs are returned in the same - // order as they were provided in the creation of the Manager. - // - // NOTE: mutating the returned slice is not supported. - func (c *{{$configurationName}}) Nodes() []*{{$nodeName}} { - return c.nodes - } +// And returns a NodeListOption that can be used to create a new configuration combining c and d. +func (c {{$configurationName}}) And(d *{{$configurationName}}) {{$nodeListOptions}} { + return c.RawConfiguration.And(d.RawConfiguration) +} - // And returns a NodeListOption that can be used to create a new configuration combining c and d. - func (c {{$configurationName}}) And(d *{{$configurationName}}) {{$nodeListOptions}} { - 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 {{$configurationName}}) Except(rm *{{$configurationName}}) {{$nodeListOptions}} { - return c.RawConfiguration.Except(rm.RawConfiguration) - } - -{{- end}} +// Except returns a NodeListOption that can be used to create a new configuration +// from c without the nodes in rm. +func (c {{$configurationName}}) Except(rm *{{$configurationName}}) {{$nodeListOptions}} { + return c.RawConfiguration.Except(rm.RawConfiguration) +} ` -var configuration = configurationVars + configurationStruct + configurationFromRaw + configurationMethodsTemplate +var configuration = configurationVars + + configurationServicesBegin + + configurationStruct + configurationFromRaw + configurationMethodsTemplate + + configurationServicesEnd diff --git a/cmd/protoc-gen-gorums/gengorums/template_manager.go b/cmd/protoc-gen-gorums/gengorums/template_manager.go index 362df505..edd9c281 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_manager.go +++ b/cmd/protoc-gen-gorums/gengorums/template_manager.go @@ -6,89 +6,82 @@ var managerVariables = ` {{$callOpt := use "gorums.CallOption" .GenFile}} ` -var managerStructs = ` +var managerServicesBegin = ` {{- $genFile := .GenFile}} {{- range .Services}} {{- $service := .GoName}} {{- $managerName := printf "%sManager" $service}} - // {{$managerName}} maintains a connection pool of nodes on - // which quorum calls can be performed. - type {{$managerName}} struct { - *gorums.RawManager - } + {{- $nodeName := printf "%sNode" $service}} +` + +var managerServicesEnd = ` {{- end}} ` +var managerStructs = ` +// {{$managerName}} maintains a connection pool of nodes on +// which quorum calls can be performed. +type {{$managerName}} struct { + *gorums.RawManager +} +` + var managerConstructor = ` -{{- $genFile := .GenFile}} -{{- range .Services}} - {{- $service := .GoName}} - {{- $managerName := printf "%sManager" $service}} - // New{{$managerName}} returns a new {{$managerName}} for managing connection to nodes added - // to the manager. This function accepts manager options used to configure - // various aspects of the manager. - func New{{$managerName}}(opts ...gorums.ManagerOption) *{{$managerName}} { - return &{{$managerName}}{ - RawManager: gorums.NewRawManager(opts...), - } +// New{{$managerName}} returns a new {{$managerName}} for managing connection to nodes added +// to the manager. This function accepts manager options used to configure +// various aspects of the manager. +func New{{$managerName}}(opts ...gorums.ManagerOption) *{{$managerName}} { + return &{{$managerName}}{ + RawManager: gorums.NewRawManager(opts...), } -{{- end}} +} ` var managerNewConfiguration = ` -{{- $genFile := .GenFile}} -{{- range .Services}} - {{- $service := .GoName}} - {{- $managerName := printf "%sManager" $service}} - {{- $configurationName := printf "%sConfiguration" $service}} - {{- $qspecName := printf "%sQuorumSpec" $service}} - {{- $nodeName := printf "%sNode" $service}} - {{- $isQspec := ne (len (qspecMethods .Methods)) 0}} +{{- $configurationName := printf "%sConfiguration" $service}} +{{- $qspecName := printf "%sQuorumSpec" $service}} +{{- $isQspec := ne (len (qspecMethods .Methods)) 0}} - // New{{$configurationName}} returns a {{$configurationName}} based on the provided list of nodes (required) {{- if $isQspec}}and a quorum specification{{- end}}. - // 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 *{{$managerName}}) NewConfiguration(cfg gorums.NodeListOption{{if $isQspec}}, qspec {{$qspecName}}{{end}}) (c *{{$configurationName}}, err error) { - c = &{{$configurationName}}{} - c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) - if err != nil { - return nil, err - } - {{- if $isQspec}} - // return an error if qspec is nil. - if qspec == nil { - return nil, {{use "fmt.Errorf" $genFile}}("config: missing required {{$qspecName}}") - } - c.qspec = qspec - {{- end}} - // initialize the nodes slice - c.nodes = make([]*{{$nodeName}}, c.Size()) - for i, n := range c.RawConfiguration { - c.nodes[i] = &{{$nodeName}}{n} +// New{{$configurationName}} returns a {{$configurationName}} based on the provided list of nodes (required) {{- if $isQspec}}and a quorum specification{{- end}}. +// 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 *{{$managerName}}) NewConfiguration(cfg gorums.NodeListOption{{if $isQspec}}, qspec {{$qspecName}}{{end}}) (c *{{$configurationName}}, err error) { + c = &{{$configurationName}}{} + c.RawConfiguration, err = gorums.NewRawConfiguration(m.RawManager, cfg) + if err != nil { + return nil, err + } + {{- if $isQspec}} + // return an error if qspec is nil. + if qspec == nil { + return nil, {{use "fmt.Errorf" $genFile}}("config: missing required {{$qspecName}}") } - return c, nil + c.qspec = qspec + {{- end}} + // initialize the nodes slice + c.nodes = make([]*{{$nodeName}}, c.Size()) + for i, n := range c.RawConfiguration { + c.nodes[i] = &{{$nodeName}}{n} } -{{- end}} + return c, nil +} ` var managerMethodNodes = ` -{{- $genFile := .GenFile}} -{{- range .Services}} - {{- $service := .GoName}} - {{- $managerName := printf "%sManager" $service}} - {{- $nodeName := printf "%sNode" $service}} - // Nodes returns a slice of available nodes on this manager. - // IDs are returned in the order they were added at creation of the manager. - func (m *{{$managerName}}) Nodes() []*{{$nodeName}} { - gorumsNodes := m.RawManager.Nodes() - nodes := make([]*{{$nodeName}}, len(gorumsNodes)) - for i, n := range gorumsNodes { - nodes[i] = &{{$nodeName}}{n} - } - return nodes +// Nodes returns a slice of available nodes on this manager. +// IDs are returned in the order they were added at creation of the manager. +func (m *{{$managerName}}) Nodes() []*{{$nodeName}} { + gorumsNodes := m.RawManager.Nodes() + nodes := make([]*{{$nodeName}}, len(gorumsNodes)) + for i, n := range gorumsNodes { + nodes[i] = &{{$nodeName}}{n} } -{{- end}} + return nodes +} ` -var manager = managerVariables + managerStructs + managerConstructor + managerNewConfiguration + managerMethodNodes +var manager = managerVariables + + managerServicesBegin + + managerStructs + managerConstructor + managerNewConfiguration + managerMethodNodes + + managerServicesEnd diff --git a/examples/storage/proto/storage.pb.go b/examples/storage/proto/storage.pb.go index 3e4cc623..433e1b42 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.3 -// protoc v5.29.2 +// 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 ce7ce1f7..f0185ac3 100644 --- a/examples/storage/proto/storage_gorums.pb.go +++ b/examples/storage/proto/storage_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: storage/proto/storage.proto package proto @@ -53,7 +53,9 @@ type StorageConfiguration struct { gorums.RawConfiguration qspec StorageQuorumSpec nodes []*StorageNode -} // StorageQuorumSpecFromRaw returns a new StorageQuorumSpec from the given raw configuration and QuorumSpec. +} + +// StorageQuorumSpecFromRaw returns a new StorageQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -108,9 +110,9 @@ func NewStorageManager(opts ...gorums.ManagerOption) *StorageManager { return &StorageManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewStorageConfiguration returns a StorageConfiguration based on the provided list of nodes (required) -// and a quorum specification -// . +} + +// NewStorageConfiguration returns a StorageConfiguration based on the provided list of nodes (required)and a quorum specification. // 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. diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 00000000..b528810f --- /dev/null +++ b/go.work.sum @@ -0,0 +1,40 @@ +cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4= +cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw= +cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I= +cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.25.0 h1:3c8yed4lgqTt+oTQ+JNMDo+F4xprBf+O/il4ZC0nRLw= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.25.0/go.mod h1:obipzmGjfSjam60XLwGfqUkJsfiheAl+TUjG+4yzyPM= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cncf/xds/go v0.0.0-20241223141626-cff3c89139a3 h1:boJj011Hh+874zpIySeApCX4GeOjPl9qhRF3QuIZq+Q= +github.com/cncf/xds/go v0.0.0-20241223141626-cff3c89139a3/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= +github.com/envoyproxy/go-control-plane v0.13.4 h1:zEqyPVyku6IvWCFwux4x9RxkLOMUL+1vC9xUFv5l2/M= +github.com/envoyproxy/go-control-plane v0.13.4/go.mod h1:kDfuBlDVsSj2MjrLEtRWtHlsWIFcGyB2RMO44Dc5GZA= +github.com/envoyproxy/go-control-plane/envoy v1.32.4 h1:jb83lalDRZSpPWW2Z7Mck/8kXZ5CQAFYVjQcdVIr83A= +github.com/envoyproxy/go-control-plane/envoy v1.32.4/go.mod h1:Gzjc5k8JcJswLjAx1Zm+wSYE20UrLtt7JZMWiWQXQEw= +github.com/envoyproxy/go-control-plane/ratelimit v0.1.0 h1:/G9QYbddjL25KvtKTv3an9lx6VBE2cnb8wp1vEGNYGI= +github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJPzVVHnPgRKdUdwW/KdbRt94AzgRee4= +github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8= +github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU= +github.com/golang/glog v1.2.4 h1:CNNw5U8lSiiBk7druxtSHHTsRWcxKoac6kZKm2peBBc= +github.com/golang/glog v1.2.4/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= +github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.opentelemetry.io/contrib/detectors/gcp v1.34.0 h1:JRxssobiPg23otYU5SbWtQC//snGVIM3Tx6QRzlQBao= +go.opentelemetry.io/contrib/detectors/gcp v1.34.0/go.mod h1:cV4BMFcscUR/ckqLkbfQmF0PRsq8w/lMGzdbCSveBHo= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= +golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457 h1:zf5N6UOrA487eEFacMePxjXAJctxKmyjKUsjA11Uzuk= +golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 h1:GVIKPyP/kLIyVOgOnTwFOrvQaQUzOzGMCxgFUOEmm24= +google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422/go.mod h1:b6h1vNKhxaSoEI+5jc3PJUCustfli/mRab7295pY7rw= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/gorums.pb.go b/gorums.pb.go index b13fe39e..a701c84f 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: gorums.proto package gorums @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" + unsafe "unsafe" ) const ( @@ -113,47 +114,20 @@ 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, 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, 0xd5, 0x86, 0x03, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0b, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x36, - 0x0a, 0x05, 0x61, 0x73, 0x79, 0x6e, 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, 0xda, 0x86, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x05, 0x61, 0x73, 0x79, 0x6e, 0x63, 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, 0x3a, 0x4e, 0x0a, 0x12, 0x63, 0x75, - 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x74, 0x79, 0x70, 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, 0xee, 0x86, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, - 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x54, 0x79, 0x70, 0x65, 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" + + "\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" var file_gorums_proto_goTypes = []any{ (*descriptorpb.MethodOptions)(nil), // 0: google.protobuf.MethodOptions @@ -183,7 +157,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: 8, @@ -194,7 +168,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 0a87c360..d5b8e705 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: internal/correctable/opts.proto package correctable @@ -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/internal/testprotos/failing/reservednames/reserved.pb.go b/internal/testprotos/failing/reservednames/reserved.pb.go index 974f3b0b..a6cc5a0a 100644 --- a/internal/testprotos/failing/reservednames/reserved.pb.go +++ b/internal/testprotos/failing/reservednames/reserved.pb.go @@ -4,7 +4,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.3 -// protoc v5.29.2 +// protoc v6.30.2 // source: failing/reservednames/reserved.proto package reservednames diff --git a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go index dd265a47..6c612e59 100644 --- a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go +++ b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: failing/reservednames/reserved.proto package reservednames @@ -49,7 +49,9 @@ type ReservedConfiguration struct { gorums.RawConfiguration qspec ReservedQuorumSpec nodes []*ReservedNode -} // ReservedQuorumSpecFromRaw returns a new ReservedQuorumSpec from the given raw configuration and QuorumSpec. +} + +// ReservedQuorumSpecFromRaw returns a new ReservedQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -104,9 +106,9 @@ func NewReservedManager(opts ...gorums.ManagerOption) *ReservedManager { return &ReservedManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewReservedConfiguration returns a ReservedConfiguration based on the provided list of nodes (required) -// and a quorum specification -// . +} + +// NewReservedConfiguration returns a ReservedConfiguration based on the provided list of nodes (required)and a quorum specification. // 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. diff --git a/ordering/ordering.pb.go b/ordering/ordering.pb.go index f22a2baf..59ef371b 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: ordering/ordering.proto package ordering @@ -11,6 +11,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -120,27 +121,16 @@ func (b0 Metadata_builder) Build() *Metadata { 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, 0x6c, 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, 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\"l\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\x06Status2B\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, 1) var file_ordering_ordering_proto_goTypes = []any{ @@ -167,7 +157,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: 1, NumExtensions: 0, @@ -178,7 +168,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/ordering/ordering_grpc.pb.go b/ordering/ordering_grpc.pb.go index 385adba9..351b84c4 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/tests/config/config.pb.go b/tests/config/config.pb.go index 15ac7ef9..8012625d 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: config/config.proto package config @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -119,33 +120,26 @@ func (x *Response) GetNum() uint64 { 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_rawDescOnce sync.Once - file_config_config_proto_rawDescData = file_config_config_proto_rawDesc + 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(file_config_config_proto_rawDescData) + 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 } @@ -174,7 +168,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, @@ -185,7 +179,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 30763d70..37b9b8be 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: config/config.proto package config @@ -35,13 +35,22 @@ type ConfigTestClient interface { // enforce interface compliance var _ ConfigTestClient = (*ConfigTestConfiguration)(nil) +// ConfigTestNodeClient is the single node client interface for the ConfigTest service. +type ConfigTestNodeClient interface { +} + +// enforce interface compliance +var _ ConfigTestNodeClient = (*ConfigTestNode)(nil) + // A ConfigTestConfiguration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type ConfigTestConfiguration struct { gorums.RawConfiguration qspec ConfigTestQuorumSpec nodes []*ConfigTestNode -} // ConfigTestQuorumSpecFromRaw returns a new ConfigTestQuorumSpec from the given raw configuration and QuorumSpec. +} + +// ConfigTestQuorumSpecFromRaw returns a new ConfigTestQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -96,9 +105,9 @@ func NewConfigTestManager(opts ...gorums.ManagerOption) *ConfigTestManager { return &ConfigTestManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewConfigTestConfiguration returns a ConfigTestConfiguration based on the provided list of nodes (required) -// and a quorum specification -// . +} + +// NewConfigTestConfiguration returns a ConfigTestConfiguration based on the provided list of nodes (required)and a quorum specification. // 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. diff --git a/tests/correctable/correctable.pb.go b/tests/correctable/correctable.pb.go index d153562f..d6ae8f18 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: correctable/correctable.proto package correctable @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -103,42 +104,24 @@ func (x *CorrectableResponse) GetLevel() int32 { 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, 0xa8, 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, 0xa8, 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\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 = file_correctable_correctable_proto_rawDesc + 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(file_correctable_correctable_proto_rawDescData) + 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 } @@ -169,7 +152,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, @@ -180,7 +163,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 fe60ea01..86b81dbb 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: correctable/correctable.proto package correctable @@ -38,13 +38,22 @@ type CorrectableTestClient interface { // enforce interface compliance var _ CorrectableTestClient = (*CorrectableTestConfiguration)(nil) +// CorrectableTestNodeClient is the single node client interface for the CorrectableTest service. +type CorrectableTestNodeClient interface { +} + +// enforce interface compliance +var _ CorrectableTestNodeClient = (*CorrectableTestNode)(nil) + // A CorrectableTestConfiguration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type CorrectableTestConfiguration struct { gorums.RawConfiguration qspec CorrectableTestQuorumSpec nodes []*CorrectableTestNode -} // CorrectableTestQuorumSpecFromRaw returns a new CorrectableTestQuorumSpec from the given raw configuration and QuorumSpec. +} + +// CorrectableTestQuorumSpecFromRaw returns a new CorrectableTestQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -142,9 +151,9 @@ func NewCorrectableTestManager(opts ...gorums.ManagerOption) *CorrectableTestMan return &CorrectableTestManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewCorrectableTestConfiguration returns a CorrectableTestConfiguration based on the provided list of nodes (required) -// and a quorum specification -// . +} + +// NewCorrectableTestConfiguration returns a CorrectableTestConfiguration based on the provided list of nodes (required)and a quorum specification. // 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. diff --git a/tests/dummy/dummy.pb.go b/tests/dummy/dummy.pb.go index 7ef7db97..311ac0bc 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: dummy/dummy.proto package dummy @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -58,26 +59,21 @@ func (*Empty) Descriptor() ([]byte, []int) { 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_rawDescOnce sync.Once - file_dummy_dummy_proto_rawDescData = file_dummy_dummy_proto_rawDesc + 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(file_dummy_dummy_proto_rawDescData) + 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 } @@ -105,7 +101,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, @@ -116,7 +112,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 ee2dccd2..9e2f1a60 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: dummy/dummy.proto package dummy @@ -25,20 +25,14 @@ func init() { } } -// DummyNodeClient is the single node client interface for the Dummy service. -type DummyNodeClient interface { - Test(ctx context.Context, in *Empty) (resp *Empty, err error) -} - -// enforce interface compliance -var _ DummyNodeClient = (*DummyNode)(nil) - // A DummyConfiguration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type DummyConfiguration struct { gorums.RawConfiguration nodes []*DummyNode -} // DummyQuorumSpecFromRaw returns a new DummyQuorumSpec from the given raw configuration. +} + +// DummyQuorumSpecFromRaw returns a new DummyQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -88,8 +82,9 @@ func NewDummyManager(opts ...gorums.ManagerOption) *DummyManager { return &DummyManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewDummyConfiguration returns a DummyConfiguration based on the provided list of nodes (required) -// . +} + +// NewDummyConfiguration returns a DummyConfiguration based on the provided list of nodes (required). // 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. diff --git a/tests/metadata/metadata.pb.go b/tests/metadata/metadata.pb.go index 05e67ad1..f4facc2c 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: metadata/metadata.proto package metadata @@ -12,6 +12,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -111,37 +112,25 @@ func (x *IPAddr) GetAddr() string { 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_rawDescOnce sync.Once - file_metadata_metadata_proto_rawDescData = file_metadata_metadata_proto_rawDesc + 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(file_metadata_metadata_proto_rawDescData) + 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 } @@ -173,7 +162,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, @@ -184,7 +173,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 823ed257..976fb451 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: metadata/metadata.proto package metadata @@ -26,21 +26,14 @@ func init() { } } -// MetadataTestNodeClient is the single node client interface for the MetadataTest service. -type MetadataTestNodeClient interface { - IDFromMD(ctx context.Context, in *emptypb.Empty) (resp *NodeID, err error) - WhatIP(ctx context.Context, in *emptypb.Empty) (resp *IPAddr, err error) -} - -// enforce interface compliance -var _ MetadataTestNodeClient = (*MetadataTestNode)(nil) - // A MetadataTestConfiguration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type MetadataTestConfiguration struct { gorums.RawConfiguration nodes []*MetadataTestNode -} // MetadataTestQuorumSpecFromRaw returns a new MetadataTestQuorumSpec from the given raw configuration. +} + +// MetadataTestQuorumSpecFromRaw returns a new MetadataTestQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -90,8 +83,9 @@ func NewMetadataTestManager(opts ...gorums.ManagerOption) *MetadataTestManager { return &MetadataTestManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewMetadataTestConfiguration returns a MetadataTestConfiguration based on the provided list of nodes (required) -// . +} + +// NewMetadataTestConfiguration returns a MetadataTestConfiguration based on the provided list of nodes (required). // 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. diff --git a/tests/oneway/oneway.pb.go b/tests/oneway/oneway.pb.go index 18c78284..7a0136f9 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: oneway/oneway.proto package oneway @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -103,37 +104,26 @@ func (*Empty) Descriptor() ([]byte, []int) { 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_rawDescOnce sync.Once - file_oneway_oneway_proto_rawDescData = file_oneway_oneway_proto_rawDesc + 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(file_oneway_oneway_proto_rawDescData) + 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 } @@ -166,7 +156,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, @@ -177,7 +167,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 281f5152..d35ee71f 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: oneway/oneway.proto package oneway @@ -48,7 +48,9 @@ var _ OnewayTestNodeClient = (*OnewayTestNode)(nil) type OnewayTestConfiguration struct { gorums.RawConfiguration nodes []*OnewayTestNode -} // OnewayTestQuorumSpecFromRaw returns a new OnewayTestQuorumSpec from the given raw configuration. +} + +// OnewayTestQuorumSpecFromRaw returns a new OnewayTestQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -98,8 +100,9 @@ func NewOnewayTestManager(opts ...gorums.ManagerOption) *OnewayTestManager { return &OnewayTestManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewOnewayTestConfiguration returns a OnewayTestConfiguration based on the provided list of nodes (required) -// . +} + +// NewOnewayTestConfiguration returns a OnewayTestConfiguration based on the provided list of nodes (required). // 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. diff --git a/tests/ordering/order.pb.go b/tests/ordering/order.pb.go index 72d18e8a..1bcc088c 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: ordering/order.proto package ordering @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -111,39 +112,27 @@ func (x *Response) GetInOrder() bool { 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, 0xb0, 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, 0x3a, 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, 0x08, 0xa0, 0xb5, 0x18, 0x01, 0xd0, 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\xb0\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" + + "\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 = file_ordering_order_proto_rawDesc + 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(file_ordering_order_proto_rawDescData) + 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 } @@ -176,7 +165,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, @@ -187,7 +176,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 fb39ef40..3ffa1d41 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: ordering/order.proto package ordering @@ -70,7 +70,9 @@ type GorumsTestConfiguration struct { gorums.RawConfiguration qspec GorumsTestQuorumSpec nodes []*GorumsTestNode -} // GorumsTestQuorumSpecFromRaw returns a new GorumsTestQuorumSpec from the given raw configuration and QuorumSpec. +} + +// GorumsTestQuorumSpecFromRaw returns a new GorumsTestQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -125,9 +127,9 @@ func NewGorumsTestManager(opts ...gorums.ManagerOption) *GorumsTestManager { return &GorumsTestManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewGorumsTestConfiguration returns a GorumsTestConfiguration based on the provided list of nodes (required) -// and a quorum specification -// . +} + +// NewGorumsTestConfiguration returns a GorumsTestConfiguration based on the provided list of nodes (required)and a quorum specification. // 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. diff --git a/tests/qf/qf.pb.go b/tests/qf/qf.pb.go index 6da39825..b3469279 100644 --- a/tests/qf/qf.pb.go +++ b/tests/qf/qf.pb.go @@ -2,8 +2,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: qf/qf.proto package qf @@ -14,6 +14,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -113,34 +114,25 @@ func (x *Response) GetResult() int64 { 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_rawDescOnce sync.Once - file_qf_qf_proto_rawDescData = file_qf_qf_proto_rawDesc + 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(file_qf_qf_proto_rawDescData) + 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 } @@ -171,7 +163,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, @@ -182,7 +174,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 df1d16e1..07da4cf2 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: qf/qf.proto package qf @@ -36,13 +36,22 @@ type QuorumFunctionClient interface { // enforce interface compliance var _ QuorumFunctionClient = (*QuorumFunctionConfiguration)(nil) +// QuorumFunctionNodeClient is the single node client interface for the QuorumFunction service. +type QuorumFunctionNodeClient interface { +} + +// enforce interface compliance +var _ QuorumFunctionNodeClient = (*QuorumFunctionNode)(nil) + // A QuorumFunctionConfiguration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type QuorumFunctionConfiguration struct { gorums.RawConfiguration qspec QuorumFunctionQuorumSpec nodes []*QuorumFunctionNode -} // QuorumFunctionQuorumSpecFromRaw returns a new QuorumFunctionQuorumSpec from the given raw configuration and QuorumSpec. +} + +// QuorumFunctionQuorumSpecFromRaw returns a new QuorumFunctionQuorumSpec from the given raw configuration and QuorumSpec. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -97,9 +106,9 @@ func NewQuorumFunctionManager(opts ...gorums.ManagerOption) *QuorumFunctionManag return &QuorumFunctionManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewQuorumFunctionConfiguration returns a QuorumFunctionConfiguration based on the provided list of nodes (required) -// and a quorum specification -// . +} + +// NewQuorumFunctionConfiguration returns a QuorumFunctionConfiguration based on the provided list of nodes (required)and a quorum specification. // 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. diff --git a/tests/tls/tls.pb.go b/tests/tls/tls.pb.go index e7b3fec7..d1e1bcf1 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: tls/tls.proto package tls @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -102,28 +103,23 @@ func (x *Response) GetOK() bool { 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_rawDescOnce sync.Once - file_tls_tls_proto_rawDescData = file_tls_tls_proto_rawDesc + 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(file_tls_tls_proto_rawDescData) + 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 } @@ -152,7 +148,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, @@ -163,7 +159,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 7633f1c8..09991622 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: tls/tls.proto package tls @@ -25,20 +25,14 @@ func init() { } } -// TLSNodeClient is the single node client interface for the TLS service. -type TLSNodeClient interface { - TestTLS(ctx context.Context, in *Request) (resp *Response, err error) -} - -// enforce interface compliance -var _ TLSNodeClient = (*TLSNode)(nil) - // A TLSConfiguration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type TLSConfiguration struct { gorums.RawConfiguration nodes []*TLSNode -} // TLSQuorumSpecFromRaw returns a new TLSQuorumSpec from the given raw configuration. +} + +// TLSQuorumSpecFromRaw returns a new TLSQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -88,8 +82,9 @@ func NewTLSManager(opts ...gorums.ManagerOption) *TLSManager { return &TLSManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewTLSConfiguration returns a TLSConfiguration based on the provided list of nodes (required) -// . +} + +// NewTLSConfiguration returns a TLSConfiguration based on the provided list of nodes (required). // 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. diff --git a/tests/unresponsive/unresponsive.pb.go b/tests/unresponsive/unresponsive.pb.go index 0b180d4d..153bf773 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.3 -// protoc v5.29.2 +// protoc-gen-go v1.36.6 +// protoc v6.30.2 // source: unresponsive/unresponsive.proto package unresponsive @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -58,30 +59,21 @@ func (*Empty) Descriptor() ([]byte, []int) { 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_rawDescOnce sync.Once - file_unresponsive_unresponsive_proto_rawDescData = file_unresponsive_unresponsive_proto_rawDesc + 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(file_unresponsive_unresponsive_proto_rawDescData) + 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 } @@ -109,7 +101,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, @@ -120,7 +112,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 178be4c6..9790f836 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: // protoc-gen-gorums v0.8.0-devel -// protoc v5.29.2 +// protoc v6.30.2 // source: unresponsive/unresponsive.proto package unresponsive @@ -25,20 +25,14 @@ func init() { } } -// UnresponsiveNodeClient is the single node client interface for the Unresponsive service. -type UnresponsiveNodeClient interface { - TestUnresponsive(ctx context.Context, in *Empty) (resp *Empty, err error) -} - -// enforce interface compliance -var _ UnresponsiveNodeClient = (*UnresponsiveNode)(nil) - // A UnresponsiveConfiguration represents a static set of nodes on which quorum remote // procedure calls may be invoked. type UnresponsiveConfiguration struct { gorums.RawConfiguration nodes []*UnresponsiveNode -} // UnresponsiveQuorumSpecFromRaw returns a new UnresponsiveQuorumSpec from the given raw configuration. +} + +// UnresponsiveQuorumSpecFromRaw returns a new UnresponsiveQuorumSpec from the given raw configuration. // // This function may for example be used to "clone" a configuration but install a different QuorumSpec: // @@ -88,8 +82,9 @@ func NewUnresponsiveManager(opts ...gorums.ManagerOption) *UnresponsiveManager { return &UnresponsiveManager{ RawManager: gorums.NewRawManager(opts...), } -} // NewUnresponsiveConfiguration returns a UnresponsiveConfiguration based on the provided list of nodes (required) -// . +} + +// NewUnresponsiveConfiguration returns a UnresponsiveConfiguration based on the provided list of nodes (required). // 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. From daaa6535b8f5de0094906797f5d6f1a22844315e Mon Sep 17 00:00:00 2001 From: asbjorn Date: Tue, 13 May 2025 14:12:04 +0200 Subject: [PATCH 09/11] add the serviceTypeName template func to detect name collisions --- benchmark/benchmark_gorums.pb.go | 4 +- .../dev/zorums_client_gorums.pb.go | 2 +- .../dev/zorums_configuration_gorums.pb.go | 2 +- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_node_gorums.pb.go | 2 +- .../dev/zorums_quorumcall_gorums.pb.go | 2 +- .../dev/zorums_rpc_gorums.pb.go | 2 +- .../dev/zorums_server_gorums.pb.go | 29 +++--- .../dev/zorums_unicast_gorums.pb.go | 2 +- .../gengorums/gorums_func_map.go | 4 + .../gengorums/template_async.go | 12 +-- .../gengorums/template_client.go | 12 +-- .../gengorums/template_configuration.go | 9 +- .../gengorums/template_correctable.go | 12 +-- .../gengorums/template_multicast.go | 10 +-- .../gengorums/template_node.go | 6 +- .../gengorums/template_quorumcall.go | 26 +++--- .../gengorums/template_rpc.go | 8 +- .../gengorums/template_server.go | 38 ++++---- .../failing/reservednames/reserved.pb.go | 88 +++++++++---------- .../failing/reservednames/reserved.proto | 10 +-- .../reservednames/reserved_gorums.pb.go | 24 ++--- tests/config/config_gorums.pb.go | 4 +- tests/correctable/correctable_gorums.pb.go | 4 +- tests/dummy/dummy_gorums.pb.go | 16 +--- tests/metadata/metadata_gorums.pb.go | 23 +---- tests/oneway/oneway_gorums.pb.go | 4 +- tests/ordering/order_gorums.pb.go | 4 +- tests/qf/qf_gorums.pb.go | 4 +- tests/tls/tls_gorums.pb.go | 16 +--- tests/unresponsive/unresponsive_gorums.pb.go | 16 +--- 31 files changed, 172 insertions(+), 225 deletions(-) diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 998aa77f..655e75db 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: benchmark/benchmark.proto @@ -243,7 +243,7 @@ func (c *BenchmarkConfiguration) SlowServer(ctx context.Context, in *Echo) gorum return gorums.QuorumCall[*Echo](ctx, c.RawConfiguration, cd) } -// Benchmark is the server-side API for the Benchmark Service +// BenchmarkServer is the server-side API for the Benchmark Service type BenchmarkServer interface { StartServerBenchmark(ctx gorums.ServerCtx, request *StartRequest) (response *StartResponse, err error) StopServerBenchmark(ctx gorums.ServerCtx, request *StopRequest) (response *Result, 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 9ca1fabd..dc988dbe 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go index 98bb4825..63850d75 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // 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 696409ad..d70fd614 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go index 9fa766b9..dcbab81e 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // 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 10c9b4af..f2e36635 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // 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 c6e7b5c2..a8f1177d 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // 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 8527ef3a..a663e3cf 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: zorums.proto @@ -20,7 +20,7 @@ const ( _ = gorums.EnforceVersion(gorums.MaxVersion - 9) ) -// ZorumsService is the server-side API for the ZorumsService Service +// ZorumsServiceServer is the server-side API for the ZorumsService Service type ZorumsServiceServer interface { GRPCCall(ctx gorums.ServerCtx, request *Request) (response *Response, err error) QuorumCall(ctx gorums.ServerCtx, request *Request) (response *Response, err error) @@ -40,18 +40,6 @@ type ZorumsServiceServer interface { Unicast2(ctx gorums.ServerCtx, request *Request) } -// ZorumsNoQCService is the server-side API for the ZorumsNoQCService Service -type ZorumsNoQCServiceServer interface { - GRPCCall(ctx gorums.ServerCtx, request *Request) (response *Response, err 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) - Unicast(ctx gorums.ServerCtx, request *Request) - Unicast2(ctx gorums.ServerCtx, request *Request) -} - func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { srv.RegisterHandler("dev.ZorumsService.GRPCCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) @@ -167,6 +155,19 @@ func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { impl.Unicast2(ctx, req) }) } + +// ZorumsNoQCServiceServer is the server-side API for the ZorumsNoQCService Service +type ZorumsNoQCServiceServer interface { + GRPCCall(ctx gorums.ServerCtx, request *Request) (response *Response, err 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) + Unicast(ctx gorums.ServerCtx, request *Request) + Unicast2(ctx gorums.ServerCtx, request *Request) +} + func RegisterZorumsNoQCServiceServer(srv *gorums.Server, impl ZorumsNoQCServiceServer) { srv.RegisterHandler("dev.ZorumsNoQCService.GRPCCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) 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 a79ad412..4ff07c93 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go index bd51879b..60358daa 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go @@ -58,6 +58,10 @@ var funcMap = template.FuncMap{ } return g.QualifiedGoIdent(pkg.Ident(ident)) }, + "serviceTypeName": func(serviceName, typeName string) string { + // TODO(Asbjørn): set the type name as reserved + return serviceName + typeName + }, "hasPerNodeArg": func(method *protogen.Method) bool { return hasMethodOption(method, gorums.E_PerNodeArg) }, diff --git a/cmd/protoc-gen-gorums/gengorums/template_async.go b/cmd/protoc-gen-gorums/gengorums/template_async.go index d0ef7a9b..7f7cd886 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_async.go +++ b/cmd/protoc-gen-gorums/gengorums/template_async.go @@ -27,7 +27,7 @@ var asyncSignature = `func (c *{{$configurationName}}) {{$method}}(` + `*{{$asyncOut}} {` var asyncVar = qcVar + ` -{{$asyncOut := outType .Method $customOut}} +{{- $asyncOut := outType .Method $customOut}} ` var asyncBody = ` cd := {{$callData}}{ @@ -41,11 +41,11 @@ var asyncBody = ` cd := {{$callData}}{ } 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}} + {{- 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} diff --git a/cmd/protoc-gen-gorums/gengorums/template_client.go b/cmd/protoc-gen-gorums/gengorums/template_client.go index 1a0221d4..ba7ed24d 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_client.go +++ b/cmd/protoc-gen-gorums/gengorums/template_client.go @@ -6,9 +6,9 @@ import ( // gorums need to be imported in the zorums file var clientVariables = ` -{{$context := use "context.Context" .GenFile}} -{{$_ := use "gorums.EnforceVersion" .GenFile}} -{{$callOpt := use "gorums.CallOption" .GenFile}} +{{- $context := use "context.Context" .GenFile}} +{{- $_ := use "gorums.EnforceVersion" .GenFile}} +{{- $callOpt := use "gorums.CallOption" .GenFile}} ` var clientServicesBegin = ` @@ -22,7 +22,7 @@ var clientServicesEnd = ` ` var clientConfigurationInterface = ` - {{- $interfaceName := printf "%sClient" $service}} + {{- $interfaceName := serviceTypeName $service "Client"}} {{- $configurationName := printf "%sConfiguration" $service}} // {{$interfaceName}} is the client interface for the {{$service}} service. type {{$interfaceName}} interface { @@ -42,8 +42,8 @@ var clientConfigurationInterface = ` ` var clientNodeInterface = ` - {{- $interfaceName := printf "%sNodeClient" $service}} - {{- $nodeName := printf "%sNode" $service}} + {{- $interfaceName := serviceTypeName $service "NodeClient"}} + {{- $nodeName := serviceTypeName $service "Node"}} // {{$interfaceName}} is the single node client interface for the {{$service}} service. type {{$interfaceName}} interface { {{- range nodeMethods .Methods}} diff --git a/cmd/protoc-gen-gorums/gengorums/template_configuration.go b/cmd/protoc-gen-gorums/gengorums/template_configuration.go index 65fa618d..96212889 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_configuration.go +++ b/cmd/protoc-gen-gorums/gengorums/template_configuration.go @@ -1,17 +1,16 @@ package gengorums var configurationVars = ` -{{$rawConfiguration := use "gorums.RawConfiguration" .GenFile}} -{{$nodeListOptions := use "gorums.NodeListOption" .GenFile}} +{{- $rawConfiguration := use "gorums.RawConfiguration" .GenFile}} +{{- $nodeListOptions := use "gorums.NodeListOption" .GenFile}} ` var configurationServicesBegin = ` {{- $genFile := .GenFile}} {{- range .Services}} {{- $service := .GoName}} - {{- $configurationName := printf "%sConfiguration" $service}} - {{- $qspecName := printf "%sQuorumSpec" $service}} - {{- $nodeName := printf "%sNode" $service}} + {{- $configurationName := serviceTypeName $service "Configuration"}} + {{- $nodeName := serviceTypeName $service "Node"}} ` var configurationServicesEnd = ` diff --git a/cmd/protoc-gen-gorums/gengorums/template_correctable.go b/cmd/protoc-gen-gorums/gengorums/template_correctable.go index 1f7b675f..9a5a1af8 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_correctable.go +++ b/cmd/protoc-gen-gorums/gengorums/template_correctable.go @@ -25,12 +25,12 @@ var correctableCallComment = ` ` 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}} + {{- $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 *{{$configurationName}}) {{$method}}(` + diff --git a/cmd/protoc-gen-gorums/gengorums/template_multicast.go b/cmd/protoc-gen-gorums/gengorums/template_multicast.go index 413d2aea..40c56ad8 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_multicast.go +++ b/cmd/protoc-gen-gorums/gengorums/template_multicast.go @@ -8,11 +8,11 @@ var _ {{$out}} ` var mcVar = ` - {{$callData := use "gorums.QuorumCallData" .GenFile}} - {{$genFile := .GenFile}} - {{$unexportMethod := unexport .Method.GoName}} - {{$context := use "context.Context" .GenFile}} - {{$callOpt := use "gorums.CallOption" .GenFile}} + {{- $callData := use "gorums.QuorumCallData" .GenFile}} + {{- $genFile := .GenFile}} + {{- $unexportMethod := unexport .Method.GoName}} + {{- $context := use "context.Context" .GenFile}} + {{- $callOpt := use "gorums.CallOption" .GenFile}} ` var multicastSignature = `func (c *{{$configurationName}}) {{$method}}(` + diff --git a/cmd/protoc-gen-gorums/gengorums/template_node.go b/cmd/protoc-gen-gorums/gengorums/template_node.go index 1680c3d2..e7f26b16 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_node.go +++ b/cmd/protoc-gen-gorums/gengorums/template_node.go @@ -2,15 +2,15 @@ package gengorums // gorums need to be imported in the zorums file var nodeVariables = ` -{{$_ := use "gorums.EnforceVersion" .GenFile}} -{{$callOpt := use "gorums.CallOption" .GenFile}} +{{- $_ := use "gorums.EnforceVersion" .GenFile}} +{{- $callOpt := use "gorums.CallOption" .GenFile}} ` var nodeStructs = ` {{- $genFile := .GenFile}} {{- range .Services}} {{- $service := .GoName}} - {{- $nodeName := printf "%sNode" $service}} + {{- $nodeName := serviceTypeName $service "Node"}} // {{$nodeName}} holds the node specific methods for the {{$service}} service. type {{$nodeName}} struct { *gorums.RawNode diff --git a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go index b3ecd803..bf12253e 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go +++ b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go @@ -2,15 +2,15 @@ package gengorums // Common variables used in several template functions. var commonVariables = ` -{{$fullName := .Method.Desc.FullName}} -{{$method := .Method.GoName}} -{{$in := in .GenFile .Method}} -{{$out := out .GenFile .Method}} -{{$intOut := internalOut $out}} -{{$unexportOutput := unexport .Method.Output.GoIdent.GoName}} -{{$serviceName := .Method.Parent.GoName}} -{{$nodeName := printf "%sNode" $serviceName}} -{{$configurationName := printf "%sConfiguration" $serviceName}} +{{- $fullName := .Method.Desc.FullName}} +{{- $method := .Method.GoName}} +{{- $in := in .GenFile .Method}} +{{- $out := out .GenFile .Method}} +{{- $intOut := internalOut $out}} +{{- $unexportOutput := unexport .Method.Output.GoIdent.GoName}} +{{- $serviceName := .Method.Parent.GoName}} +{{- $nodeName := serviceTypeName $serviceName "Node"}} +{{- $configurationName := serviceTypeName $serviceName "Configuration"}} ` // Common variables used in several template functions. @@ -46,10 +46,10 @@ var quorumCallSignature = `func (c *{{$configurationName}}) {{$method}}(` + ` var qcVar = ` -{{$callData := use "gorums.QuorumCallData" .GenFile}} -{{$genFile := .GenFile}} -{{$unexportMethod := unexport .Method.GoName}} -{{$context := use "context.Context" .GenFile}} +{{- $callData := use "gorums.QuorumCallData" .GenFile}} +{{- $genFile := .GenFile}} +{{- $unexportMethod := unexport .Method.GoName}} +{{- $context := use "context.Context" .GenFile}} ` var quorumCallBody = ` cd := {{$callData}}{ diff --git a/cmd/protoc-gen-gorums/gengorums/template_rpc.go b/cmd/protoc-gen-gorums/gengorums/template_rpc.go index 832b5a15..9c54a37d 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_rpc.go +++ b/cmd/protoc-gen-gorums/gengorums/template_rpc.go @@ -1,10 +1,10 @@ package gengorums var rpcVar = ` - {{$callData := use "gorums.CallData" .GenFile}} - {{$genFile := .GenFile}} - {{$unexportMethod := unexport .Method.GoName}} - {{$context := use "context.Context" .GenFile}} + {{- $callData := use "gorums.CallData" .GenFile}} + {{- $genFile := .GenFile}} + {{- $unexportMethod := unexport .Method.GoName}} + {{- $context := use "context.Context" .GenFile}} ` var rpcSignature = `func (n *{{$nodeName}}) {{$method}}(` + diff --git a/cmd/protoc-gen-gorums/gengorums/template_server.go b/cmd/protoc-gen-gorums/gengorums/template_server.go index c513aab9..1c18a47f 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_server.go +++ b/cmd/protoc-gen-gorums/gengorums/template_server.go @@ -1,15 +1,26 @@ package gengorums var serverVariables = ` -{{$context := use "gorums.ServerCtx" .GenFile}} +{{- $context := use "gorums.ServerCtx" .GenFile}} +{{- $gorumsMessage := use "gorums.Message" .GenFile}} +{{- $wrapMessage := use "gorums.WrapMessage" .GenFile}} +{{- $sendMessage := use "gorums.SendMessage" .GenFile}} +` + +var serverServicesBegin = ` +{{- $genFile := .GenFile}} +{{- range configurationsServices .Services}} + {{- $service := .GoName}} + {{- $serverName := serviceTypeName $service "Server"}} +` + +var serverServicesEnd = ` +{{- end}} ` var serverInterface = ` -{{$genFile := .GenFile}} -{{range .Services -}} -{{$service := .GoName}} -// {{$service}} is the server-side API for the {{$service}} Service -type {{$service}}Server interface { +// {{$serverName}} is the server-side API for the {{$service}} Service +type {{$serverName}} interface { {{- range .Methods}} {{- if isOneway .}} {{.GoName}}(ctx {{$context}}, request *{{in $genFile .}}) @@ -20,17 +31,10 @@ type {{$service}}Server interface { {{- end}} {{- end}} } -{{- end}} ` var registerInterface = ` -{{$genFile := .GenFile}} -{{$gorumsMessage := use "gorums.Message" .GenFile}} -{{$wrapMessage := use "gorums.WrapMessage" $genFile}} -{{$sendMessage := use "gorums.SendMessage" $genFile}} -{{range .Services -}} -{{$service := .GoName}} -func Register{{$service}}Server(srv *{{use "gorums.Server" $genFile}}, impl {{$service}}Server) { +func Register{{$serverName}}(srv *{{use "gorums.Server" $genFile}}, impl {{$serverName}}) { {{- range .Methods}} srv.RegisterHandler("{{.Desc.FullName}}", func(ctx {{$context}}, in *{{$gorumsMessage}}, {{if isOneway .}} _ {{- else}} finished {{- end}} chan<- *{{$gorumsMessage}}) { req := in.Message.(*{{in $genFile .}}) @@ -53,7 +57,9 @@ func Register{{$service}}Server(srv *{{use "gorums.Server" $genFile}}, impl {{$s }) {{- end}} } -{{- end}} ` -var server = serverVariables + serverInterface + registerInterface +var server = serverVariables + + serverServicesBegin + + serverInterface + registerInterface + + serverServicesEnd diff --git a/internal/testprotos/failing/reservednames/reserved.pb.go b/internal/testprotos/failing/reservednames/reserved.pb.go index 3bf1231c..879ebfef 100644 --- a/internal/testprotos/failing/reservednames/reserved.pb.go +++ b/internal/testprotos/failing/reservednames/reserved.pb.go @@ -24,27 +24,27 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type Configuration struct { +type ReservedConfiguration struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Conf string `protobuf:"bytes,1,opt,name=Conf"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *Configuration) Reset() { - *x = Configuration{} +func (x *ReservedConfiguration) Reset() { + *x = ReservedConfiguration{} mi := &file_failing_reservednames_reserved_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *Configuration) String() string { +func (x *ReservedConfiguration) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Configuration) ProtoMessage() {} +func (*ReservedConfiguration) ProtoMessage() {} -func (x *Configuration) ProtoReflect() protoreflect.Message { +func (x *ReservedConfiguration) ProtoReflect() protoreflect.Message { mi := &file_failing_reservednames_reserved_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -56,52 +56,52 @@ func (x *Configuration) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -func (x *Configuration) GetConf() string { +func (x *ReservedConfiguration) GetConf() string { if x != nil { return x.xxx_hidden_Conf } return "" } -func (x *Configuration) SetConf(v string) { +func (x *ReservedConfiguration) SetConf(v string) { x.xxx_hidden_Conf = v } -type Configuration_builder struct { +type ReservedConfiguration_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Conf string } -func (b0 Configuration_builder) Build() *Configuration { - m0 := &Configuration{} +func (b0 ReservedConfiguration_builder) Build() *ReservedConfiguration { + m0 := &ReservedConfiguration{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Conf = b.Conf return m0 } -type Manager struct { - state protoimpl.MessageState `protogen:"opaque.v1"` - xxx_hidden_Mgr string `protobuf:"bytes,1,opt,name=Mgr"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache +type ReservedNode struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Node string `protobuf:"bytes,1,opt,name=Node"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (x *Manager) Reset() { - *x = Manager{} +func (x *ReservedNode) Reset() { + *x = ReservedNode{} mi := &file_failing_reservednames_reserved_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *Manager) String() string { +func (x *ReservedNode) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Manager) ProtoMessage() {} +func (*ReservedNode) ProtoMessage() {} -func (x *Manager) ProtoReflect() protoreflect.Message { +func (x *ReservedNode) ProtoReflect() protoreflect.Message { mi := &file_failing_reservednames_reserved_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -113,28 +113,28 @@ func (x *Manager) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -func (x *Manager) GetMgr() string { +func (x *ReservedNode) GetNode() string { if x != nil { - return x.xxx_hidden_Mgr + return x.xxx_hidden_Node } return "" } -func (x *Manager) SetMgr(v string) { - x.xxx_hidden_Mgr = v +func (x *ReservedNode) SetNode(v string) { + x.xxx_hidden_Node = v } -type Manager_builder struct { +type ReservedNode_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. - Mgr string + Node string } -func (b0 Manager_builder) Build() *Manager { - m0 := &Manager{} +func (b0 ReservedNode_builder) Build() *ReservedNode { + m0 := &ReservedNode{} b, x := &b0, m0 _, _ = b, x - x.xxx_hidden_Mgr = b.Mgr + x.xxx_hidden_Node = b.Node return m0 } @@ -142,26 +142,26 @@ var File_failing_reservednames_reserved_proto protoreflect.FileDescriptor const file_failing_reservednames_reserved_proto_rawDesc = "" + "\n" + - "$failing/reservednames/reserved.proto\x12'gorums.testprotos.failing.reservednames\x1a\fgorums.proto\"#\n" + - "\rConfiguration\x12\x12\n" + - "\x04Conf\x18\x01 \x01(\tR\x04Conf\"\x1b\n" + - "\aManager\x12\x10\n" + - "\x03Mgr\x18\x01 \x01(\tR\x03Mgr2\x80\x02\n" + - "\bReserved\x12v\n" + - "\bConfTest\x126.gorums.testprotos.failing.reservednames.Configuration\x1a0.gorums.testprotos.failing.reservednames.Manager\"\x00\x12|\n" + + "$failing/reservednames/reserved.proto\x12'gorums.testprotos.failing.reservednames\x1a\fgorums.proto\"+\n" + + "\x15ReservedConfiguration\x12\x12\n" + + "\x04Conf\x18\x01 \x01(\tR\x04Conf\"\"\n" + + "\fReservedNode\x12\x12\n" + + "\x04Node\x18\x01 \x01(\tR\x04Node2\x9c\x02\n" + + "\bReserved\x12\x83\x01\n" + + "\bConfTest\x12>.gorums.testprotos.failing.reservednames.ReservedConfiguration\x1a5.gorums.testprotos.failing.reservednames.ReservedNode\"\x00\x12\x89\x01\n" + "\n" + - "QuorumCall\x126.gorums.testprotos.failing.reservednames.Configuration\x1a0.gorums.testprotos.failing.reservednames.Manager\"\x04\xa0\xb5\x18\x01BHZAgithub.com/relab/gorums/internal/testprotos/failing/reservednames\x92\x03\x02\b\x02b\beditionsp\xe8\a" + "QuorumCall\x12>.gorums.testprotos.failing.reservednames.ReservedConfiguration\x1a5.gorums.testprotos.failing.reservednames.ReservedNode\"\x04\xa0\xb5\x18\x01BHZAgithub.com/relab/gorums/internal/testprotos/failing/reservednames\x92\x03\x02\b\x02b\beditionsp\xe8\a" var file_failing_reservednames_reserved_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_failing_reservednames_reserved_proto_goTypes = []any{ - (*Configuration)(nil), // 0: gorums.testprotos.failing.reservednames.Configuration - (*Manager)(nil), // 1: gorums.testprotos.failing.reservednames.Manager + (*ReservedConfiguration)(nil), // 0: gorums.testprotos.failing.reservednames.ReservedConfiguration + (*ReservedNode)(nil), // 1: gorums.testprotos.failing.reservednames.ReservedNode } var file_failing_reservednames_reserved_proto_depIdxs = []int32{ - 0, // 0: gorums.testprotos.failing.reservednames.Reserved.ConfTest:input_type -> gorums.testprotos.failing.reservednames.Configuration - 0, // 1: gorums.testprotos.failing.reservednames.Reserved.QuorumCall:input_type -> gorums.testprotos.failing.reservednames.Configuration - 1, // 2: gorums.testprotos.failing.reservednames.Reserved.ConfTest:output_type -> gorums.testprotos.failing.reservednames.Manager - 1, // 3: gorums.testprotos.failing.reservednames.Reserved.QuorumCall:output_type -> gorums.testprotos.failing.reservednames.Manager + 0, // 0: gorums.testprotos.failing.reservednames.Reserved.ConfTest:input_type -> gorums.testprotos.failing.reservednames.ReservedConfiguration + 0, // 1: gorums.testprotos.failing.reservednames.Reserved.QuorumCall:input_type -> gorums.testprotos.failing.reservednames.ReservedConfiguration + 1, // 2: gorums.testprotos.failing.reservednames.Reserved.ConfTest:output_type -> gorums.testprotos.failing.reservednames.ReservedNode + 1, // 3: gorums.testprotos.failing.reservednames.Reserved.QuorumCall:output_type -> gorums.testprotos.failing.reservednames.ReservedNode 2, // [2:4] is the sub-list for method output_type 0, // [0:2] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/internal/testprotos/failing/reservednames/reserved.proto b/internal/testprotos/failing/reservednames/reserved.proto index 13399cf5..8782fc64 100644 --- a/internal/testprotos/failing/reservednames/reserved.proto +++ b/internal/testprotos/failing/reservednames/reserved.proto @@ -11,15 +11,15 @@ option features.field_presence = IMPLICIT; import "gorums.proto"; service Reserved { - rpc ConfTest(Configuration) returns (Manager) {} - rpc QuorumCall(Configuration) returns (Manager) { + rpc ConfTest(ReservedConfiguration) returns (ReservedNode) {} + rpc QuorumCall(ReservedConfiguration) returns (ReservedNode) { option (gorums.quorumcall) = true; } } -message Configuration { +message ReservedConfiguration { string Conf = 1; } -message Manager { - string Mgr = 1; +message ReservedNode { + string Node = 1; } diff --git a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go index 1ca1ac7c..db953ead 100644 --- a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go +++ b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: failing/reservednames/reserved.proto @@ -27,7 +27,7 @@ func init() { // ReservedClient is the client interface for the Reserved service. type ReservedClient interface { - QuorumCall(ctx context.Context, in *Configuration) gorums.Responses[*Manager] + QuorumCall(ctx context.Context, in *ReservedConfiguration) gorums.Responses[*ReservedNode] } // enforce interface compliance @@ -35,7 +35,7 @@ var _ ReservedClient = (*ReservedConfiguration)(nil) // ReservedNodeClient is the single node client interface for the Reserved service. type ReservedNodeClient interface { - ConfTest(ctx context.Context, in *Configuration) (resp *Manager, err error) + ConfTest(ctx context.Context, in *ReservedConfiguration) (resp *ReservedNode, err error) } // enforce interface compliance @@ -134,20 +134,20 @@ type ReservedNode struct { // QuorumCall 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 *ReservedConfiguration) QuorumCall(ctx context.Context, in *Configuration) gorums.Responses[*Manager] { +func (c *ReservedConfiguration) QuorumCall(ctx context.Context, in *ReservedConfiguration) gorums.Responses[*ReservedNode] { cd := gorums.QuorumCallData{ Message: in, Method: "gorums.testprotos.failing.reservednames.Reserved.QuorumCall", ServerStream: false, } - return gorums.QuorumCall[*Manager](ctx, c.RawConfiguration, cd) + return gorums.QuorumCall[*ReservedNode](ctx, c.RawConfiguration, cd) } // ConfTest 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 *ReservedNode) ConfTest(ctx context.Context, in *Configuration) (resp *Manager, err error) { +func (n *ReservedNode) ConfTest(ctx context.Context, in *ReservedConfiguration) (resp *ReservedNode, err error) { cd := gorums.CallData{ Message: in, Method: "gorums.testprotos.failing.reservednames.Reserved.ConfTest", @@ -157,24 +157,24 @@ func (n *ReservedNode) ConfTest(ctx context.Context, in *Configuration) (resp *M if err != nil { return nil, err } - return res.(*Manager), err + return res.(*ReservedNode), err } -// Reserved is the server-side API for the Reserved Service +// ReservedServer is the server-side API for the Reserved Service type ReservedServer interface { - ConfTest(ctx gorums.ServerCtx, request *Configuration) (response *Manager, err error) - QuorumCall(ctx gorums.ServerCtx, request *Configuration) (response *Manager, err error) + ConfTest(ctx gorums.ServerCtx, request *ReservedConfiguration) (response *ReservedNode, err error) + QuorumCall(ctx gorums.ServerCtx, request *ReservedConfiguration) (response *ReservedNode, err error) } func RegisterReservedServer(srv *gorums.Server, impl ReservedServer) { srv.RegisterHandler("gorums.testprotos.failing.reservednames.Reserved.ConfTest", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Configuration) + req := in.Message.(*ReservedConfiguration) defer ctx.Release() resp, err := impl.ConfTest(ctx, req) gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) }) srv.RegisterHandler("gorums.testprotos.failing.reservednames.Reserved.QuorumCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Configuration) + req := in.Message.(*ReservedConfiguration) defer ctx.Release() resp, err := impl.QuorumCall(ctx, req) gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index 94586e58..a392bf05 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: config/config.proto @@ -143,7 +143,7 @@ func (c *ConfigTestConfiguration) Config(ctx context.Context, in *Request) gorum return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } -// ConfigTest is the server-side API for the ConfigTest Service +// ConfigTestServer is the server-side API for the ConfigTest Service type ConfigTestServer interface { Config(ctx gorums.ServerCtx, request *Request) (response *Response, err error) } diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 77b4d4ae..96de84c1 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: correctable/correctable.proto @@ -161,7 +161,7 @@ func (c *CorrectableTestConfiguration) CorrectableStream(ctx context.Context, in return gorums.QuorumCall[*CorrectableResponse](ctx, c.RawConfiguration, cd) } -// CorrectableTest is the server-side API for the CorrectableTest Service +// CorrectableTestServer is the server-side API for the CorrectableTest Service type CorrectableTestServer interface { Correctable(ctx gorums.ServerCtx, request *CorrectableRequest) (response *CorrectableResponse, err error) CorrectableStream(ctx gorums.ServerCtx, request *CorrectableRequest, send func(response *CorrectableResponse) error) error diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index f40b88b4..91d41c09 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: dummy/dummy.proto @@ -130,17 +130,3 @@ func (n *DummyNode) Test(ctx context.Context, in *Empty) (resp *Empty, err error } return res.(*Empty), err } - -// Dummy is the server-side API for the Dummy Service -type DummyServer interface { - Test(ctx gorums.ServerCtx, request *Empty) (response *Empty, err error) -} - -func RegisterDummyServer(srv *gorums.Server, impl DummyServer) { - srv.RegisterHandler("dummy.Dummy.Test", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Empty) - defer ctx.Release() - resp, err := impl.Test(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) -} diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index b3ac40bc..cb1548e8 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: metadata/metadata.proto @@ -143,24 +143,3 @@ func (n *MetadataTestNode) WhatIP(ctx context.Context, in *emptypb.Empty) (resp } return res.(*IPAddr), err } - -// MetadataTest is the server-side API for the MetadataTest Service -type MetadataTestServer interface { - IDFromMD(ctx gorums.ServerCtx, request *emptypb.Empty) (response *NodeID, err error) - WhatIP(ctx gorums.ServerCtx, request *emptypb.Empty) (response *IPAddr, err error) -} - -func RegisterMetadataTestServer(srv *gorums.Server, impl MetadataTestServer) { - srv.RegisterHandler("metadata.MetadataTest.IDFromMD", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*emptypb.Empty) - defer ctx.Release() - resp, err := impl.IDFromMD(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("metadata.MetadataTest.WhatIP", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*emptypb.Empty) - defer ctx.Release() - resp, err := impl.WhatIP(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) -} diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index eb660a32..a8caa660 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: oneway/oneway.proto @@ -167,7 +167,7 @@ type OnewayTestNode struct { *gorums.RawNode } -// OnewayTest is the server-side API for the OnewayTest Service +// OnewayTestServer is the server-side API for the OnewayTest Service type OnewayTestServer interface { Unicast(ctx gorums.ServerCtx, request *Request) Multicast(ctx gorums.ServerCtx, request *Request) diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index bdfd1877..b5a0cbb2 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: ordering/order.proto @@ -174,7 +174,7 @@ func (n *GorumsTestNode) UnaryRPC(ctx context.Context, in *Request) (resp *Respo return res.(*Response), err } -// GorumsTest is the server-side API for the GorumsTest Service +// GorumsTestServer is the server-side API for the GorumsTest Service type GorumsTestServer interface { QC(ctx gorums.ServerCtx, request *Request) (response *Response, err error) QCAsync(ctx gorums.ServerCtx, request *Request) (response *Response, err error) diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 61678a0f..1e26edd5 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: qf/qf.proto @@ -157,7 +157,7 @@ func (c *QuorumFunctionConfiguration) IgnoreReq(ctx context.Context, in *Request return gorums.QuorumCall[*Response](ctx, c.RawConfiguration, cd) } -// QuorumFunction is the server-side API for the QuorumFunction Service +// QuorumFunctionServer is the server-side API for the QuorumFunction Service type QuorumFunctionServer interface { UseReq(ctx gorums.ServerCtx, request *Request) (response *Response, err error) IgnoreReq(ctx gorums.ServerCtx, request *Request) (response *Response, err error) diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 7487eb7c..921f2e4f 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: tls/tls.proto @@ -130,17 +130,3 @@ func (n *TLSNode) TestTLS(ctx context.Context, in *Request) (resp *Response, err } return res.(*Response), err } - -// TLS is the server-side API for the TLS Service -type TLSServer interface { - TestTLS(ctx gorums.ServerCtx, request *Request) (response *Response, err error) -} - -func RegisterTLSServer(srv *gorums.Server, impl TLSServer) { - srv.RegisterHandler("tls.TLS.TestTLS", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Request) - defer ctx.Release() - resp, err := impl.TestTLS(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) -} diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index 19e28376..65f33292 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+87979cf3 // protoc v6.30.2 // source: unresponsive/unresponsive.proto @@ -130,17 +130,3 @@ func (n *UnresponsiveNode) TestUnresponsive(ctx context.Context, in *Empty) (res } return res.(*Empty), err } - -// Unresponsive is the server-side API for the Unresponsive Service -type UnresponsiveServer interface { - TestUnresponsive(ctx gorums.ServerCtx, request *Empty) (response *Empty, err error) -} - -func RegisterUnresponsiveServer(srv *gorums.Server, impl UnresponsiveServer) { - srv.RegisterHandler("unresponsive.Unresponsive.TestUnresponsive", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*Empty) - defer ctx.Release() - resp, err := impl.TestUnresponsive(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) -} From a35cbf26926008c634daf806897858944e43e532 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Tue, 13 May 2025 14:43:59 +0200 Subject: [PATCH 10/11] detect name collisions --- benchmark/benchmark_gorums.pb.go | 2 +- .../dev/zorums_client_gorums.pb.go | 2 +- .../dev/zorums_configuration_gorums.pb.go | 2 +- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_node_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_unicast_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/gengorums/gorums.go | 26 +++ cmd/protoc-gen-gorums/gengorums/gorums_dev.go | 5 + .../gengorums/gorums_func_map.go | 5 +- .../gengorums/template_server.go | 2 +- examples/storage/proto/storage_gorums.pb.go | 4 +- .../failing/reservednames/reserved.pb.go | 194 ------------------ .../failing/reservednames/reserved.proto | 19 +- .../reservednames/reserved_gorums.pb.go | 182 ---------------- tests/config/config_gorums.pb.go | 2 +- tests/correctable/correctable_gorums.pb.go | 2 +- tests/dummy/dummy_gorums.pb.go | 16 +- tests/metadata/metadata_gorums.pb.go | 23 ++- tests/mock/mock.pb.go | 178 +++++++--------- 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 | 16 +- tests/unresponsive/unresponsive_gorums.pb.go | 16 +- 27 files changed, 212 insertions(+), 502 deletions(-) delete mode 100644 internal/testprotos/failing/reservednames/reserved.pb.go delete mode 100644 internal/testprotos/failing/reservednames/reserved_gorums.pb.go diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 655e75db..3bb1774b 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // protoc v6.30.2 // source: benchmark/benchmark.proto 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 dc988dbe..c999b7cf 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go index 63850d75..d5821f12 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 d70fd614..332ddc6d 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go index dcbab81e..c6796b68 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 f2e36635..f6b07f14 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 a8f1177d..1b82e332 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 a663e3cf..dcb50982 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 4ff07c93..95efd270 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 3cc4ee54..834ab2b0 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -89,6 +89,27 @@ func gorumsGuard(file *protogen.File) bool { return true } +var reservedNames map[string]struct{} + +func initReservedNames() { + reservedNames = make(map[string]struct{}) +} + +func checkNameCollision(file *protogen.File) { + for _, msg := range file.Messages { + msgName := fmt.Sprintf("%v", msg.Desc.Name()) + for reserved := range reservedNames { + if msgName == reserved { + log.Fatalf("%v.proto: contains message %s, which is a reserved Gorums service type.\n", file.GeneratedFilenamePrefix, msgName) + } + } + } +} + +func reserveName(name string) { + reservedNames[name] = struct{}{} +} + // GenerateFileContent generates the Gorums service definitions, excluding the package statement. func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile) { // sort the gorums types so that output remains stable across rebuilds @@ -97,9 +118,14 @@ func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen. sortedTypes = append(sortedTypes, gorumsType) } sort.Strings(sortedTypes) + + initReservedNames() + for _, gorumsType := range sortedTypes { genGorumsType(g, file.Services, gorumsType) } + + checkNameCollision(file) } // servicesData hold the services to generate and a reference to the file in which diff --git a/cmd/protoc-gen-gorums/gengorums/gorums_dev.go b/cmd/protoc-gen-gorums/gengorums/gorums_dev.go index d6e10f61..8951885b 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums_dev.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums_dev.go @@ -10,9 +10,14 @@ func GenerateDevFiles(gen *protogen.Plugin, file *protogen.File) { if !gorumsGuard(file) { return } + + initReservedNames() + for gorumsType := range gorumsCallTypesInfo { generateDevFile(gen, file, gorumsType) } + + checkNameCollision(file) } func generateDevFile(gen *protogen.Plugin, file *protogen.File, gorumsType string) { diff --git a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go index 60358daa..b6aedbf8 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go @@ -59,8 +59,9 @@ var funcMap = template.FuncMap{ return g.QualifiedGoIdent(pkg.Ident(ident)) }, "serviceTypeName": func(serviceName, typeName string) string { - // TODO(Asbjørn): set the type name as reserved - return serviceName + typeName + name := serviceName + typeName + reserveName(name) + return name }, "hasPerNodeArg": func(method *protogen.Method) bool { return hasMethodOption(method, gorums.E_PerNodeArg) diff --git a/cmd/protoc-gen-gorums/gengorums/template_server.go b/cmd/protoc-gen-gorums/gengorums/template_server.go index 1c18a47f..40a21ff7 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_server.go +++ b/cmd/protoc-gen-gorums/gengorums/template_server.go @@ -9,7 +9,7 @@ var serverVariables = ` var serverServicesBegin = ` {{- $genFile := .GenFile}} -{{- range configurationsServices .Services}} +{{- range .Services}} {{- $service := .GoName}} {{- $serverName := serviceTypeName $service "Server"}} ` diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index 0a0d8eb1..f5a42736 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+d97bfa83 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // protoc v6.30.2 // source: storage/proto/storage.proto @@ -203,7 +203,7 @@ func (n *StorageNode) WriteRPC(ctx context.Context, in *WriteRequest) (resp *Wri return res.(*WriteResponse), err } -// Storage is the server-side API for the Storage Service +// StorageServer is the server-side API for the Storage Service type StorageServer interface { ReadRPC(ctx gorums.ServerCtx, request *ReadRequest) (response *ReadResponse, err error) WriteRPC(ctx gorums.ServerCtx, request *WriteRequest) (response *WriteResponse, err error) diff --git a/internal/testprotos/failing/reservednames/reserved.pb.go b/internal/testprotos/failing/reservednames/reserved.pb.go deleted file mode 100644 index 879ebfef..00000000 --- a/internal/testprotos/failing/reservednames/reserved.pb.go +++ /dev/null @@ -1,194 +0,0 @@ -// Test that Gorums will stop code generation if one of the -// reserved Gorums types are used as a message type. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc v6.30.2 -// source: failing/reservednames/reserved.proto - -package reservednames - -import ( - _ "github.com/relab/gorums" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ReservedConfiguration struct { - state protoimpl.MessageState `protogen:"opaque.v1"` - xxx_hidden_Conf string `protobuf:"bytes,1,opt,name=Conf"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ReservedConfiguration) Reset() { - *x = ReservedConfiguration{} - mi := &file_failing_reservednames_reserved_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ReservedConfiguration) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReservedConfiguration) ProtoMessage() {} - -func (x *ReservedConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_failing_reservednames_reserved_proto_msgTypes[0] - 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 *ReservedConfiguration) GetConf() string { - if x != nil { - return x.xxx_hidden_Conf - } - return "" -} - -func (x *ReservedConfiguration) SetConf(v string) { - x.xxx_hidden_Conf = v -} - -type ReservedConfiguration_builder struct { - _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. - - Conf string -} - -func (b0 ReservedConfiguration_builder) Build() *ReservedConfiguration { - m0 := &ReservedConfiguration{} - b, x := &b0, m0 - _, _ = b, x - x.xxx_hidden_Conf = b.Conf - return m0 -} - -type ReservedNode struct { - state protoimpl.MessageState `protogen:"opaque.v1"` - xxx_hidden_Node string `protobuf:"bytes,1,opt,name=Node"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ReservedNode) Reset() { - *x = ReservedNode{} - mi := &file_failing_reservednames_reserved_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ReservedNode) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReservedNode) ProtoMessage() {} - -func (x *ReservedNode) ProtoReflect() protoreflect.Message { - mi := &file_failing_reservednames_reserved_proto_msgTypes[1] - 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 *ReservedNode) GetNode() string { - if x != nil { - return x.xxx_hidden_Node - } - return "" -} - -func (x *ReservedNode) SetNode(v string) { - x.xxx_hidden_Node = v -} - -type ReservedNode_builder struct { - _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. - - Node string -} - -func (b0 ReservedNode_builder) Build() *ReservedNode { - m0 := &ReservedNode{} - b, x := &b0, m0 - _, _ = b, x - x.xxx_hidden_Node = b.Node - return m0 -} - -var File_failing_reservednames_reserved_proto protoreflect.FileDescriptor - -const file_failing_reservednames_reserved_proto_rawDesc = "" + - "\n" + - "$failing/reservednames/reserved.proto\x12'gorums.testprotos.failing.reservednames\x1a\fgorums.proto\"+\n" + - "\x15ReservedConfiguration\x12\x12\n" + - "\x04Conf\x18\x01 \x01(\tR\x04Conf\"\"\n" + - "\fReservedNode\x12\x12\n" + - "\x04Node\x18\x01 \x01(\tR\x04Node2\x9c\x02\n" + - "\bReserved\x12\x83\x01\n" + - "\bConfTest\x12>.gorums.testprotos.failing.reservednames.ReservedConfiguration\x1a5.gorums.testprotos.failing.reservednames.ReservedNode\"\x00\x12\x89\x01\n" + - "\n" + - "QuorumCall\x12>.gorums.testprotos.failing.reservednames.ReservedConfiguration\x1a5.gorums.testprotos.failing.reservednames.ReservedNode\"\x04\xa0\xb5\x18\x01BHZAgithub.com/relab/gorums/internal/testprotos/failing/reservednames\x92\x03\x02\b\x02b\beditionsp\xe8\a" - -var file_failing_reservednames_reserved_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_failing_reservednames_reserved_proto_goTypes = []any{ - (*ReservedConfiguration)(nil), // 0: gorums.testprotos.failing.reservednames.ReservedConfiguration - (*ReservedNode)(nil), // 1: gorums.testprotos.failing.reservednames.ReservedNode -} -var file_failing_reservednames_reserved_proto_depIdxs = []int32{ - 0, // 0: gorums.testprotos.failing.reservednames.Reserved.ConfTest:input_type -> gorums.testprotos.failing.reservednames.ReservedConfiguration - 0, // 1: gorums.testprotos.failing.reservednames.Reserved.QuorumCall:input_type -> gorums.testprotos.failing.reservednames.ReservedConfiguration - 1, // 2: gorums.testprotos.failing.reservednames.Reserved.ConfTest:output_type -> gorums.testprotos.failing.reservednames.ReservedNode - 1, // 3: gorums.testprotos.failing.reservednames.Reserved.QuorumCall:output_type -> gorums.testprotos.failing.reservednames.ReservedNode - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] 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 -} - -func init() { file_failing_reservednames_reserved_proto_init() } -func file_failing_reservednames_reserved_proto_init() { - if File_failing_reservednames_reserved_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_failing_reservednames_reserved_proto_rawDesc), len(file_failing_reservednames_reserved_proto_rawDesc)), - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_failing_reservednames_reserved_proto_goTypes, - DependencyIndexes: file_failing_reservednames_reserved_proto_depIdxs, - MessageInfos: file_failing_reservednames_reserved_proto_msgTypes, - }.Build() - File_failing_reservednames_reserved_proto = out.File - file_failing_reservednames_reserved_proto_goTypes = nil - file_failing_reservednames_reserved_proto_depIdxs = nil -} diff --git a/internal/testprotos/failing/reservednames/reserved.proto b/internal/testprotos/failing/reservednames/reserved.proto index 8782fc64..78ffb41d 100644 --- a/internal/testprotos/failing/reservednames/reserved.proto +++ b/internal/testprotos/failing/reservednames/reserved.proto @@ -12,14 +12,27 @@ import "gorums.proto"; service Reserved { rpc ConfTest(ReservedConfiguration) returns (ReservedNode) {} - rpc QuorumCall(ReservedConfiguration) returns (ReservedNode) { + rpc QuorumCall(ReservedServer) returns (ReservedClient) { option (gorums.quorumcall) = true; } } +message ReservedNode { + string Node = 1; +} + +message ReservedServer { + string Srv = 1; +} + message ReservedConfiguration { string Conf = 1; } -message ReservedNode { - string Node = 1; + +message ReservedClient { + string Client = 1; +} + +message ReservedNodeClient { + string NClient = 1; } diff --git a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go b/internal/testprotos/failing/reservednames/reserved_gorums.pb.go deleted file mode 100644 index db953ead..00000000 --- a/internal/testprotos/failing/reservednames/reserved_gorums.pb.go +++ /dev/null @@ -1,182 +0,0 @@ -// Code generated by protoc-gen-gorums. DO NOT EDIT. -// versions: -// protoc-gen-gorums v0.9.0-devel+87979cf3 -// protoc v6.30.2 -// source: failing/reservednames/reserved.proto - -package reservednames - -import ( - context "context" - gorums "github.com/relab/gorums" - encoding "google.golang.org/grpc/encoding" -) - -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) -) - -func init() { - if encoding.GetCodec(gorums.ContentSubtype) == nil { - encoding.RegisterCodec(gorums.NewCodec()) - } -} - -// ReservedClient is the client interface for the Reserved service. -type ReservedClient interface { - QuorumCall(ctx context.Context, in *ReservedConfiguration) gorums.Responses[*ReservedNode] -} - -// enforce interface compliance -var _ ReservedClient = (*ReservedConfiguration)(nil) - -// ReservedNodeClient is the single node client interface for the Reserved service. -type ReservedNodeClient interface { - ConfTest(ctx context.Context, in *ReservedConfiguration) (resp *ReservedNode, err error) -} - -// enforce interface compliance -var _ ReservedNodeClient = (*ReservedNode)(nil) - -// A ReservedConfiguration represents a static set of nodes on which quorum remote -// procedure calls may be invoked. -type ReservedConfiguration struct { - gorums.RawConfiguration -} - -// NewReservedConfiguration returns a configuration based on the provided list of nodes (required) -// and an optional quorum specification. The QuorumSpec is necessary for call types that -// must process replies. For configurations only used for unicast or multicast call types, -// a QuorumSpec is not needed. -// Nodes can be supplied using WithNodeMap or WithNodeList. -// Using any other type of NodeListOption will not work. -// The ManagerOption list controls how the nodes in the configuration are created. -func NewReservedConfiguration(cfg gorums.NodeListOption, opts ...gorums.ManagerOption) (c *ReservedConfiguration, err error) { - c = &ReservedConfiguration{} - c.RawConfiguration, err = gorums.NewRawConfiguration(cfg, opts...) - if err != nil { - return nil, err - } - return c, nil -} - -// SubReservedConfiguration allows for making a new Configuration from the -// ManagerOption list and node list of another set of configurations, -// 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 (c *ReservedConfiguration) SubReservedConfiguration(cfg gorums.NodeListOption) (subCfg *ReservedConfiguration, err error) { - subCfg = &ReservedConfiguration{} - subCfg.RawConfiguration, err = c.SubRawConfiguration(cfg) - if err != nil { - return nil, err - } - return subCfg, nil -} - -// ReservedConfigurationFromRaw returns a new ReservedConfiguration from the given raw configuration. -// -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: -// -// cfg1, err := mgr.NewConfiguration(qspec1, opts...) -// cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func ReservedConfigurationFromRaw(rawCfg gorums.RawConfiguration) (*ReservedConfiguration, error) { - newCfg := &ReservedConfiguration{ - RawConfiguration: rawCfg, - } - return newCfg, nil -} - -// Nodes returns a slice of each available node. IDs are returned in the same -// order as they were provided in the creation of the Manager. -// -// NOTE: mutating the returned slice is not supported. -func (c *ReservedConfiguration) Nodes() []*ReservedNode { - rawNodes := c.RawConfiguration.Nodes() - nodes := make([]*ReservedNode, len(rawNodes)) - for i, n := range rawNodes { - nodes[i] = &ReservedNode{n} - } - return nodes -} - -// AllNodes returns a slice of each available node of all subconfigurations. Sorted by node id. -// -// NOTE: mutating the returned slice is not supported. -func (c *ReservedConfiguration) AllNodes() []*ReservedNode { - rawNodes := c.RawConfiguration.AllNodes() - nodes := make([]*ReservedNode, len(rawNodes)) - for i, n := range rawNodes { - nodes[i] = &ReservedNode{n} - } - return nodes -} - -// And returns a NodeListOption that can be used to create a new configuration combining c and d. -func (c ReservedConfiguration) And(d *ReservedConfiguration) 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 ReservedConfiguration) Except(rm *ReservedConfiguration) gorums.NodeListOption { - return c.RawConfiguration.Except(rm.RawConfiguration) -} - -// ReservedNode holds the node specific methods for the Reserved service. -type ReservedNode struct { - *gorums.RawNode -} - -// QuorumCall 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 *ReservedConfiguration) QuorumCall(ctx context.Context, in *ReservedConfiguration) gorums.Responses[*ReservedNode] { - cd := gorums.QuorumCallData{ - Message: in, - Method: "gorums.testprotos.failing.reservednames.Reserved.QuorumCall", - ServerStream: false, - } - - return gorums.QuorumCall[*ReservedNode](ctx, c.RawConfiguration, cd) -} - -// ConfTest 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 *ReservedNode) ConfTest(ctx context.Context, in *ReservedConfiguration) (resp *ReservedNode, err error) { - cd := gorums.CallData{ - Message: in, - Method: "gorums.testprotos.failing.reservednames.Reserved.ConfTest", - } - - res, err := n.RawNode.RPCCall(ctx, cd) - if err != nil { - return nil, err - } - return res.(*ReservedNode), err -} - -// ReservedServer is the server-side API for the Reserved Service -type ReservedServer interface { - ConfTest(ctx gorums.ServerCtx, request *ReservedConfiguration) (response *ReservedNode, err error) - QuorumCall(ctx gorums.ServerCtx, request *ReservedConfiguration) (response *ReservedNode, err error) -} - -func RegisterReservedServer(srv *gorums.Server, impl ReservedServer) { - srv.RegisterHandler("gorums.testprotos.failing.reservednames.Reserved.ConfTest", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*ReservedConfiguration) - defer ctx.Release() - resp, err := impl.ConfTest(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) - srv.RegisterHandler("gorums.testprotos.failing.reservednames.Reserved.QuorumCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { - req := in.Message.(*ReservedConfiguration) - defer ctx.Release() - resp, err := impl.QuorumCall(ctx, req) - gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) - }) -} diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index a392bf05..d4648686 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 96de84c1..7d7aa9a0 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 91d41c09..82190eb6 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // protoc v6.30.2 // source: dummy/dummy.proto @@ -130,3 +130,17 @@ func (n *DummyNode) Test(ctx context.Context, in *Empty) (resp *Empty, err error } return res.(*Empty), err } + +// DummyServer is the server-side API for the Dummy Service +type DummyServer interface { + Test(ctx gorums.ServerCtx, request *Empty) (response *Empty, err error) +} + +func RegisterDummyServer(srv *gorums.Server, impl DummyServer) { + srv.RegisterHandler("dummy.Dummy.Test", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*Empty) + defer ctx.Release() + resp, err := impl.Test(ctx, req) + gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) + }) +} diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index cb1548e8..d03e81fb 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // protoc v6.30.2 // source: metadata/metadata.proto @@ -143,3 +143,24 @@ func (n *MetadataTestNode) WhatIP(ctx context.Context, in *emptypb.Empty) (resp } return res.(*IPAddr), err } + +// MetadataTestServer is the server-side API for the MetadataTest Service +type MetadataTestServer interface { + IDFromMD(ctx gorums.ServerCtx, request *emptypb.Empty) (response *NodeID, err error) + WhatIP(ctx gorums.ServerCtx, request *emptypb.Empty) (response *IPAddr, err error) +} + +func RegisterMetadataTestServer(srv *gorums.Server, impl MetadataTestServer) { + srv.RegisterHandler("metadata.MetadataTest.IDFromMD", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*emptypb.Empty) + defer ctx.Release() + resp, err := impl.IDFromMD(ctx, req) + gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) + }) + srv.RegisterHandler("metadata.MetadataTest.WhatIP", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*emptypb.Empty) + defer ctx.Release() + resp, err := impl.WhatIP(ctx, req) + gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) + }) +} diff --git a/tests/mock/mock.pb.go b/tests/mock/mock.pb.go index 5808077e..e81e4119 100644 --- a/tests/mock/mock.pb.go +++ b/tests/mock/mock.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v3.12.4 -// source: mock.proto +// protoc-gen-go v1.36.6 +// protoc v6.30.2 +// source: tests/mock/mock.proto package mock @@ -10,7 +10,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" - sync "sync" + unsafe "unsafe" ) const ( @@ -21,20 +21,17 @@ const ( ) type Request struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Val string `protobuf:"bytes,1,opt,name=val,proto3" json:"val,omitempty"` + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Val string `protobuf:"bytes,1,opt,name=val"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Request) Reset() { *x = Request{} - if protoimpl.UnsafeEnabled { - mi := &file_mock_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_tests_mock_mock_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Request) String() string { @@ -44,8 +41,8 @@ func (x *Request) String() string { func (*Request) ProtoMessage() {} func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_mock_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_tests_mock_mock_proto_msgTypes[0] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -55,33 +52,43 @@ func (x *Request) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_mock_proto_rawDescGZIP(), []int{0} -} - func (x *Request) GetVal() string { if x != nil { - return x.Val + return x.xxx_hidden_Val } return "" } -type Response struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields +func (x *Request) SetVal(v string) { + x.xxx_hidden_Val = v +} + +type Request_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. + + Val string +} - Val string `protobuf:"bytes,1,opt,name=val,proto3" json:"val,omitempty"` +func (b0 Request_builder) Build() *Request { + m0 := &Request{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Val = b.Val + return m0 +} + +type Response struct { + state protoimpl.MessageState `protogen:"opaque.v1"` + xxx_hidden_Val string `protobuf:"bytes,1,opt,name=val"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Response) Reset() { *x = Response{} - if protoimpl.UnsafeEnabled { - mi := &file_mock_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_tests_mock_mock_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Response) String() string { @@ -91,8 +98,8 @@ func (x *Response) String() string { func (*Response) ProtoMessage() {} func (x *Response) ProtoReflect() protoreflect.Message { - mi := &file_mock_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_tests_mock_mock_proto_msgTypes[1] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -102,49 +109,47 @@ func (x *Response) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_mock_proto_rawDescGZIP(), []int{1} -} - func (x *Response) GetVal() string { if x != nil { - return x.Val + return x.xxx_hidden_Val } return "" } -var File_mock_proto protoreflect.FileDescriptor - -var file_mock_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x6d, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6d, 0x6f, - 0x63, 0x6b, 0x22, 0x1b, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, - 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, - 0x1c, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x76, - 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x42, 0x24, 0x5a, - 0x22, 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, - 0x6f, 0x63, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +func (x *Response) SetVal(v string) { + x.xxx_hidden_Val = v } -var ( - file_mock_proto_rawDescOnce sync.Once - file_mock_proto_rawDescData = file_mock_proto_rawDesc -) +type Response_builder struct { + _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. -func file_mock_proto_rawDescGZIP() []byte { - file_mock_proto_rawDescOnce.Do(func() { - file_mock_proto_rawDescData = protoimpl.X.CompressGZIP(file_mock_proto_rawDescData) - }) - return file_mock_proto_rawDescData + Val string } -var file_mock_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_mock_proto_goTypes = []interface{}{ +func (b0 Response_builder) Build() *Response { + m0 := &Response{} + b, x := &b0, m0 + _, _ = b, x + x.xxx_hidden_Val = b.Val + return m0 +} + +var File_tests_mock_mock_proto protoreflect.FileDescriptor + +const file_tests_mock_mock_proto_rawDesc = "" + + "\n" + + "\x15tests/mock/mock.proto\x12\x04mock\"\x1b\n" + + "\aRequest\x12\x10\n" + + "\x03val\x18\x01 \x01(\tR\x03val\"\x1c\n" + + "\bResponse\x12\x10\n" + + "\x03val\x18\x01 \x01(\tR\x03valB)Z\"github.com/relab/gorums/tests/mock\x92\x03\x02\b\x02b\beditionsp\xe8\a" + +var file_tests_mock_mock_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_tests_mock_mock_proto_goTypes = []any{ (*Request)(nil), // 0: mock.Request (*Response)(nil), // 1: mock.Response } -var file_mock_proto_depIdxs = []int32{ +var file_tests_mock_mock_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -152,53 +157,26 @@ var file_mock_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_mock_proto_init() } -func file_mock_proto_init() { - if File_mock_proto != nil { +func init() { file_tests_mock_mock_proto_init() } +func file_tests_mock_mock_proto_init() { + if File_tests_mock_mock_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_mock_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Request); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_mock_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Response); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_mock_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_tests_mock_mock_proto_rawDesc), len(file_tests_mock_mock_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_mock_proto_goTypes, - DependencyIndexes: file_mock_proto_depIdxs, - MessageInfos: file_mock_proto_msgTypes, + GoTypes: file_tests_mock_mock_proto_goTypes, + DependencyIndexes: file_tests_mock_mock_proto_depIdxs, + MessageInfos: file_tests_mock_mock_proto_msgTypes, }.Build() - File_mock_proto = out.File - file_mock_proto_rawDesc = nil - file_mock_proto_goTypes = nil - file_mock_proto_depIdxs = nil + File_tests_mock_mock_proto = out.File + file_tests_mock_mock_proto_goTypes = nil + file_tests_mock_mock_proto_depIdxs = nil } diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index a8caa660..4b023538 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 b5a0cbb2..19a0c271 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 1e26edd5..05336149 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // 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 921f2e4f..1fe463b1 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // protoc v6.30.2 // source: tls/tls.proto @@ -130,3 +130,17 @@ func (n *TLSNode) TestTLS(ctx context.Context, in *Request) (resp *Response, err } return res.(*Response), err } + +// TLSServer is the server-side API for the TLS Service +type TLSServer interface { + TestTLS(ctx gorums.ServerCtx, request *Request) (response *Response, err error) +} + +func RegisterTLSServer(srv *gorums.Server, impl TLSServer) { + srv.RegisterHandler("tls.TLS.TestTLS", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*Request) + defer ctx.Release() + resp, err := impl.TestTLS(ctx, req) + gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) + }) +} diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index 65f33292..eed67e06 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+87979cf3 +// protoc-gen-gorums v0.9.0-devel+daaa6535 // protoc v6.30.2 // source: unresponsive/unresponsive.proto @@ -130,3 +130,17 @@ func (n *UnresponsiveNode) TestUnresponsive(ctx context.Context, in *Empty) (res } return res.(*Empty), err } + +// UnresponsiveServer is the server-side API for the Unresponsive Service +type UnresponsiveServer interface { + TestUnresponsive(ctx gorums.ServerCtx, request *Empty) (response *Empty, err error) +} + +func RegisterUnresponsiveServer(srv *gorums.Server, impl UnresponsiveServer) { + srv.RegisterHandler("unresponsive.Unresponsive.TestUnresponsive", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { + req := in.Message.(*Empty) + defer ctx.Release() + resp, err := impl.TestUnresponsive(ctx, req) + gorums.SendMessage(ctx, finished, gorums.WrapMessage(in.Metadata, resp, err)) + }) +} From 8b9e95f34c4c6903fb437213b80d8802a0dfc9b3 Mon Sep 17 00:00:00 2001 From: asbjorn Date: Wed, 14 May 2025 01:17:26 +0200 Subject: [PATCH 11/11] avoid collision on methods aswell --- benchmark/benchmark_gorums.pb.go | 7 +- .../dev/zorums_client_gorums.pb.go | 2 +- .../dev/zorums_configuration_gorums.pb.go | 6 +- .../dev/zorums_multicast_gorums.pb.go | 2 +- .../dev/zorums_node_gorums.pb.go | 2 +- .../dev/zorums_quorumcall_gorums.pb.go | 2 +- .../dev/zorums_rpc_gorums.pb.go | 2 +- .../dev/zorums_server_gorums.pb.go | 8 ++- .../dev/zorums_unicast_gorums.pb.go | 2 +- cmd/protoc-gen-gorums/gengorums/gorums.go | 12 ++-- .../gengorums/gorums_func_map.go | 9 ++- .../gengorums/template_async.go | 59 ---------------- .../gengorums/template_client.go | 8 ++- .../gengorums/template_configuration.go | 29 +++++--- .../gengorums/template_correctable.go | 68 ------------------- .../gengorums/template_multicast.go | 3 + .../gengorums/template_node.go | 3 +- .../gengorums/template_quorumcall.go | 9 ++- .../gengorums/template_rpc.go | 3 + .../gengorums/template_server.go | 10 ++- examples/storage/proto/storage_gorums.pb.go | 7 +- tests/config/config_gorums.pb.go | 7 +- tests/correctable/correctable_gorums.pb.go | 7 +- tests/dummy/dummy_gorums.pb.go | 7 +- tests/metadata/metadata_gorums.pb.go | 7 +- tests/oneway/oneway_gorums.pb.go | 7 +- tests/ordering/order_gorums.pb.go | 7 +- tests/qf/qf_gorums.pb.go | 7 +- tests/tls/tls_gorums.pb.go | 7 +- tests/unresponsive/unresponsive_gorums.pb.go | 7 +- 30 files changed, 132 insertions(+), 184 deletions(-) delete mode 100644 cmd/protoc-gen-gorums/gengorums/template_async.go delete mode 100644 cmd/protoc-gen-gorums/gengorums/template_correctable.go diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 3bb1774b..990e552d 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: benchmark/benchmark.proto @@ -86,7 +86,7 @@ func (c *BenchmarkConfiguration) SubBenchmarkConfiguration(cfg gorums.NodeListOp // BenchmarkConfigurationFromRaw returns a new BenchmarkConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -255,6 +255,9 @@ type BenchmarkServer interface { Multicast(ctx gorums.ServerCtx, request *TimedMsg) } +// RegisterBenchmarkServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterBenchmarkServer(srv *gorums.Server, impl BenchmarkServer) { srv.RegisterHandler("benchmark.Benchmark.StartServerBenchmark", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*StartRequest) 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 c999b7cf..efad15ff 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go index d5821f12..55724e0d 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_configuration_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: zorums.proto @@ -55,7 +55,7 @@ func (c *ZorumsServiceConfiguration) SubZorumsServiceConfiguration(cfg gorums.No // ZorumsServiceConfigurationFromRaw returns a new ZorumsServiceConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -140,7 +140,7 @@ func (c *ZorumsNoQCServiceConfiguration) SubZorumsNoQCServiceConfiguration(cfg g // ZorumsNoQCServiceConfigurationFromRaw returns a new ZorumsNoQCServiceConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) 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 332ddc6d..26993040 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: zorums.proto diff --git a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go index c6796b68..3e8fc74c 100644 --- a/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go +++ b/cmd/protoc-gen-gorums/dev/zorums_node_gorums.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-gorums. DO NOT EDIT. // versions: -// protoc-gen-gorums v0.9.0-devel+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // 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 f6b07f14..984ec5d5 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // 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 1b82e332..e0b7de93 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // 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 dcb50982..234d3e6f 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: zorums.proto @@ -40,6 +40,9 @@ type ZorumsServiceServer interface { Unicast2(ctx gorums.ServerCtx, request *Request) } +// RegisterZorumsServiceServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterZorumsServiceServer(srv *gorums.Server, impl ZorumsServiceServer) { srv.RegisterHandler("dev.ZorumsService.GRPCCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) @@ -168,6 +171,9 @@ type ZorumsNoQCServiceServer interface { Unicast2(ctx gorums.ServerCtx, request *Request) } +// RegisterZorumsNoQCServiceServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterZorumsNoQCServiceServer(srv *gorums.Server, impl ZorumsNoQCServiceServer) { srv.RegisterHandler("dev.ZorumsNoQCService.GRPCCall", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) 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 95efd270..e88ad623 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // 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 834ab2b0..33e89780 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums.go @@ -98,15 +98,19 @@ func initReservedNames() { func checkNameCollision(file *protogen.File) { for _, msg := range file.Messages { msgName := fmt.Sprintf("%v", msg.Desc.Name()) - for reserved := range reservedNames { - if msgName == reserved { - log.Fatalf("%v.proto: contains message %s, which is a reserved Gorums service type.\n", file.GeneratedFilenamePrefix, msgName) - } + + _, ok := reservedNames[msgName] + if ok { + log.Fatalf("%v.proto: contains message %s, which is a reserved Gorums service type.\n", file.GeneratedFilenamePrefix, msgName) } } } func reserveName(name string) { + _, ok := reservedNames[name] + if ok { + log.Fatalf("reserveName: Redefinition of method %s.\n", name) + } reservedNames[name] = struct{}{} } diff --git a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go index b6aedbf8..49e878a7 100644 --- a/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go +++ b/cmd/protoc-gen-gorums/gengorums/gorums_func_map.go @@ -58,10 +58,13 @@ var funcMap = template.FuncMap{ } return g.QualifiedGoIdent(pkg.Ident(ident)) }, - "serviceTypeName": func(serviceName, typeName string) string { - name := serviceName + typeName + "reserveName": func(name string) string { reserveName(name) - return name + return "" + }, + "reserveMethod": func(structName, methodName string) string { + reserveName(structName + "." + methodName) + return "" }, "hasPerNodeArg": func(method *protogen.Method) bool { return hasMethodOption(method, gorums.E_PerNodeArg) 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 7f7cd886..00000000 --- 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 *{{$configurationName}}) {{$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 ba7ed24d..666befbf 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_client.go +++ b/cmd/protoc-gen-gorums/gengorums/template_client.go @@ -22,9 +22,10 @@ var clientServicesEnd = ` ` var clientConfigurationInterface = ` - {{- $interfaceName := serviceTypeName $service "Client"}} + {{- $interfaceName := printf "%sClient" $service}} {{- $configurationName := printf "%sConfiguration" $service}} // {{$interfaceName}} is the client interface for the {{$service}} service. + {{- reserveName $interfaceName}} type {{$interfaceName}} interface { {{- range configurationMethods .Methods}} {{- $method := .GoName}} @@ -42,9 +43,10 @@ var clientConfigurationInterface = ` ` var clientNodeInterface = ` - {{- $interfaceName := serviceTypeName $service "NodeClient"}} - {{- $nodeName := serviceTypeName $service "Node"}} + {{- $interfaceName := printf "%sNodeClient" $service}} + {{- $nodeName := printf "%sNode" $service}} // {{$interfaceName}} is the single node client interface for the {{$service}} service. + {{- reserveName $interfaceName}} type {{$interfaceName}} interface { {{- range nodeMethods .Methods}} {{- $method := .GoName}} diff --git a/cmd/protoc-gen-gorums/gengorums/template_configuration.go b/cmd/protoc-gen-gorums/gengorums/template_configuration.go index 96212889..c0f7b062 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_configuration.go +++ b/cmd/protoc-gen-gorums/gengorums/template_configuration.go @@ -9,8 +9,8 @@ var configurationServicesBegin = ` {{- $genFile := .GenFile}} {{- range .Services}} {{- $service := .GoName}} - {{- $configurationName := serviceTypeName $service "Configuration"}} - {{- $nodeName := serviceTypeName $service "Node"}} + {{- $configurationName := printf "%sConfiguration" $service}} + {{- $nodeName := printf "%sNode" $service}} ` var configurationServicesEnd = ` @@ -20,20 +20,23 @@ var configurationServicesEnd = ` var configurationStruct = ` // A {{$configurationName}} represents a static set of nodes on which quorum remote // procedure calls may be invoked. +{{- reserveName $configurationName}} type {{$configurationName}} struct { {{$rawConfiguration}} } ` var newConfiguration = ` -// New{{$configurationName}} returns a configuration based on the provided list of nodes (required) +{{- $funcName := printf "New%s" $configurationName}} +// {{$funcName}} returns a configuration based on the provided list of nodes (required) // and an optional quorum specification. The QuorumSpec is necessary for call types that // must process replies. For configurations only used for unicast or multicast call types, // a QuorumSpec is not needed. // Nodes can be supplied using WithNodeMap or WithNodeList. // Using any other type of NodeListOption will not work. // The ManagerOption list controls how the nodes in the configuration are created. -func New{{$configurationName}}(cfg gorums.NodeListOption, opts ...gorums.ManagerOption) (c *{{$configurationName}}, err error) { +{{- reserveName $funcName}} +func {{$funcName}}(cfg gorums.NodeListOption, opts ...gorums.ManagerOption) (c *{{$configurationName}}, err error) { c = &{{$configurationName}}{} c.RawConfiguration, err = gorums.NewRawConfiguration(cfg, opts...) if err != nil { @@ -44,12 +47,14 @@ func New{{$configurationName}}(cfg gorums.NodeListOption, opts ...gorums.Manager ` var subConfiguration = ` -// Sub{{$configurationName}} allows for making a new Configuration from the +{{- $methodName := printf "Sub%s" $configurationName}} +// {{$methodName}} allows for making a new Configuration from the // ManagerOption list and node list of another set of configurations, // 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 (c *{{$configurationName}}) Sub{{$configurationName}}(cfg gorums.NodeListOption) (subCfg *{{$configurationName}}, err error) { +{{- reserveMethod $configurationName $methodName}} +func (c *{{$configurationName}}) {{$methodName}}(cfg gorums.NodeListOption) (subCfg *{{$configurationName}}, err error) { subCfg = &{{$configurationName}}{} subCfg.RawConfiguration, err = c.SubRawConfiguration(cfg) if err != nil { @@ -60,13 +65,15 @@ func (c *{{$configurationName}}) Sub{{$configurationName}}(cfg gorums.NodeListOp ` var configurationFromRaw = ` -// {{$configurationName}}FromRaw returns a new {{$configurationName}} from the given raw configuration. +{{- $funcName := printf "%sFromRaw" $configurationName}} +// {{$funcName}} returns a new {{$configurationName}} from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) -func {{$configurationName}}FromRaw(rawCfg {{$rawConfiguration}}) (*{{$configurationName}}, error) { +{{- reserveName $funcName}} +func {{$funcName}}(rawCfg {{$rawConfiguration}}) (*{{$configurationName}}, error) { newCfg := &{{$configurationName}}{ RawConfiguration: rawCfg, } @@ -79,6 +86,7 @@ var configurationMethodsTemplate = ` // order as they were provided in the creation of the Manager. // // NOTE: mutating the returned slice is not supported. +{{- reserveMethod $configurationName "Nodes"}} func (c *{{$configurationName}}) Nodes() []*{{$nodeName}} { rawNodes := c.RawConfiguration.Nodes() nodes := make([]*{{$nodeName}}, len(rawNodes)) @@ -91,6 +99,7 @@ func (c *{{$configurationName}}) Nodes() []*{{$nodeName}} { // AllNodes returns a slice of each available node of all subconfigurations. Sorted by node id. // // NOTE: mutating the returned slice is not supported. +{{- reserveMethod $configurationName "AllNodes"}} func (c *{{$configurationName}}) AllNodes() []*{{$nodeName}} { rawNodes := c.RawConfiguration.AllNodes() nodes := make([]*{{$nodeName}}, len(rawNodes)) @@ -101,12 +110,14 @@ func (c *{{$configurationName}}) AllNodes() []*{{$nodeName}} { } // And returns a NodeListOption that can be used to create a new configuration combining c and d. +{{- reserveMethod $configurationName "And"}} func (c {{$configurationName}}) And(d *{{$configurationName}}) {{$nodeListOptions}} { 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. +{{- reserveMethod $configurationName "Except"}} func (c {{$configurationName}}) Except(rm *{{$configurationName}}) {{$nodeListOptions}} { return c.RawConfiguration.Except(rm.RawConfiguration) } 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 9a5a1af8..00000000 --- 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 *{{$configurationName}}) {{$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_multicast.go b/cmd/protoc-gen-gorums/gengorums/template_multicast.go index 40c56ad8..c468ee28 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_multicast.go +++ b/cmd/protoc-gen-gorums/gengorums/template_multicast.go @@ -15,6 +15,8 @@ var mcVar = ` {{- $callOpt := use "gorums.CallOption" .GenFile}} ` +var multicastReserve = `{{reserveMethod $configurationName $method}}` + var multicastSignature = `func (c *{{$configurationName}}) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}},` + @@ -41,5 +43,6 @@ var multicastCall = commonVariables + mcVar + multicastRefImports + quorumCallComment + + multicastReserve + multicastSignature + multicastBody diff --git a/cmd/protoc-gen-gorums/gengorums/template_node.go b/cmd/protoc-gen-gorums/gengorums/template_node.go index e7f26b16..fadaeee2 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_node.go +++ b/cmd/protoc-gen-gorums/gengorums/template_node.go @@ -10,8 +10,9 @@ var nodeStructs = ` {{- $genFile := .GenFile}} {{- range .Services}} {{- $service := .GoName}} - {{- $nodeName := serviceTypeName $service "Node"}} + {{- $nodeName := printf "%sNode" $service}} // {{$nodeName}} holds the node specific methods for the {{$service}} service. + {{- reserveName $nodeName}} type {{$nodeName}} struct { *gorums.RawNode } diff --git a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go index bf12253e..b72b937c 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go +++ b/cmd/protoc-gen-gorums/gengorums/template_quorumcall.go @@ -8,9 +8,9 @@ var commonVariables = ` {{- $out := out .GenFile .Method}} {{- $intOut := internalOut $out}} {{- $unexportOutput := unexport .Method.Output.GoIdent.GoName}} -{{- $serviceName := .Method.Parent.GoName}} -{{- $nodeName := serviceTypeName $serviceName "Node"}} -{{- $configurationName := serviceTypeName $serviceName "Configuration"}} +{{- $service := .Method.Parent.GoName}} +{{- $nodeName := printf "%sNode" $service}} +{{- $configurationName := printf "%sConfiguration" $service}} ` // Common variables used in several template functions. @@ -39,6 +39,8 @@ var quorumCallComment = ` {{end -}} ` +var quorumCallReserve = `{{reserveMethod $configurationName $method}}` + var quorumCallSignature = `func (c *{{$configurationName}}) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}})` + @@ -72,5 +74,6 @@ var quorumCall = commonVariables + quorumCallVariables + qcVar + quorumCallComment + + quorumCallReserve + quorumCallSignature + quorumCallBody diff --git a/cmd/protoc-gen-gorums/gengorums/template_rpc.go b/cmd/protoc-gen-gorums/gengorums/template_rpc.go index 9c54a37d..5f829679 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_rpc.go +++ b/cmd/protoc-gen-gorums/gengorums/template_rpc.go @@ -7,6 +7,8 @@ var rpcVar = ` {{- $context := use "context.Context" .GenFile}} ` +var rpcReserve = `{{reserveMethod $nodeName $method}}` + var rpcSignature = `func (n *{{$nodeName}}) {{$method}}(` + `ctx {{$context}}, in *{{$in}}` + `{{perNodeFnType .GenFile .Method ", f"}}) (resp *{{$out}}, err error) { @@ -34,5 +36,6 @@ var rpcBody = ` cd := {{$callData}}{ var rpcCall = commonVariables + rpcVar + quorumCallComment + + rpcReserve + rpcSignature + rpcBody diff --git a/cmd/protoc-gen-gorums/gengorums/template_server.go b/cmd/protoc-gen-gorums/gengorums/template_server.go index 40a21ff7..716c2cb8 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_server.go +++ b/cmd/protoc-gen-gorums/gengorums/template_server.go @@ -11,7 +11,7 @@ var serverServicesBegin = ` {{- $genFile := .GenFile}} {{- range .Services}} {{- $service := .GoName}} - {{- $serverName := serviceTypeName $service "Server"}} + {{- $serverName := printf "%sServer" $service}} ` var serverServicesEnd = ` @@ -20,6 +20,7 @@ var serverServicesEnd = ` var serverInterface = ` // {{$serverName}} is the server-side API for the {{$service}} Service +{{- reserveName $serverName}} type {{$serverName}} interface { {{- range .Methods}} {{- if isOneway .}} @@ -34,7 +35,12 @@ type {{$serverName}} interface { ` var registerInterface = ` -func Register{{$serverName}}(srv *{{use "gorums.Server" $genFile}}, impl {{$serverName}}) { +{{- $funcName := printf "Register%s" $serverName}} +// {{$funcName}} adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client +{{- reserveName $funcName}} +func {{$funcName}}(srv *{{use "gorums.Server" $genFile}}, impl {{$serverName}}) { {{- range .Methods}} srv.RegisterHandler("{{.Desc.FullName}}", func(ctx {{$context}}, in *{{$gorumsMessage}}, {{if isOneway .}} _ {{- else}} finished {{- end}} chan<- *{{$gorumsMessage}}) { req := in.Message.(*{{in $genFile .}}) diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index f5a42736..388e8e0e 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: storage/proto/storage.proto @@ -83,7 +83,7 @@ func (c *StorageConfiguration) SubStorageConfiguration(cfg gorums.NodeListOption // StorageConfigurationFromRaw returns a new StorageConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -212,6 +212,9 @@ type StorageServer interface { WriteMulticast(ctx gorums.ServerCtx, request *WriteRequest) } +// RegisterStorageServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterStorageServer(srv *gorums.Server, impl StorageServer) { srv.RegisterHandler("storage.Storage.ReadRPC", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*ReadRequest) diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index d4648686..b46b587e 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: config/config.proto @@ -78,7 +78,7 @@ func (c *ConfigTestConfiguration) SubConfigTestConfiguration(cfg gorums.NodeList // ConfigTestConfigurationFromRaw returns a new ConfigTestConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -148,6 +148,9 @@ type ConfigTestServer interface { Config(ctx gorums.ServerCtx, request *Request) (response *Response, err error) } +// RegisterConfigTestServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterConfigTestServer(srv *gorums.Server, impl ConfigTestServer) { srv.RegisterHandler("config.ConfigTest.Config", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index 7d7aa9a0..1717b046 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: correctable/correctable.proto @@ -81,7 +81,7 @@ func (c *CorrectableTestConfiguration) SubCorrectableTestConfiguration(cfg gorum // CorrectableTestConfigurationFromRaw returns a new CorrectableTestConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -167,6 +167,9 @@ type CorrectableTestServer interface { CorrectableStream(ctx gorums.ServerCtx, request *CorrectableRequest, send func(response *CorrectableResponse) error) error } +// RegisterCorrectableTestServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterCorrectableTestServer(srv *gorums.Server, impl CorrectableTestServer) { srv.RegisterHandler("correctable.CorrectableTest.Correctable", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*CorrectableRequest) diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index 82190eb6..bf5896d9 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: dummy/dummy.proto @@ -63,7 +63,7 @@ func (c *DummyConfiguration) SubDummyConfiguration(cfg gorums.NodeListOption) (s // DummyConfigurationFromRaw returns a new DummyConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -136,6 +136,9 @@ type DummyServer interface { Test(ctx gorums.ServerCtx, request *Empty) (response *Empty, err error) } +// RegisterDummyServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterDummyServer(srv *gorums.Server, impl DummyServer) { srv.RegisterHandler("dummy.Dummy.Test", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Empty) diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index d03e81fb..67637f5e 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: metadata/metadata.proto @@ -64,7 +64,7 @@ func (c *MetadataTestConfiguration) SubMetadataTestConfiguration(cfg gorums.Node // MetadataTestConfigurationFromRaw returns a new MetadataTestConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -150,6 +150,9 @@ type MetadataTestServer interface { WhatIP(ctx gorums.ServerCtx, request *emptypb.Empty) (response *IPAddr, err error) } +// RegisterMetadataTestServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterMetadataTestServer(srv *gorums.Server, impl MetadataTestServer) { srv.RegisterHandler("metadata.MetadataTest.IDFromMD", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*emptypb.Empty) diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index 4b023538..cabe13c5 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: oneway/oneway.proto @@ -81,7 +81,7 @@ func (c *OnewayTestConfiguration) SubOnewayTestConfiguration(cfg gorums.NodeList // OnewayTestConfigurationFromRaw returns a new OnewayTestConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -174,6 +174,9 @@ type OnewayTestServer interface { MulticastPerNode(ctx gorums.ServerCtx, request *Request) } +// RegisterOnewayTestServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterOnewayTestServer(srv *gorums.Server, impl OnewayTestServer) { srv.RegisterHandler("oneway.OnewayTest.Unicast", func(ctx gorums.ServerCtx, in *gorums.Message, _ chan<- *gorums.Message) { req := in.Message.(*Request) diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index 19a0c271..26fe6385 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: ordering/order.proto @@ -80,7 +80,7 @@ func (c *GorumsTestConfiguration) SubGorumsTestConfiguration(cfg gorums.NodeList // GorumsTestConfigurationFromRaw returns a new GorumsTestConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -181,6 +181,9 @@ type GorumsTestServer interface { UnaryRPC(ctx gorums.ServerCtx, request *Request) (response *Response, err error) } +// RegisterGorumsTestServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterGorumsTestServer(srv *gorums.Server, impl GorumsTestServer) { srv.RegisterHandler("ordering.GorumsTest.QC", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 05336149..ab96fde5 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: qf/qf.proto @@ -79,7 +79,7 @@ func (c *QuorumFunctionConfiguration) SubQuorumFunctionConfiguration(cfg gorums. // QuorumFunctionConfigurationFromRaw returns a new QuorumFunctionConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -163,6 +163,9 @@ type QuorumFunctionServer interface { IgnoreReq(ctx gorums.ServerCtx, request *Request) (response *Response, err error) } +// RegisterQuorumFunctionServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterQuorumFunctionServer(srv *gorums.Server, impl QuorumFunctionServer) { srv.RegisterHandler("qf.QuorumFunction.UseReq", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 1fe463b1..00e349e6 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: tls/tls.proto @@ -63,7 +63,7 @@ func (c *TLSConfiguration) SubTLSConfiguration(cfg gorums.NodeListOption) (subCf // TLSConfigurationFromRaw returns a new TLSConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -136,6 +136,9 @@ type TLSServer interface { TestTLS(ctx gorums.ServerCtx, request *Request) (response *Response, err error) } +// RegisterTLSServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterTLSServer(srv *gorums.Server, impl TLSServer) { srv.RegisterHandler("tls.TLS.TestTLS", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Request) diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index eed67e06..4d129c8d 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+daaa6535 +// protoc-gen-gorums v0.9.0-devel+a35cbf26 // protoc v6.30.2 // source: unresponsive/unresponsive.proto @@ -63,7 +63,7 @@ func (c *UnresponsiveConfiguration) SubUnresponsiveConfiguration(cfg gorums.Node // UnresponsiveConfigurationFromRaw returns a new UnresponsiveConfiguration from the given raw configuration. // -// This function may for example be used to "clone" a configuration but install a different QuorumSpec: +// This function may for example be used to "clone" a configuration: // // cfg1, err := mgr.NewConfiguration(qspec1, opts...) // cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2) @@ -136,6 +136,9 @@ type UnresponsiveServer interface { TestUnresponsive(ctx gorums.ServerCtx, request *Empty) (response *Empty, err error) } +// RegisterUnresponsiveServer adds rpc handler functions to a server, +// the handlers decide how the server responds when it receives +// a request from a client func RegisterUnresponsiveServer(srv *gorums.Server, impl UnresponsiveServer) { srv.RegisterHandler("unresponsive.Unresponsive.TestUnresponsive", func(ctx gorums.ServerCtx, in *gorums.Message, finished chan<- *gorums.Message) { req := in.Message.(*Empty)