Skip to content

Commit c9b3a16

Browse files
authored
Merge pull request #15 from netifi/feature/tagging-config
Feature/tagging config
2 parents 475d60e + 563f75b commit c9b3a16

1 file changed

Lines changed: 11 additions & 22 deletions

File tree

netifi-broker-client/src/main/java/com/netifi/broker/DefaultBuilderConfig.java

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import java.net.SocketAddress;
2424
import java.net.UnknownHostException;
2525
import java.util.ArrayList;
26+
import java.util.Arrays;
2627
import java.util.List;
27-
import java.util.stream.Stream;
2828

2929
/**
3030
* Gets current default configuration for {@link BrokerClient.Builder}. Can be overriden with System
@@ -148,27 +148,16 @@ static short getAdditionalConnectionFlags() {
148148
static Tags getTags() {
149149
Tags tags = Tags.empty();
150150
try {
151-
Stream<Tag> stream =
152-
conf.getObject("netifi.client.tags")
153-
.entrySet()
154-
.stream()
155-
.map(
156-
e -> {
157-
String key = e.getKey();
158-
ConfigValue configValue = e.getValue();
159-
if (configValue.valueType() == ConfigValueType.STRING) {
160-
String value = (String) configValue.unwrapped();
161-
if (value.isEmpty()) {
162-
throw new IllegalArgumentException("Tag mapping " + key + " is empty");
163-
}
164-
return Tag.of(key, value);
165-
}
166-
throw new IllegalArgumentException(
167-
"Tag mapping " + key + " is not a string: " + configValue);
168-
});
169-
tags = Tags.of(stream::iterator);
170-
} catch (ConfigException.Missing m) {
171-
151+
Arrays.stream(conf.getString("netifi.client.tags").split(","))
152+
.forEach(
153+
s -> {
154+
String[] t = s.split(":");
155+
Tag tag = Tag.of(t[0], t[1]);
156+
tags.and(tag);
157+
});
158+
159+
} catch (Throwable t) {
160+
System.err.println("error parsing tags from config: " + t.getMessage());
172161
}
173162

174163
return tags;

0 commit comments

Comments
 (0)