All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aerospike.vector.client.internal.MultiAddressNameResolverFactory Maven / Gradle / Ivy

Go to download

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";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy