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

Add tags service discovery #737

Merged

Conversation

id-regis
Copy link

Currently it's impossible to retrieve tags from service discovery or pass tags to an endpoint, this pull request allow to set tags then register them into service discovery provider. It also add host in Registration domain from Consul

@id-regis
Copy link
Author

Test are passing on my side only a timeout.
But host registration still doesn't work in Consul due to a bug in Boon (boonproject/boon#352)

@RichardHightower
Copy link
Member

I will take a look.

@RichardHightower
Copy link
Member

Are you sure?

The JsonMapper that ships with QBit is preconfigure to handle annotations.

This works

package io.advantageous.qbit.bugs;

import io.advantageous.boon.json.annotations.JsonProperty;
import io.advantageous.qbit.QBit;
import io.advantageous.qbit.json.JsonMapper;
import org.junit.Assert;
import org.junit.Test;

public class BoonBug352 {

    @Test
    public void test() {
        Registration registration = new Registration();
        registration.setName("name");
        registration.setHost("localhost");
        final JsonMapper mapper = QBit.factory().createJsonMapper();
        String jsonSource = "{\"Name\":\"name\",\"Address\":\"localhost\"}";
        Registration unserializedRegistration = mapper.fromJson(jsonSource, Registration.class);
        String json = mapper.toJson(unserializedRegistration);
        Assert.assertEquals(jsonSource, json);
    }

    public static class Registration {
        @JsonProperty("Name")
        private String name;
        @JsonProperty("Address")
        private String host;

        public String getName() {
            return name;
        }

        public Registration setName(String name) {
            this.name = name;
            return this;
        }

        public String getHost() {
            return host;
        }

        public Registration setHost(String host) {
            this.host = host;
            return this;
        }
    }

}

That said.. we should never output two fields. I will look into that.

@RichardHightower
Copy link
Member

Ok.. I found the issue.

@RichardHightower
Copy link
Member

Merge master into your branch and try it again.

@id-regis
Copy link
Author

Thank for the patch it fixes the issue. Build and tests pass on my side.

@RichardHightower RichardHightower merged commit 19c11ff into advantageous:master Jun 20, 2016
@RichardHightower
Copy link
Member

you are welcome.. thanks for contributing.

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

Successfully merging this pull request may close these issues.

None yet

2 participants