You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by bismy <bi...@qq.com> on 2018/03/05 00:43:04 UTC

Re: [Discussion]Improve metrics health checker register mode

spring injection or SPI is preferred, as have done in other modules 


------------------ Original ------------------
From: Jimin Wu <wu...@apache.org>
Date: Tue,Jan 9,2018 10:03 AM
To: dev <de...@servicecomb.apache.org>
Subject: Re: [Discussion]Improve metrics health checker register mode





On 2018-01-08 15:29, Willem Jiang <wi...@gmail.com> wrote: 
> The annotation way just a common use case in Spring. I don't think it will
> slow down your application startup processing too much.
> 
> You don't need to do the work yourself, Spring support it out of box.
> we could add @Service  to specify the instance of HealthChecker.
> We could use the @Autowire to inject the instance to registry without
> changing anything.
> 
> 
> 
> 
> Willem Jiang
> 
> Blog: http://willemjiang.blogspot.com (English)
>           http://jnn.iteye.com  (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
> 
> On Mon, Jan 8, 2018 at 3:15 PM, 郑扬勇 <ya...@qq.com> wrote:
> 
> > Hi everyone:
> >    Current we support user use "HealthCheckerManager.register(HealthChecker
> > checker)" to register his own health checker,and I think we may make this
> > registration more easier.
> >    1. The first way is implement an Annotation like @Health,like this :
> >
> >               @Health
> >               public class CustomHealthCheckerAnnotation implements
> > HealthChecker {...}
> >
> >    This way don't need any more config,but the disadvantage is that we
> > need scan all package find out those checkers like :
> >
> >               ClassPathScanningCandidateComponentProvider scanner = new
> > ClassPathScanningCandidateComponentProvider(false);
> >              scanner.addIncludeFilter(new AnnotationTypeFilter(Health.
> > class));
> >              for (BeanDefinition definition : scanner.findCandidateComponents("./"))
> > { ...}
> >
> >    this stage may slow.
> >
> >    2.The second way is use java SPI, use declare checkers in
> > META-INF/services/xxx,It's more fast but need config.
> >
> >    Any suggestion is welcome!
> >
> >  Best Regards & Thanks!
> >  zhengyangyong
> 

infact, spring need to write component-scan, otherwise got nothing.

and in our old production, we faced this slow scan problem many times.