spring-cloud-tencent icon indicating copy to clipboard operation
spring-cloud-tencent copied to clipboard

Bugfix: InstancePreRegisteredEvent and InstanceRegisteredEvent modify Registration info

Open galaxy-sea opened this issue 3 years ago • 4 comments

根据 Spring Cloud Commons的设计可以利用InstancePreRegisteredEventInstanceRegisteredEventRegistration进行一些相关骚操作, 比如InstancePreRegisteredEvent来修改metadata org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration#start()

	public void start() {
		if (!isEnabled()) {
			if (logger.isDebugEnabled()) {
				logger.debug("Discovery Lifecycle disabled. Not starting");
			}
			return;
		}

		// only initialize if nonSecurePort is greater than 0 and it isn't already running
		// because of containerPortInitializer below
		if (!this.running.get()) {
			this.context.publishEvent(
					new InstancePreRegisteredEvent(this, getRegistration()));
			register();
			if (shouldRegisterManagement()) {
				registerManagement();
			}
			this.context.publishEvent(
					new InstanceRegisteredEvent<>(this, getConfiguration()));
			this.running.compareAndSet(false, true);
		}

	}

galaxy-sea avatar Sep 12 '22 09:09 galaxy-sea

pls create issue first and like it

chuntaojun avatar Sep 13 '22 01:09 chuntaojun

hello @chuntaojun , look issue 584

galaxy-sea avatar Sep 13 '22 02:09 galaxy-sea

Use English PR title.

SkyeBeFreeman avatar Sep 13 '22 03:09 SkyeBeFreeman

Codecov Report

Merging #583 (18d13ba) into main (86211c5) will decrease coverage by 0.04%. The diff coverage is 33.33%.

@@             Coverage Diff              @@
##               main     #583      +/-   ##
============================================
- Coverage     76.32%   76.28%   -0.05%     
  Complexity      982      982              
============================================
  Files           186      186              
  Lines          3510     3512       +2     
  Branches        419      419              
============================================
  Hits           2679     2679              
- Misses          600      602       +2     
  Partials        231      231              
Impacted Files Coverage Δ
...nt/cloud/polaris/registry/PolarisRegistration.java 80.64% <33.33%> (-5.57%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Sep 13 '22 04:09 codecov-commenter