Skip to content

Commit

Permalink
fix: correct err returned, removed named returns
Browse files Browse the repository at this point in the history
  • Loading branch information
vidarandrebo committed Jan 30, 2024
1 parent 674c033 commit b98a8c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ cmd/benchmark/benchmark
ideas.txt

cmd/protoc-gen-gorums/gengorums/template_static.go.bak

# jetbrains IDE files
.idea/
6 changes: 3 additions & 3 deletions rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ type CallData struct {
// RPCCall executes a remote procedure call on the node.
//
// This method should be used by generated code only.
func (n *RawNode) RPCCall(ctx context.Context, d CallData) (resp protoreflect.ProtoMessage, err error) {
func (n *RawNode) RPCCall(ctx context.Context, d CallData) (protoreflect.ProtoMessage, error) {
md := &ordering.Metadata{MessageID: n.mgr.getMsgID(), Method: d.Method}
replyChan := make(chan response, 1)
n.channel.enqueue(request{ctx: ctx, msg: &Message{Metadata: md, Message: d.Message}}, replyChan, false)

select {
case r := <-replyChan:
if r.err != nil {
return nil, err
return nil, r.err
}
return r.msg, nil
case <-ctx.Done():
return resp, ctx.Err()
return nil, ctx.Err()
}
}
12 changes: 12 additions & 0 deletions rpc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gorums_test

import (
"testing"
)

func TestRPCCall(t *testing.T) {
// TODO implement test for RPCCall
if true == false {
t.Errorf("should be true")
}
}

0 comments on commit b98a8c2

Please sign in to comment.