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

Add GetLatestErrorMessage feature #138

Merged
merged 4 commits into from
Jul 28, 2019
Merged

Conversation

wangjuneng
Copy link
Contributor

What is the purpose of the change

Add GetLatestErrorMessage feature

Brief changelog

1、Add MQClientErrorContainer to save the latest error message
2、Provide C interface for getting the latest error message
3、Modify C interface CPullConsumer,CPushConsumer,CPushConsumer when occur error use MQClientErrorContainer save error message

Verifying this change

Follow this checklist to help us incorporate your contribution quickly and easily. Notice, it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when a cross-module dependency exists.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@ShannonDing
Copy link
Member

Maybe a character array defined in commom.c is enough. IMO, we only save the latest error message in C module, the error message can set to the array directly, so the standalone method in CPP does not need. What do you think about it?

@messense
Copy link
Member

I think this C API should be thread safe?

@wangjuneng
Copy link
Contributor Author

Maybe a character array defined in commom.c is enough. IMO, we only save the latest error message in C module, the error message can set to the array directly, so the standalone method in CPP does not need. What do you think about it?

I agree with your opinion,Define a character array in Common.c to save the latest error message.
But I think use global variable will be cause the variable name conflicts.
So Use standalone class to save the latest error message .
there have two benifit.
1.Resolve the variable name conflict.
2.Provide expansion capabilities for the future.

@ShannonDing
Copy link
Member

I think this C API should be thread safe?

Maybe we can refer to the processing logic of linux errorno and only keep the last error message. once an error occurs, we need to retrieve the error information immediately. in order to achieve simple logic, the following error information is allowed to cover the old error information.

@messense
Copy link
Member

@ShannonDing https://linux.die.net/man/3/errno

errno is defined by the ISO C standard to be a modifiable lvalue of type int, and must not be explicitly declared; errno may be a macro. errno is thread-local; setting it in one thread does not affect its value in any other thread.

I think the error information should be thread-local just like linux errno.

@ShannonDing ShannonDing added this to the 1.2.3 milestone Apr 23, 2019
@ShannonDing
Copy link
Member

@wangjuneng Could you please check the CI result?

extern "C" {
#endif

ROCKETMQCLIENT_API const char *GetLatestErrorMessage(); // Return the last error message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all files in this pr have wrong format, pls format them

@jonnxu jonnxu merged commit ed71e22 into apache:master Jul 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants