Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rpc): implement Err() #165

Open
pancsta opened this issue Nov 23, 2024 · 3 comments
Open

feat(rpc): implement Err() #165

pancsta opened this issue Nov 23, 2024 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers p:2 Medium priority pkg-rpc

Comments

@pancsta
Copy link
Owner

pancsta commented Nov 23, 2024

Remote Err() is simply a getter.

@pancsta pancsta added enhancement New feature or request pkg-rpc good first issue Good for newcomers p:2 Medium priority labels Nov 23, 2024
@sureshkrishnan-v
Copy link

Hi, I’d like to work on this issue as a first-time contributor—could you confirm if it’s available and share any guidelines?

@pancsta
Copy link
Owner Author

pancsta commented Dec 10, 2024

Hi, thanks for the interest. This still hasnt been implemented, here are the guidelines:

  • in rpcnames.go, new server enum entry & String()
  • in rpc.go, new response struct, like type RespErr struct {err error}
  • in rpc_server.go, new remote method, like
func (s *Server) RemoteErr(
	_ *rpc2.Client, args *Empty, resp *RespErr,
) error {
  • in rpc_worker.go, Err() should call callFailsafe
    • similar to Add(), but only return the result, without clock updates
    • Worker.err can now be removed
  • in rpc_test.go, smth like this:
func TestErr(t *testing.T) {
	// config
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
	source := utils.NewRelsRpcWorker(t, nil)
	_, _, s, c := NewTest(t, ctx, source, nil, nil, nil, false)

	// test
	source.AddErr(errors.New("test"))

	// assert
	
	// c.Worker.Err()
	// c.Worker.IsErr()
}

Feel free to ask questions. It will be interesting to see if errors.Is() will work out of the box...

@sureshkrishnan-v
Copy link

ok thank you i will work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers p:2 Medium priority pkg-rpc
Projects
None yet
Development

No branches or pull requests

2 participants