Skip to content

Commit

Permalink
jd-opensource#6: add requests metadata to all Syncers
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanzhibang committed Aug 31, 2024
1 parent 2f38996 commit 67c7e35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ private Response<Service> getService(String name, ServiceSyncMeta meta, SyncConf
*/
private void configure(SyncConfig config, HttpURLConnection conn) {
config.header(conn::setRequestProperty);
application.sync(conn::setRequestProperty);
conn.setRequestProperty("Accept", "application/json");
conn.setConnectTimeout((int) config.getTimeout());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.jd.live.agent.core.inject.annotation.Config;
import com.jd.live.agent.core.inject.annotation.Inject;
import com.jd.live.agent.core.inject.annotation.Injectable;
import com.jd.live.agent.core.instance.Application;
import com.jd.live.agent.core.parser.ObjectParser;
import com.jd.live.agent.core.parser.TypeReference;
import com.jd.live.agent.core.service.AbstractService;
Expand Down Expand Up @@ -85,6 +86,9 @@ public class LiveServiceSyncer extends AbstractService implements PolicyService,
@Inject(PolicySupervisor.COMPONENT_POLICY_SUPERVISOR)
private PolicySupervisor policySupervisor;

@Inject(Application.COMPONENT_APPLICATION)
private Application application;

@Inject(Timer.COMPONENT_TIMER)
private Timer timer;

Expand Down Expand Up @@ -320,6 +324,7 @@ private Response<Service> getService(String name, ServiceSyncMeta meta, SyncConf
*/
private void configure(SyncConfig config, HttpURLConnection conn) {
config.header(conn::setRequestProperty);
application.sync(conn::setRequestProperty);
conn.setRequestProperty("Accept", "application/json");
conn.setConnectTimeout((int) config.getTimeout());
}
Expand Down

0 comments on commit 67c7e35

Please sign in to comment.