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 support for tags #59

Merged
merged 3 commits into from
Jan 4, 2016
Merged

Conversation

justenwalker
Copy link
Contributor

For #10

Add support for tags in the service configuration. Didn't seem like too much work to add, so I'm afraid I may have glossed over some important details.

Another set of eyes appreciated.

@@ -65,6 +65,7 @@ type ServiceConfig struct {
Port int `json:"port"`
TTL int `json:"ttl"`
Interfaces json.RawMessage `json:"interfaces"`
Tags []string `json:"tags,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're going to need to include tags for the BackendConfig as well. It's my understanding that the primary use case for this that @misterbisson was talking about in #10 was being able to split out services for e.g. dev vs prod. So when we query Consul we're probably going to want to have a list of tags to send to checkHealth and then on to Health.Service so that we're optionally filtering by tag.

@justenwalker
Copy link
Contributor Author

@tgross What would the filter behavior be for tags on a Backend. Would they filter with AND (Must have every tag) or with OR (must have one of the tags)

Or to make things easier - should it just be 1 tag.

Consul API defines server-side filtering on a tag: https://www.consul.io/docs/agent/http/health.html#health_service But it doesn't go into detail about if it parses a comma-separated list of tags, or if it expects just 1 tag.

@justenwalker
Copy link
Contributor Author

I checked the consul codebase for clarification. It just accepts 1 tag (ignoring case) and filters if that tag is not found. So I think we should just use a single tag.

We could support multiple tags by requesting all services and post-filtering them, but we still have to figure out what behavior we want for that (AND or OR)

@tgross
Copy link
Contributor

tgross commented Jan 4, 2016

I'm feeling like there's going to come a point where we want query-with-multiple-tags support but without a backend that supports it I feel that'd be YAGNI. It's easy enough to add it in later.

@@ -85,6 +87,15 @@ func TestValidConfigParse(t *testing.T) {
t.Errorf("Expected 3 args but got unexpected results: %v", args)
}

expectedTags := []string{"tag1", "tag2"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make sure we have a test for empty tags too? Just to verify that we don't regress with it down the road?

@tgross
Copy link
Contributor

tgross commented Jan 4, 2016

Ok, this LGTM.

tgross added a commit that referenced this pull request Jan 4, 2016
@tgross tgross merged commit 586b540 into TritonDataCenter:master Jan 4, 2016
@justenwalker justenwalker deleted the service_tags branch January 5, 2016 14:56
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.

2 participants