diff --git a/benchmark/benchmark_gorums.pb.go b/benchmark/benchmark_gorums.pb.go index 95129d55..e8eaf13f 100644 --- a/benchmark/benchmark_gorums.pb.go +++ b/benchmark/benchmark_gorums.pb.go @@ -30,22 +30,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/cmd/protoc-gen-gorums/gengorums/template_static.go b/cmd/protoc-gen-gorums/gengorums/template_static.go index 0b88f88d..0bbcd5ef 100644 --- a/cmd/protoc-gen-gorums/gengorums/template_static.go +++ b/cmd/protoc-gen-gorums/gengorums/template_static.go @@ -19,22 +19,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/examples/go.mod b/examples/go.mod index e2fe9325..2342412b 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -1,6 +1,6 @@ module github.com/relab/gorums/examples -go 1.22 +go 1.22.1 require ( github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 diff --git a/examples/storage/proto/storage_gorums.pb.go b/examples/storage/proto/storage_gorums.pb.go index fdd9c86a..62680263 100644 --- a/examples/storage/proto/storage_gorums.pb.go +++ b/examples/storage/proto/storage_gorums.pb.go @@ -30,22 +30,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/config/config_gorums.pb.go b/tests/config/config_gorums.pb.go index 72eeb510..f8748cfc 100644 --- a/tests/config/config_gorums.pb.go +++ b/tests/config/config_gorums.pb.go @@ -29,22 +29,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/correctable/correctable_gorums.pb.go b/tests/correctable/correctable_gorums.pb.go index c4c9aa19..47e6d00d 100644 --- a/tests/correctable/correctable_gorums.pb.go +++ b/tests/correctable/correctable_gorums.pb.go @@ -31,22 +31,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/dummy/dummy_gorums.pb.go b/tests/dummy/dummy_gorums.pb.go index e6a3ed88..d72db19a 100644 --- a/tests/dummy/dummy_gorums.pb.go +++ b/tests/dummy/dummy_gorums.pb.go @@ -28,22 +28,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/metadata/metadata_gorums.pb.go b/tests/metadata/metadata_gorums.pb.go index cd302c86..0cb5504c 100644 --- a/tests/metadata/metadata_gorums.pb.go +++ b/tests/metadata/metadata_gorums.pb.go @@ -29,22 +29,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/oneway/oneway_gorums.pb.go b/tests/oneway/oneway_gorums.pb.go index 2f1f244f..8d60009f 100644 --- a/tests/oneway/oneway_gorums.pb.go +++ b/tests/oneway/oneway_gorums.pb.go @@ -29,22 +29,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/ordering/order_gorums.pb.go b/tests/ordering/order_gorums.pb.go index d55bd61a..9f21f7a5 100644 --- a/tests/ordering/order_gorums.pb.go +++ b/tests/ordering/order_gorums.pb.go @@ -29,22 +29,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/qf/qf_gorums.pb.go b/tests/qf/qf_gorums.pb.go index 395635e8..617d42bb 100644 --- a/tests/qf/qf_gorums.pb.go +++ b/tests/qf/qf_gorums.pb.go @@ -29,22 +29,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/tls/tls_gorums.pb.go b/tests/tls/tls_gorums.pb.go index 2da572f0..594e212d 100644 --- a/tests/tls/tls_gorums.pb.go +++ b/tests/tls/tls_gorums.pb.go @@ -28,22 +28,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil diff --git a/tests/unresponsive/unresponsive_gorums.pb.go b/tests/unresponsive/unresponsive_gorums.pb.go index 5ca662c1..d36abd50 100644 --- a/tests/unresponsive/unresponsive_gorums.pb.go +++ b/tests/unresponsive/unresponsive_gorums.pb.go @@ -28,22 +28,25 @@ type Configuration struct { nodes []*Node } -// Clone returns a new Configuration that is a copy of c with a different QuorumSpec. -// 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. -func (c *Configuration) Clone(qspec QuorumSpec) (*Configuration, error) { +// 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: c.RawConfiguration, + RawConfiguration: rawCfg, qspec: qspec, } // initialize the nodes slice - newCfg.nodes = make([]*Node, c.Size()) - for i, n := range c.RawConfiguration { + newCfg.nodes = make([]*Node, newCfg.Size()) + for i, n := range rawCfg { newCfg.nodes[i] = &Node{n} } return newCfg, nil