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

Support hystrix global SetterFactory and FallbackFactory #427

Closed
ScienJus opened this issue Dec 14, 2018 · 0 comments
Closed

Support hystrix global SetterFactory and FallbackFactory #427

ScienJus opened this issue Dec 14, 2018 · 0 comments
Milestone

Comments

@ScienJus
Copy link
Member

ScienJus commented Dec 14, 2018

Your scenes

describe your use scenes (why need this feature)

from sofastack/sofa-rpc-boot-projects#135 (comment)

In sofa-rpc-boot-project and sofa-boot, the user cannot register SetterFactory and FallbackFactory with ConsumerConfig.

So we provide some global settings that allow the user to create a single factory and loaded by all consumers, for example:

public class GlobalFallbackFactory implements FallbackFactory {
    @Override
    public Object create(FallbackContext context) {
        String interface = context.getRequest().getInterfaceId();
        if ("xxx.a.Service".equals(interface)) {
            return new ServiceAFallback();
        }
        if ("xxx.b.Service".equals(interface)) {
            return new ServiceBFallback();
        }
        return null;
    }
}

SofaHystrixConfig.registerGlobalFallbackFactory(new GlobalFallbackFactory());
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

No branches or pull requests

2 participants