package toolkit import ( "time" "github.com/go-kit/kit/log" consulsd "github.com/go-kit/kit/sd/consul" consulapi "github.com/hashicorp/consul/api" ) // ServiceOptions server options type ServiceOptions struct { // Address is the address of the Consul server Address string // Scheme is the URI scheme for the Consul server Scheme string // Datacenter to use. If not provided, the default agent datacenter is used. Datacenter string // Transport is the Transport to use for the http client. //Transport *http.Transport // HttpClient is the client to use. Default will be // used if not provided. //HttpClient *http.Client // HttpAuth is the auth info to use for http access. //HttpAuth *HttpBasicAuth // WaitTime limits how long a Watch will block. If not provided, // the agent default values will be used. WaitTime time.Duration // Token is used to provide a per-request ACL token // which overrides the agent's default token. Token string //TLSConfig TLSConfig } // NewConsulInstancer consul Instancer func NewConsulInstancer(options ServiceOptions, name string, tags []string, passingOnly bool, logger log.Logger) (instancer *consulsd.Instancer, err error) { var client consulsd.Client config := consulapi.DefaultConfig() config.Address = options.Address config.Scheme = options.Scheme config.Datacenter = options.Datacenter config.WaitTime = options.WaitTime config.Token = options.Token consulClient, err := consulapi.NewClient(config) if err != nil { //logger.Log("err", err) return } client = consulsd.NewClient(consulClient) instancer = consulsd.NewInstancer(client, logger, name, tags, passingOnly) return }