com.aerospike.vector.client.internal.MultiAddressNameResolverFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of avs-client-java Show documentation
Show all versions of avs-client-java Show documentation
This project includes the Java client for Aerospike Vector Search for high-performance data interactions.
The newest version!
package com.aerospike.vector.client.internal;
import io.grpc.Attributes;
import io.grpc.EquivalentAddressGroup;
import io.grpc.NameResolver;
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.List;
class MultiAddressNameResolverFactory extends NameResolver.Factory {
private final List addresses;
public MultiAddressNameResolverFactory(List addresses) {
this.addresses = addresses.stream()
.map(EquivalentAddressGroup::new)
.toList();
}
@Override
public NameResolver newNameResolver(URI notUsedUri, NameResolver.Args args) {
return new NameResolver() {
@Override
public String getServiceAuthority() {
return "Authority";
}
@Override
public void start(Listener2 listener) {
ResolutionResult result = ResolutionResult.newBuilder()
.setAddresses(addresses)
.setAttributes(Attributes.EMPTY)
.build();
listener.onResult(result);
}
@Override
public void shutdown() {
// Implementation of shutdown if required
}
};
}
@Override
public String getDefaultScheme() {
return "multiaddress";
}
}