func (l *FunctionLookup) byName(ctx context.Context, name string) (string, error) {
	serviceFilter := filters.NewArgs()
	serviceFilter.Add("name", name)
	services, err := l.lister.ServiceList(ctx, types.ServiceListOptions{Filters: serviceFilter})
	if err != nil {
		return "", err
	}
	if len(services) > 0 {
		return name, nil
	}
	return "", fmt.Errorf("could not resolve: %s", name)
}
resolve the function by checking the available docker VIP based resolution
package handlers
import (
	"context"
	"fmt"
	"math/rand"
	"net"
	"net/url"
	"time"
	"github.com/docker/docker/api/types"
	"github.com/docker/docker/api/types/filters"
	"github.com/docker/docker/api/types/swarm"
)
const watchdogPort = 8080
const urlScheme = "http"
type ServiceLister interface {
	ServiceList(context.Context, types.ServiceListOptions) ([]swarm.Service, error)
}
type FunctionLookup struct {
	lister ServiceLister
	dnsRoundRobin bool
	scheme string
	dnsrrLookup func(context.Context, string) ([]net.IP, error)
}
func NewFunctionLookup(client ServiceLister, dnsRoundRobin bool) *FunctionLookup {
	return &FunctionLookup{
		lister:        client,
		dnsRoundRobin: dnsRoundRobin,
		scheme:        urlScheme,
		dnsrrLookup:   lookupIP,
	}
}
func (l *FunctionLookup) Resolve(name string) (u url.URL, err error) {
	return l.ResolveContext(context.Background(), name)
}
func (l *FunctionLookup) ResolveContext(ctx context.Context, name string) (u url.URL, err error) {
	if l.dnsRoundRobin {
		u.Host, err = l.byDNSRoundRobin(ctx, name)
	} else {
		u.Host, err = l.byName(ctx, name)
	}
	if err != nil {
		return u, err
	}
	u.Scheme = l.scheme
	return u, nil
}