// Create a new Call to execute the "Get" method on node 4 with key "foo". call := &cockroach.GetRequest{ Key: []byte("foo"), } rpcCall := &cockroach.Call{ Method: "Get", Args: call, NodeID: 4, ... } // Execute the Call and get the response. responseBytes, err := rpcCall.Execute() if err != nil { log.Fatalf("Error executing RPC call: %v", err) } // Parse the response into a GetResponse object. response := &cockroach.GetResponse{} if err := proto.Unmarshal(responseBytes, response); err != nil { log.Fatalf("Error unmarshaling response: %v", err) }
// Create a new Call to execute a custom method on node 1. call := &myCustomMethodRequest{ ... } rpcCall := &cockroach.Call{ Method: "MyCustomMethod", Args: call, NodeID: 1, ... } // Send the Call asynchronously and don't wait for a response. rpcCall.SendAsync()In this example, a Call is created to execute a custom method on node 1 with some custom request type. The Call is then sent asynchronously, meaning the function does not wait for a response. Overall, the github.com.cockroachdb.cockroach.proto package provides a set of protocol buffer message definitions and generated Go types for communication between nodes in a CockroachDB cluster. The Call type specifically represents an RPC method call from one node to another, and can be used to execute methods and receive responses asynchronously.