consul

package module
v0.0.0-...-f9b57e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

registry-consul

use Consul as service register and discovery backend

How to use?

Client
import (
    ...
    consul "github.com/kitex-contrib/registry-consul"
    "github.com/cloudwego/kitex/client"
    ...
)

func main() {
    ...
    // "127.0.0.1:8500" is the default Consul agent address.
    // DataCenter/ACL/TLS/HTTP basic auth, etc. can use the ConsulResolverConfig to configure.
    r, err := consul.NewConsulResolver("127.0.0.1:8500", &consul.ConsulResolverConfig{})
    if err != nil {
        log.Fatal(err)
    }

    client, err := echo.NewClient("echo", client.WithResolver(r))
	if err != nil {
		log.Fatal(err)
	}
    ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConsulResolver

func NewConsulResolver(endpoint string, extraConfig *ConsulResolverConfig) (discovery.Resolver, error)

NewConsulResolver creates a consul based resolver.

Types

type ConsulResolverConfig

type ConsulResolverConfig struct {
	// Datacenter to use. If not provided, the default agent datacenter is used.
	Datacenter string

	// Token is used to provide a per-request ACL token
	// which overrides the agent's default token.
	ACLToken string

	// generate a TLSClientConfig that's useful for talking to Consul using TLS.
	TLSConfig *api.TLSConfig

	// HTTPAuth is used to authenticate http client with HTTP Basic Authentication
	HTTPAuth *api.HttpBasicAuth
}

ConsulResolverConfig is used to configure the creation of a client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL