Closed ryansb closed 8 years ago
@ryansb With revision fec96e945dd9182fc60432e60f27d66ed7fefb26, when I use XML API like this:
e := fargo.NewConn("http://127.0.0.1:8080/eureka/v2")
//e.UseJson = true
i := &fargo.Instance{
HostName: "test.test",
App: "apptest",
IPAddr: "127.0.0.1",
Port: 6666,
DataCenterInfo: fargo.DataCenterInfo{
Name: fargo.MyOwn,
},
}
i.SetMetadataString("hello", "world")
err := e.RegisterInstance(i)
The register send this to eureka (with empt metadata tag):
<instance>
<hostName>test.test</hostName>
<app>apptest</app>
<ipAddr>127.0.0.1</ipAddr>
<vipAddress></vipAddress>
<secureVipAddress></secureVipAddress>
<status></status>
<overriddenstatus></overriddenstatus>
<port>6666</port>
<securePort>0</securePort>
<homePageUrl></homePageUrl>
<statusPageUrl></statusPageUrl>
<healthCheckUrl></healthCheckUrl>
<countryId>0</countryId>
<dataCenterInfo>
<name>MyOwn</name>
<metadata>
<ami-launch-index></ami-launch-index>
<local-hostname></local-hostname>
<availability-zone></availability-zone>
<instance-id></instance-id>
<public-ipv4></public-ipv4>
<public-hostname></public-hostname>
<ami-manifest-path></ami-manifest-path>
<local-ipv4></local-ipv4>
<hostname></hostname>
<ami-id></ami-id>
<instance-type></instance-type>
</metadata>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>0</renewalIntervalInSecs>
<durationInSecs>0</durationInSecs>
<registrationTimestamp>0</registrationTimestamp>
<lastRenewalTimestamp>0</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>0</serviceUpTimestamp>
</leaseInfo>
<metadata></metadata>
</instance>
When I use JSON API:
e := fargo.NewConn("http://127.0.0.1:8080/eureka/v2")
e.UseJson = true
i := &fargo.Instance{
HostName: "test.test",
App: "apptest",
IPAddr: "127.0.0.1",
Port: 6666,
DataCenterInfo: fargo.DataCenterInfo{
Name: fargo.MyOwn,
},
}
i.SetMetadataString("hello", "world")
err := e.RegisterInstance(i)
I have this json (with expected metadata):
{
"instance": {
"hostName": "test.test",
"app": "apptest",
"ipAddr": "127.0.0.1",
"vipAddress": "",
"secureVipAddress": "",
"status": "",
"overriddenstatus": "",
"port": {
"$": "6666",
"@enabled": ""
},
"securePort": {
"$": "0",
"@enabled": ""
},
"homePageUrl": "",
"statusPageUrl": "",
"healthCheckUrl": "",
"countryId": 0,
"dataCenterInfo": {
"name": "MyOwn",
"metadata": {
"ami-launch-index": "",
"local-hostname": "",
"availability-zone": "",
"instance-id": "",
"public-ipv4": "",
"public-hostname": "",
"ami-manifest-path": "",
"local-ipv4": "",
"hostname": "",
"ami-id": "",
"instance-type": ""
}
},
"leaseInfo": {
"renewalIntervalInSecs": 0,
"durationInSecs": 0,
"registrationTimestamp": 0,
"lastRenewalTimestamp": 0,
"evictionTimestamp": 0,
"serviceUpTimestamp": 0
},
"metadata": {
"hello": "world"
}
}
}
Surely, that xml.Marshal(v) (https://github.com/hudl/fargo/blob/master/net.go#L29) doesn't marshal the map (https://github.com/hudl/fargo/blob/master/struct.go#L116) as describe here: http://stackoverflow.com/questions/30928770/marshall-map-to-xml-in-go IHMO, you have to implement own marshaller for InstanceMetadata.
Thanks for all that info, I'll try to get to this over the weekend so we have feature parity between the XML and JSON APIs.
@jerome-laforge this should be fixed in #34, so you could pull down that branch if you need it. Sorry for taking so long on this bug.
Many thanks for this fix, I will pull it down and I will check whether everything is OK. I will send you my feedback before the end of the week. Many thanks Best regard Le 6 déc. 2015 9:28 PM, "Ryan Brown" notifications@github.com a écrit :
@jerome-laforge https://github.com/jerome-laforge this should be fixed in #34 https://github.com/hudl/fargo/pull/34, so you could pull down that branch if you need it. Sorry for taking so long on this bug.
— Reply to this email directly or view it on GitHub https://github.com/hudl/fargo/issues/32#issuecomment-162344919.
@ryansb I have just finished to test it with eureka 1.1.147 and 1.3.1 and that works like a charm. Thx. BR
@jerome-laforge you mentioned in #29 that you were having problems with the XML version of instance metadata, can you tell me more about what you're seeing?